// File: JianjiaoSQ[P]MyPoorWebServer/webserver.cpp
// Function: WebServer::timer(int, sockaddr_in)
void WebServer::timer(int connfd, struct sockaddr_in client_address) {
    users[connfd].init(connfd, client_address, m_root, m_CONNTrigmode, m_close_log, m_user, m_passWord, m_databaseName);

    //初始化client_data数据
    //创建定时器，设置回调函数和超时时间，绑定用户数据，将定时器添加到链表中
    users_timer[connfd].address = client_address;
    users_timer[connfd].sockfd = connfd;
    /*
    util_timer *timer = new util_timer;
    timer->user_data = &users_timer[connfd];
    timer->cb_func = cb_func;
    time_t cur = time(NULL);
    timer->expire = cur + 3 * TIMESLOT;
    users_timer[connfd].timer = timer;
    utils.m_timer_lst.add_timer(timer);  */

    tw_timer *timer = new tw_timer(0,0);
    timer->user_data = &users_timer[connfd];
    timer->cb_func = cb_func;
    users_timer[connfd].timer = timer;

    utils.m_time_wheel.add_timer(timer,3 * TIMESLOT);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdx, -0x10(%rbp)
movq %rcx, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movq -0x18(%rbp), %rsi
movq %rsi, -0xa0(%rbp)
movq 0x28(%rsi), %rax
movslq -0x1c(%rbp), %rcx
movl %ecx, %edx
movl %edx, -0xbc(%rbp)
imulq $0xf68, %rcx, %rcx      # imm = 0xF68
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq 0x8(%rsi), %rax
movq %rax, -0xb0(%rbp)
movl 0x1d57c(%rsi), %eax
movl %eax, -0xa8(%rbp)
movl 0x14(%rsi), %eax
movl %eax, -0xa4(%rbp)
addq $0x38, %rsi
leaq -0x40(%rbp), %rdi
callq 0x31a0
movq -0xa0(%rbp), %rsi
addq $0x58, %rsi
leaq -0x60(%rbp), %rdi
callq 0x31a0
jmp 0xbb29
movq -0xa0(%rbp), %rsi
addq $0x78, %rsi
leaq -0x90(%rbp), %rdi
callq 0x31a0
jmp 0xbb42
movl -0xa4(%rbp), %r9d
movl -0xa8(%rbp), %r8d
movq -0xb0(%rbp), %rcx
movl -0xbc(%rbp), %esi
movq -0xb8(%rbp), %rdi
movq %rsp, %rax
leaq -0x90(%rbp), %rdx
movq %rdx, 0x10(%rax)
leaq -0x60(%rbp), %rdx
movq %rdx, 0x8(%rax)
leaq -0x40(%rbp), %rdx
movq %rdx, (%rax)
leaq -0x10(%rbp), %rdx
callq 0x4eb0
jmp 0xbb8c
leaq -0x90(%rbp), %rdi
callq 0x32c0
leaq -0x60(%rbp), %rdi
callq 0x32c0
leaq -0x40(%rbp), %rdi
callq 0x32c0
movq -0xa0(%rbp), %rax
movq 0x1d580(%rax), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
movups -0x10(%rbp), %xmm0
movups %xmm0, (%rcx,%rdx)
movslq -0x1c(%rbp), %rcx
movl %ecx, %edx
movq 0x1d580(%rax), %rax
shlq $0x5, %rcx
movl %edx, 0x10(%rax,%rcx)
movl $0x28, %edi
callq 0x3450
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
xorl %edx, %edx
movl %edx, %esi
callq 0xcb20
jmp 0xbbff
movq -0xa0(%rbp), %rdi
movq -0xc8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq 0x1d580(%rdi), %rcx
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x98(%rbp), %rax
leaq -0x729f(%rip), %rcx     # 0x49a0
movq %rcx, 0x8(%rax)
movq -0x98(%rbp), %rcx
movq 0x1d580(%rdi), %rax
movslq -0x1c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
addq $0x1d588, %rdi          # imm = 0x1D588
movq -0x98(%rbp), %rsi
movl $0xc, %edx
callq 0x42e0
addq $0xe0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xbcbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xbcb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x32c0
leaq -0x60(%rbp), %rdi
callq 0x32c0
leaq -0x40(%rbp), %rdi
callq 0x32c0
jmp 0xbce6
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
movl $0x28, %esi
callq 0x3460
movq -0x68(%rbp), %rdi
callq 0x3710
nop