// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl $0x20058, %edi          # imm = 0x20058
addq 0x18(%rbx), %rdi
callq 0x134d4
testb %al, %al
je 0x111bd
callq 0x16a69
movl %eax, %r14d
movq 0x18(%rbx), %rax
movq 0x20110(%rax), %r15
movq 0x20118(%rax), %rax
movq %rax, -0x40(%rbp)
movq %rbx, -0x38(%rbp)
cmpq -0x40(%rbp), %r15
je 0x111cc
movq (%r15), %rdi
testq %rdi, %rdi
je 0x111b4
addq $0x18, %rdi
movq %rdi, -0x30(%rbp)
callq 0xd764
xorl %ecx, %ecx
movq %r15, -0x48(%rbp)
movq 0x18(%rbx), %rax
movslq 0x28(%rax), %rax
cmpq %rax, %rcx
jge 0x111ab
movq (%r15), %rax
movq 0x40(%rax), %rax
movq %rcx, -0x50(%rbp)
imulq $0xa0, %rcx, %rcx
movq 0x10(%rax,%rcx), %r15
movq 0x20(%rax,%rcx), %r13
movq 0x28(%rax,%rcx), %r12
movq 0x30(%rax,%rcx), %rbx
cmpq %rbx, %r15
je 0x11197
movq (%r15), %rdi
cmpl $0x0, 0xf8(%rdi)
je 0x11175
cmpl %r14d, 0xfc(%rdi)
ja 0x11175
cmpl $-0x1, (%rdi)
je 0x11175
cmpl $0x1, 0xcc(%rdi)
jne 0x11175
addq $0x50, %rdi
callq 0xd764
movq (%r15), %rdi
cmpl $0x1, 0xcc(%rdi)
jne 0x1116c
movl $0x5, 0xcc(%rdi)
addq $0x50, %rdi
callq 0xa220
movq (%r15), %rdi
cmpb $0x0, 0xf3(%rdi)
movl $0x0, %eax
pushq $0x6
popq %rcx
cmovnel %ecx, %eax
movl %eax, 0xcc(%rdi)
addq $0x18, %rdi
leaq 0x8360(%rip), %rsi      # 0x1947a
callq 0xb93e
movq %rax, %rdi
callq 0xbf60
movq (%r15), %rax
movl 0xf8(%rax), %ecx
addl %r14d, %ecx
movl %ecx, 0xfc(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
testb $0x8, 0x20(%rax)
je 0x11175
callq 0x16a89
movq 0xee7d(%rip), %rdi      # 0x1ffd0
movq %rax, %rsi
callq 0xa2e0
movq %rax, %rdi
leaq 0x8321(%rip), %rsi      # 0x19486
callq 0xa2e0
jmp 0x11175
addq $0x50, %rdi
callq 0xa220
addq $0x8, %r15
cmpq %r13, %r15
jne 0x1108c
movq 0x8(%r12), %r15
addq $0x8, %r12
leaq 0x200(%r15), %r13
jmp 0x1108c
movq -0x50(%rbp), %rcx
incq %rcx
movq -0x38(%rbp), %rbx
movq -0x48(%rbp), %r15
jmp 0x11055
movq -0x30(%rbp), %rdi
callq 0xa220
addq $0x8, %r15
jmp 0x1102c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20058, %edi          # imm = 0x20058
addq 0x18(%rbx), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa220
movq %rax, %rbx
movq -0x30(%rbp), %rdi
callq 0xa220
movq %rbx, %rdi
callq 0xa470