// File: lega911[P]ijson/src/server.cpp
// Function: Loop::worker_result(ISlice, Connect*)
int Loop::worker_result(ISlice id, Connect *worker) {
    auto it = server->wait_response.find(id.as_string());
    if(it == server->wait_response.end()) return -1;
    Connect *client = it->second;
    server->wait_lock.lock();
    server->wait_response.erase(it);
    server->wait_lock.unlock();

    client->unlink();
    if(client->is_closed()) return -2;
    if(worker) client->send.status("200 OK")->header("Id", id)->done(worker->body);
    else client->send.status("503 Service Unavailable")->header("Id", id)->done(-1);
    client->status = Status::net;

    if(worker && worker->nloop != worker->need_loop) migrate(worker, client);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rsi, -0x18(%rbp)
movl %edx, -0x10(%rbp)
movq %rdi, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq 0x18(%rax), %rax
addq $0x20128, %rax          # imm = 0x20128
movq %rax, -0x98(%rbp)
leaq -0x50(%rbp), %rdi
movq %rdi, -0x90(%rbp)
leaq -0x18(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x1f340
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x2d980
movq %rax, -0x88(%rbp)
jmp 0x2c68b
movq -0x88(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x191e0
movq -0xa0(%rbp), %rax
movq 0x18(%rax), %rdi
addq $0x20128, %rdi          # imm = 0x20128
callq 0x2d9b0
movq %rax, -0x68(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2dfe0
testb $0x1, %al
jne 0x2c6cd
jmp 0x2c6f3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2c83a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x191e0
jmp 0x2c846
leaq -0x30(%rbp), %rdi
callq 0x2e010
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq 0x20(%rcx), %rcx
movq %rcx, -0x70(%rbp)
movq 0x18(%rax), %rdi
addq $0x20158, %rdi          # imm = 0x20158
callq 0x1fa50
movq -0xa0(%rbp), %rax
movq 0x18(%rax), %rdi
addq $0x20128, %rdi          # imm = 0x20128
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rsi
callq 0x2e030
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movq %rcx, -0x80(%rbp)
movq 0x18(%rax), %rdi
addq $0x20158, %rdi          # imm = 0x20158
callq 0x1fa80
movq -0x70(%rbp), %rdi
callq 0x19950
movq -0x70(%rbp), %rdi
callq 0x1fcc0
testb $0x1, %al
jne 0x2c777
jmp 0x2c783
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2c83a
cmpq $0x0, -0x28(%rbp)
je 0x2c7c6
movq -0x70(%rbp), %rdi
addq $0x18, %rdi
leaq 0xba98(%rip), %rsi      # 0x38231
callq 0x1b6d0
movq %rax, %rdi
leaq 0xce4d(%rip), %rsi      # 0x395f5
leaq -0x18(%rbp), %rdx
callq 0x1d660
movq %rax, %rdi
movq -0x28(%rbp), %rsi
addq $0xd0, %rsi
callq 0x1be40
jmp 0x2c7fa
movq -0x70(%rbp), %rdi
addq $0x18, %rdi
leaq 0xce7e(%rip), %rsi      # 0x39653
callq 0x1b6d0
movq %rax, %rdi
leaq 0xce11(%rip), %rsi      # 0x395f5
leaq -0x18(%rbp), %rdx
callq 0x1d660
movq %rax, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x1b770
movq -0x70(%rbp), %rax
movl $0x0, 0xcc(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x2c833
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x3c(%rcx), %eax
je 0x2c833
movq -0xa0(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0x2c850
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x194a0
nop