// File: /workspace/github_c_makefile_star2_O2/sszllzss[P]webSocket_Libevent_ThreadPool/ev_httpd.cpp
// Function: ws_read_cb_thread(void*)
void *ws_read_cb_thread(void *arg)
{
    struct httpChilent_t *client = (struct httpChilent_t *)arg;
    struct httpServer_t *httpServer = client->httpServer;
    struct bufferevent * bev = client->bev;
    unsigned char * buff = NULL;
    unsigned int buff_len = 0;
    Websocket_CommunicationType ws_data_type;
    bufferevent_lock(client->bev);
    int ret = ev_webSocket_recv(client->bev, &buff, &buff_len, &ws_data_type);
    bufferevent_unlock(client->bev);
    if(ret <= 0)
    {
        if(ret == WCT_DISCONN)
        {
            httpChilent_Close(client);
            return NULL;
        }
    }
    else
    {
        client->ws_data_type = ws_data_type;
        if(client->stat == HTTP_WS_DATA && client->httpServer->ws_read_cb != NULL)
        {
            evbuffer_lock(client->receive_evbuff);
            if(evbuffer_add(client->receive_evbuff, buff, buff_len) != 0)
            {
                De_fprintf(stderr, "evbuffer_add fail!\r\n");
                evbuffer_unlock(client->receive_evbuff);
                pthread_mutex_unlock(&client->lock);
                free(buff);
                return NULL;
            }
            evbuffer_unlock(client->receive_evbuff);
            free(buff);
            webSocket_cb_t ws_read_cb = client->httpServer->ws_read_cb;
            pthread_mutex_unlock(&client->lock);
            ws_read_cb(client);
            pthread_mutex_lock(&httpServer->clientMap_lock);
            BufferevMap::iterator v = httpServer->clientMap->find(bev);    
            if(httpServer->clientMap->end() == v)
            {
                pthread_mutex_unlock(&httpServer->clientMap_lock);
                return NULL;
            }
            pthread_mutex_unlock(&httpServer->clientMap_lock);
            pthread_mutex_lock(&client->lock);
            client->ws_data_type = WCT_NULL;
        }
        else
            free(buff);
        pthread_mutex_unlock(&client->lock);
    }
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movq 0x28(%rdi), %r12
movq 0x30(%rdi), %rdi
movq %rdi, 0x18(%rsp)
leaq 0x8(%rsp), %r14
andq $0x0, (%r14)
leaq 0x14(%rsp), %r15
andl $0x0, (%r15)
callq 0x3640
movq 0x30(%rbx), %rdi
leaq 0x10(%rsp), %rcx
movq %r14, %rsi
movq %r15, %rdx
callq 0x499e
movl %eax, %ebp
movq 0x30(%rbx), %rdi
callq 0x3710
testl %ebp, %ebp
jle 0x6439
movl 0x10(%rsp), %eax
movl %eax, 0xa0(%rbx)
cmpl $0x5, 0x38(%rbx)
jne 0x6425
movq 0x28(%rbx), %rax
cmpq $0x0, 0x90(%rax)
je 0x6425
movq 0x98(%rbx), %rdi
callq 0x32e0
movq 0x98(%rbx), %rdi
movq 0x8(%rsp), %rsi
movl 0x14(%rsp), %edx
callq 0x3430
testl %eax, %eax
jne 0x6455
movq 0x98(%rbx), %rdi
callq 0x37b0
movq 0x8(%rsp), %rdi
callq 0x3520
movq 0x28(%rbx), %rax
movq 0x90(%rax), %r14
movq %rbx, %rdi
callq 0x3320
movq %rbx, %rdi
callq *%r14
leaq 0x28(%r12), %r14
movq %r14, %rdi
callq 0x3650
movq 0x50(%r12), %rdi
leaq 0x18(%rsp), %rsi
callq 0x7a9a
movq %rax, %r15
movq 0x50(%r12), %r12
addq $0x8, %r12
movq %r14, %rdi
callq 0x3320
cmpq %r15, %r12
je 0x6446
movq %rbx, %rdi
callq 0x3650
andl $0x0, 0xa0(%rbx)
jmp 0x642f
movq 0x8(%rsp), %rdi
callq 0x3520
movq %rbx, %rdi
callq 0x3320
jmp 0x6446
cmpl $-0x11, %ebp
jne 0x6446
movq %rbx, %rdi
callq 0x64d2
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x9b7c(%rip), %r15      # 0xffd8
movq (%r15), %rdi
leaq 0x3d45(%rip), %rsi      # 0xa1ab
leaq 0x565f(%rip), %rdx      # 0xbacc
leaq 0x566a(%rip), %rcx      # 0xbade
movl $0x321, %r8d            # imm = 0x321
xorl %eax, %eax
callq 0x3610
movq (%r15), %rcx
leaq 0x5660(%rip), %rdi      # 0xbaeb
pushq $0x14
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x3800
movq (%r15), %rcx
leaq 0x5800(%rip), %rdi      # 0xbca4
pushq $0x2
popq %rsi
movq %r14, %rdx
callq 0x3800
movq 0x98(%rbx), %rdi
callq 0x37b0
movq %rbx, %rdi
callq 0x3320
movq 0x8(%rsp), %rdi
callq 0x3520
jmp 0x6446