// File: JianjiaoSQ[P]MyPoorWebServer/webserver.cpp
// Function: WebServer::dealwithread(int)
void WebServer::dealwithread(int sockfd)
{
    tw_timer *timer = users_timer[sockfd].timer;

    //reactor
    if (1 == m_actormodel)
    {
        if (timer)
        {
            adjust_timer(timer);
        }

        //若监测到读事件，将该事件放入请求队列
        m_pool->append(users + sockfd, 0);

        while (true)
        {
            if (1 == users[sockfd].improv)
            {
                if (1 == users[sockfd].timer_flag)
                {
                    deal_timer(timer, sockfd);
                    users[sockfd].timer_flag = 0;
                }
                users[sockfd].improv = 0;
                break;
            }
        }
    }
    else
    {
        //proactor
        if (users[sockfd].read_once())
        {
            LOG_INFO("deal with the client(%s)", inet_ntoa(users[sockfd].get_address()->sin_addr));

            //若监测到读事件，将该事件放入请求队列
            m_pool->append_p(users + sockfd);

            if (timer)
            {
                adjust_timer(timer);
            }
        }
        else
        {
            deal_timer(timer, sockfd);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movq 0x1d580(%rcx), %rax
movslq -0xc(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x1, %eax
cmpl 0x18(%rcx), %eax
jne 0xc22b
cmpq $0x0, -0x18(%rbp)
je 0xc173
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xbcf0
movq -0x28(%rbp), %rax
movq 0xa0(%rax), %rdi
movq 0x28(%rax), %rsi
movslq -0xc(%rbp), %rax
imulq $0xf68, %rax, %rax      # imm = 0xF68
addq %rax, %rsi
xorl %edx, %edx
callq 0xcb50
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rcx
movslq -0xc(%rbp), %rax
imulq $0xf68, %rax, %rax      # imm = 0xF68
addq %rax, %rcx
movl $0x1, %eax
cmpl 0x4(%rcx), %eax
jne 0xc221
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rcx
movslq -0xc(%rbp), %rax
imulq $0xf68, %rax, %rax      # imm = 0xF68
addq %rax, %rcx
movl $0x1, %eax
cmpl (%rcx), %eax
jne 0xc202
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0xc(%rbp), %edx
callq 0xbd60
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0xf68, %rcx, %rcx      # imm = 0xF68
addq %rcx, %rax
movl $0x0, (%rax)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0xf68, %rcx, %rcx      # imm = 0xF68
addq %rcx, %rax
movl $0x0, 0x4(%rax)
jmp 0xc226
jmp 0xc197
jmp 0xc300
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rdi
movslq -0xc(%rbp), %rax
imulq $0xf68, %rax, %rax      # imm = 0xF68
addq %rax, %rdi
callq 0x5240
testb $0x1, %al
jne 0xc24f
jmp 0xc2ee
movq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpl 0x14(%rcx), %eax
jne 0xc2b6
callq 0x6df0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq 0x28(%rax), %rdi
movslq -0xc(%rbp), %rax
imulq $0xf68, %rax, %rax      # imm = 0xF68
addq %rax, %rdi
callq 0xcbf0
movl 0x4(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %edi
callq 0x31d0
movq -0x30(%rbp), %rdi
movq %rax, %rcx
movl $0x1, %esi
leaq 0x228b(%rip), %rdx      # 0xe52d
movb $0x0, %al
callq 0x9300
callq 0x6df0
movq %rax, %rdi
callq 0x9870
movq -0x28(%rbp), %rax
movq 0xa0(%rax), %rdi
movq 0x28(%rax), %rsi
movslq -0xc(%rbp), %rax
imulq $0xf68, %rax, %rax      # imm = 0xF68
addq %rax, %rsi
callq 0xcc10
cmpq $0x0, -0x18(%rbp)
je 0xc2ec
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xbcf0
jmp 0xc2fe
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0xc(%rbp), %edx
callq 0xbd60
jmp 0xc300
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)