// File: /workspace/github_c_makefile_star2_O1/sszllzss[P]webSocket_Libevent_ThreadPool/ev_httpd.cpp
// Function: bufferev_event_cb(bufferevent*, short, void*)
static void bufferev_event_cb(struct bufferevent *bev, short events,void *ctx)
{
    httpChilent_t *client = (httpChilent_t *)ctx;
    struct sockaddr_in *address = NULL; 
    char ip[INET_ADDRSTRLEN];
    BufferevMap::iterator i;
    do
    {
        if(client == NULL)
        {
            De_printf("httpChilent NULL\r\n");
            break;
        }
        pthread_mutex_lock(&client->lock);
        address = (struct sockaddr_in *)&(client->addr);
        if(address != NULL)
        {
            inet_ntop(AF_INET, &address->sin_addr,ip, INET_ADDRSTRLEN);
        }
        if(events & BEV_EVENT_ERROR)
        {
            if(address != NULL)
                De_printf("%s:%d[ Error from bufferevnt:%s\r\n", inet_ntop(AF_INET,&address->sin_addr, ip,(socklen_t) sizeof(ip)), ntohs(address->sin_port), strerror(errno));  
            else
                De_printf("Unknown[ Error from bufferevnt:%s\r\n",strerror(errno));
        }
        else if(events & (BEV_EVENT_EOF))
        {
            if(address != NULL)
                De_printf("Connection close:%s:%d\r\n", inet_ntop(AF_INET,&address->sin_addr, ip,(socklen_t) sizeof(ip)), ntohs(address->sin_port));  
            else
                De_printf("Connection close: Unknown\r\n");
        }
        pthread_mutex_unlock(&client->lock);
    }
    while(0);
    bufferevent_lock(bev);
    bufferevent_disable(bev, EV_WRITE | EV_READ);
    if(client != NULL)
    {
        if(client->stat == HTTP_WS_DATA && client->ws_weite_cb_flage)
        {
            WebddSocket_Thread_Cb_arg_t * cb_arg = (WebddSocket_Thread_Cb_arg_t *)malloc(sizeof(WebddSocket_Thread_Cb_arg_t));
            cb_arg->client = client;
            cb_arg->type = Ws_Cb_Type_disconnect;
            threadpool_add(evbase_threadpool_get_threadpool(client->httpServer->evb_thpool), webSocke_thread_cb, cb_arg);
        }
        pthread_mutex_lock(&client->lock);
        evbase_threadpool_close_event(client->httpServer->evb_thpool, bufferevent_get_base(bev));
        pthread_mutex_lock(&client->httpServer->clientMap_lock);
        client->httpServer->clientMap->erase(bev);
        pthread_mutex_unlock(&client->httpServer->clientMap_lock);

        pthread_mutex_unlock(&client->lock);
        httpChilent_free(client);
    }
    //close(bufferevent_getfd(bev));
    bufferevent_lock(bev);
    bufferevent_free(bev);
    /* bufferevent_unlock(bev); */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rdi, 0x8(%rsp)
testq %rdx, %rdx
je 0x7539
movl %esi, %ebp
movq %rbx, %rdi
callq 0x3620
leaq 0xa8(%rbx), %r14
leaq 0x10(%rsp), %rdx
movl $0x2, %edi
movq %r14, %rsi
movl $0x10, %ecx
callq 0x3480
movzwl %bp, %eax
testb $0x20, %al
jne 0x7574
testb $0x10, %al
je 0x75eb
leaq 0x3cc7(%rip), %rdi      # 0xb1ab
leaq 0x5723(%rip), %rsi      # 0xcc0e
leaq 0x55ef(%rip), %rdx      # 0xcae1
movl $0x3be, %ecx            # imm = 0x3BE
xorl %eax, %eax
callq 0x3080
leaq 0x10(%rsp), %rdx
movl $0x2, %edi
movq %r14, %rsi
movl $0x10, %ecx
callq 0x3480
movzwl 0xa6(%rbx), %ecx
rolw $0x8, %cx
movzwl %cx, %edx
leaq 0x55f2(%rip), %rdi      # 0xcb1c
movq %rax, %rsi
xorl %eax, %eax
callq 0x3080
jmp 0x75df
leaq 0x3c6b(%rip), %rdi      # 0xb1ab
leaq 0x56c7(%rip), %rsi      # 0xcc0e
leaq 0x5593(%rip), %rdx      # 0xcae1
movl $0x3ab, %ecx            # imm = 0x3AB
xorl %eax, %eax
callq 0x3080
leaq 0x5812(%rip), %rdi      # 0xcd73
callq 0x3680
leaq 0x3f71(%rip), %rdi      # 0xb4de
callq 0x3680
jmp 0x75f3
leaq 0x3c30(%rip), %rdi      # 0xb1ab
leaq 0x568c(%rip), %rsi      # 0xcc0e
leaq 0x5558(%rip), %rdx      # 0xcae1
movl $0x3b7, %ecx            # imm = 0x3B7
xorl %eax, %eax
callq 0x3080
leaq 0x10(%rsp), %rdx
movl $0x2, %edi
movq %r14, %rsi
movl $0x10, %ecx
callq 0x3480
movq %rax, %r14
movzwl 0xa6(%rbx), %eax
rolw $0x8, %ax
movzwl %ax, %ebp
callq 0x3070
movl (%rax), %edi
callq 0x3170
leaq 0x5650(%rip), %rdi      # 0xcc20
movq %r14, %rsi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x3080
leaq 0x3ef8(%rip), %rdi      # 0xb4de
callq 0x3680
movq %rbx, %rdi
callq 0x3310
movq 0x8(%rsp), %rdi
callq 0x3610
movq 0x8(%rsp), %rdi
movl $0x6, %esi
callq 0x3650
testq %rbx, %rbx
je 0x76ca
cmpl $0x5, 0x38(%rbx)
jne 0x765a
cmpb $0x0, 0xc8(%rbx)
je 0x765a
movl $0x10, %edi
callq 0x35a0
movq %rax, %r14
movq %rbx, (%rax)
movl $0x3, 0x8(%rax)
movq 0x28(%rbx), %rax
movq 0x60(%rax), %rdi
callq 0x85bc
leaq -0x12f5(%rip), %rsi     # 0x635a
movq %rax, %rdi
movq %r14, %rdx
callq 0x920d
movq %rbx, %rdi
callq 0x3620
movq 0x28(%rbx), %rax
movq 0x60(%rax), %r14
leaq 0x8(%rsp), %r15
movq (%r15), %rdi
callq 0x3730
movq %r14, %rdi
movq %rax, %rsi
callq 0x8a8a
movq 0x28(%rbx), %rdi
addq $0x28, %rdi
callq 0x3620
movq 0x28(%rbx), %rax
movq 0x50(%rax), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x8498
movq %r14, %rdi
movq %rax, %rsi
callq 0x8514
movq 0x28(%rbx), %rdi
addq $0x28, %rdi
callq 0x3310
movq %rbx, %rdi
callq 0x3310
movq %rbx, %rdi
callq 0x7430
movq 0x8(%rsp), %rdi
callq 0x3610
movq 0x8(%rsp), %rdi
callq 0x3140
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq