// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x28(%rdi), %r13
movq 0x30(%rdi), %r14
leaq 0x8(%rsp), %r15
movq $0x0, (%r15)
leaq 0x14(%rsp), %r12
movl $0x0, (%r12)
movq %r14, %rdi
callq 0x3610
movq 0x30(%rbx), %rdi
leaq 0x10(%rsp), %rcx
movq %r15, %rsi
movq %r12, %rdx
callq 0x5323
movl %eax, %ebp
movq 0x30(%rbx), %rdi
callq 0x36e0
testl %ebp, %ebp
jle 0x7137
movl 0x10(%rsp), %eax
movl %eax, 0xa0(%rbx)
cmpl $0x5, 0x38(%rbx)
jne 0x7123
movq 0x28(%rbx), %rax
cmpq $0x0, 0x90(%rax)
je 0x7123
movq 0x98(%rbx), %rdi
callq 0x32d0
movq 0x98(%rbx), %rdi
movq 0x8(%rsp), %rsi
movl 0x14(%rsp), %edx
callq 0x3420
testl %eax, %eax
jne 0x7155
movq 0x98(%rbx), %rdi
callq 0x3780
movq 0x8(%rsp), %rdi
callq 0x3500
movq 0x28(%rbx), %rax
movq 0x90(%rax), %r15
movq %rbx, %rdi
callq 0x3310
movq %rbx, %rdi
callq *%r15
leaq 0x28(%r13), %r15
movq %r15, %rdi
callq 0x3620
movq 0x50(%r13), %r12
movq 0x10(%r12), %rcx
addq $0x8, %r12
movq %r12, %rax
testq %rcx, %rcx
je 0x70ef
movq %r12, %rax
xorl %edx, %edx
cmpq %r14, 0x20(%rcx)
setb %dl
cmovaeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x70d8
movq %r12, %r13
cmpq %r12, %rax
je 0x7102
cmpq 0x20(%rax), %r14
cmovbq %r12, %rax
movq %rax, %r13
movq %r15, %rdi
callq 0x3310
cmpq %r13, %r12
je 0x7144
movq %rbx, %rdi
callq 0x3620
movl $0x0, 0xa0(%rbx)
jmp 0x712d
movq 0x8(%rsp), %rdi
callq 0x3500
movq %rbx, %rdi
callq 0x3310
jmp 0x7144
cmpl $-0x11, %ebp
jne 0x7144
movq %rbx, %rdi
callq 0x716b
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x98(%rbx), %rdi
leaq 0x8(%rsp), %rdx
movq %rbx, %rsi
callq 0x391d
jmp 0x7144