// File: lega911[P]ijson/src/service.cpp
// Function: Service::_clean_dead_tasks()
void Service::_clean_dead_tasks() {
    LOCK _l(server->global_lock);
    for(const auto &ql : server->_queue_list) {
        if(ql == NULL) continue;
        if(!ql->mutex.try_lock()) continue;

        for(int nloop=0; nloop < server->threads; nloop++) {
            Queue *q = &ql->queue[nloop];

            auto it=q->workers.begin();
            while(it != q->workers.end()) {
                Connect *conn = *it;
                if(conn->is_closed() || conn->status != Status::worker_wait_job) {
                    it = q->workers.erase(it);
                    conn->unlink();
                } else {
                    it++;
                }
            }

            auto it2=q->clients.begin();
            while(it2 != q->clients.end()) {
                Message *msg = *it2;
                if(msg->conn && (msg->conn->is_closed() || msg->conn->status != Status::client_wait_result)) {
                    it2 = q->clients.erase(it2);
                    delete msg;
                } else {
                    it2++;
                }
            }
        }
        ql->mutex.unlock();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq 0x8(%rax), %rsi
addq $0x20058, %rsi          # imm = 0x20058
leaq -0x10(%rbp), %rdi
callq 0x1f5d0
movq -0x1a8(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x20110, %rax          # imm = 0x20110
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1f600
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1f630
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1f660
testb $0x1, %al
jne 0x35933
jmp 0x35c59
leaq -0x20(%rbp), %rdi
callq 0x1f6a0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x3594f
jmp 0x35c4b
movq -0x30(%rbp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
callq 0x2d620
testb $0x1, %al
jne 0x35968
jmp 0x35c4b
movl $0x0, -0x34(%rbp)
movq -0x1a8(%rbp), %rcx
movl -0x34(%rbp), %eax
movq 0x8(%rcx), %rcx
cmpl 0x28(%rcx), %eax
jge 0x35c37
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x40(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x1f6c0
movq -0x40(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x1f6f0
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1f720
testb $0x1, %al
jne 0x359d3
jmp 0x35ab5
leaq -0x60(%rbp), %rdi
callq 0x1f750
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0x1fcc0
movb %al, -0x1a9(%rbp)
jmp 0x359fa
movb -0x1a9(%rbp), %al
testb $0x1, %al
jne 0x35a1a
jmp 0x35a06
movq -0x88(%rbp), %rax
cmpl $0x1, 0xcc(%rax)
je 0x35a9e
movq -0x40(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
leaq -0x60(%rbp), %rsi
callq 0x2db20
movq -0x1c0(%rbp), %rsi
movq -0x1b8(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
callq 0x2dac0
jmp 0x35a58
movups -0xb8(%rbp), %xmm0
movups -0xa8(%rbp), %xmm1
movaps %xmm1, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movq -0x88(%rbp), %rdi
callq 0x19950
jmp 0x35a7c
jmp 0x35ab0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x1f880
jmp 0x35c6b
leaq -0xf8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x2db60
jmp 0x359b0
movq -0x40(%rbp), %rsi
addq $0x50, %rsi
leaq -0x118(%rbp), %rdi
callq 0x2d220
movq -0x40(%rbp), %rsi
addq $0x50, %rsi
leaq -0x138(%rbp), %rdi
callq 0x2d250
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x2d280
testb $0x1, %al
jne 0x35af9
jmp 0x35c27
leaq -0x118(%rbp), %rdi
callq 0x2d2b0
movq (%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x35c0d
movq -0x140(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1fcc0
movb %al, -0x1c1(%rbp)
jmp 0x35b39
movb -0x1c1(%rbp), %al
testb $0x1, %al
jne 0x35b5d
jmp 0x35b45
movq -0x140(%rbp), %rax
movq 0x18(%rax), %rax
cmpl $0x4, 0xcc(%rax)
je 0x35c0d
movq -0x40(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x1d8(%rbp)
leaq -0x180(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
leaq -0x118(%rbp), %rsi
callq 0x2d910
movq -0x1d8(%rbp), %rsi
movq -0x1d0(%rbp), %rdx
leaq -0x160(%rbp), %rdi
callq 0x2d8b0
jmp 0x35ba2
movq -0x160(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x150(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x140(%rbp), %rax
movq %rax, -0x1e0(%rbp)
cmpq $0x0, %rax
je 0x35c0b
movq -0x1e0(%rbp), %rdi
callq 0x2cae0
movq -0x1e0(%rbp), %rdi
movl $0x38, %esi
callq 0x19300
jmp 0x35c22
leaq -0x1a0(%rbp), %rdi
leaq -0x118(%rbp), %rsi
xorl %edx, %edx
callq 0x2d870
jmp 0x35ac9
jmp 0x35c29
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3596f
movq -0x30(%rbp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
callq 0x1fa80
jmp 0x35c49
jmp 0x35c4b
leaq -0x20(%rbp), %rdi
callq 0x1f820
jmp 0x3591d
leaq -0x10(%rbp), %rdi
callq 0x1f880
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x194a0
nopw (%rax,%rax)