// File: lega911[P]ijson/src/server.cpp
// Function: Loop::_check_timeout()
void Loop::_check_timeout() {
    if(!server->global_lock.try_lock()) return;

    u32 now = get_time_sec();
    for(const auto &ql : server->_queue_list) {
        if(!ql) continue;

        LOCK _l(ql->mutex);

        for(int i=0;i<server->threads;i++) {
            for(const auto &worker : ql->queue[i].workers) {
                if(!worker->ping) continue;
                if(worker->ping_timeout > now) continue;
                if(worker->is_closed()) continue;

                bool busy = true;
                if(worker->status == Status::worker_wait_job) {
                    worker->mutex.lock();
                    if(worker->status == Status::worker_wait_job) {
                        worker->status = Status::busy;
                        busy = false;
                    }
                    worker->mutex.unlock();
                }
                if(busy) continue;

                if(worker->worker_mode) worker->status = Status::worker_mode_async;
                else worker->status = Status::net;
                worker->send.status("408 Timeout")->done();
                worker->ping_timeout = now + worker->ping;
                if(server->log & 8) std::cout << ltime() << "408 Timeout\n";
            }
        }
    }
    server->global_lock.unlock();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x18(%rax), %rdi
addq $0x20058, %rdi          # imm = 0x20058
callq 0x2d620
testb $0x1, %al
jne 0x295d3
jmp 0x29905
callq 0x36940
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0xc(%rbp)
movq 0x18(%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 0x29622
jmp 0x298ee
leaq -0x20(%rbp), %rdi
callq 0x1f6a0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x2963e
jmp 0x298e0
movq -0x30(%rbp), %rax
movq (%rax), %rsi
addq $0x18, %rsi
leaq -0x38(%rbp), %rdi
callq 0x1f5d0
movl $0x0, -0x3c(%rbp)
movq -0xa8(%rbp), %rcx
movl -0x3c(%rbp), %eax
movq 0x18(%rcx), %rcx
cmpl 0x28(%rcx), %eax
jge 0x298d7
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x40(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0xa0, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x1f6c0
movq -0x48(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x1f6f0
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1f720
testb $0x1, %al
jne 0x296c3
jmp 0x298c7
leaq -0x68(%rbp), %rdi
callq 0x1f750
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq (%rax), %rax
cmpl $0x0, 0xf8(%rax)
jne 0x296eb
jmp 0x298b9
movq -0x90(%rbp), %rax
movq (%rax), %rax
movl 0xfc(%rax), %eax
cmpl -0xc(%rbp), %eax
jbe 0x29705
jmp 0x298b9
movq -0x90(%rbp), %rax
movq (%rax), %rdi
callq 0x1fcc0
movb %al, -0xa9(%rbp)
jmp 0x2971c
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x29728
jmp 0x2974d
jmp 0x298b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1f880
jmp 0x2990e
movb $0x1, -0x9d(%rbp)
movq -0x90(%rbp), %rax
movq (%rax), %rax
cmpl $0x1, 0xcc(%rax)
jne 0x297c1
movq -0x90(%rbp), %rax
movq (%rax), %rdi
addq $0x50, %rdi
callq 0x1fa50
jmp 0x2977c
movq -0x90(%rbp), %rax
movq (%rax), %rax
cmpl $0x1, 0xcc(%rax)
jne 0x297aa
movq -0x90(%rbp), %rax
movq (%rax), %rax
movl $0x5, 0xcc(%rax)
movb $0x0, -0x9d(%rbp)
movq -0x90(%rbp), %rax
movq (%rax), %rdi
addq $0x50, %rdi
callq 0x1fa80
jmp 0x297bf
jmp 0x297c1
testb $0x1, -0x9d(%rbp)
je 0x297cf
jmp 0x298b9
movq -0x90(%rbp), %rax
movq (%rax), %rax
testb $0x1, 0xf3(%rax)
je 0x297f8
movq -0x90(%rbp), %rax
movq (%rax), %rax
movl $0x6, 0xcc(%rax)
jmp 0x2980c
movq -0x90(%rbp), %rax
movq (%rax), %rax
movl $0x0, 0xcc(%rax)
movq -0x90(%rbp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
leaq 0xfca9(%rip), %rsi      # 0x394ca
callq 0x1b6d0
movq %rax, -0xb8(%rbp)
jmp 0x2982f
movq -0xb8(%rbp), %rdi
callq 0x1bf70
jmp 0x2983d
movq -0xa8(%rbp), %rax
movl -0xc(%rbp), %edx
movq -0x90(%rbp), %rcx
movq (%rcx), %rcx
addl 0xf8(%rcx), %edx
movq -0x90(%rbp), %rcx
movq (%rcx), %rcx
movl %edx, 0xfc(%rcx)
movq 0x18(%rax), %rax
movl 0x20(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x298b7
callq 0x36960
movq %rax, -0xc0(%rbp)
jmp 0x29884
movq -0xc0(%rbp), %rsi
movq 0x1d73e(%rip), %rdi     # 0x46fd0
callq 0x192e0
movq %rax, -0xc8(%rbp)
jmp 0x298a0
movq -0xc8(%rbp), %rdi
leaq 0xfc28(%rip), %rsi      # 0x394d6
callq 0x192e0
jmp 0x298b5
jmp 0x298b7
jmp 0x298b9
leaq -0x68(%rbp), %rdi
callq 0x1f7a0
jmp 0x296aa
jmp 0x298c9
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x29659
leaq -0x38(%rbp), %rdi
callq 0x1f880
leaq -0x20(%rbp), %rdi
callq 0x1f820
jmp 0x2960c
movq -0xa8(%rbp), %rax
movq 0x18(%rax), %rdi
addq $0x20058, %rdi          # imm = 0x20058
callq 0x1fa80
addq $0xd0, %rsp
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x194a0
nopw (%rax,%rax)