// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x4710
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x34(%rbp), %rdx
leaq -0x38(%rbp), %rcx
callq 0x6710
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x47d0
cmpl $0x0, -0x3c(%rbp)
jg 0x91c8
cmpl $-0x11, -0x3c(%rbp)
jne 0x91c3
movq -0x18(%rbp), %rdi
callq 0x93a0
movq $0x0, -0x8(%rbp)
jmp 0x9394
jmp 0x938c
movl -0x38(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x18(%rbp), %rax
cmpl $0x5, 0x38(%rax)
jne 0x937a
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
cmpq $0x0, 0x90(%rax)
je 0x937a
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x4350
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
movq -0x30(%rbp), %rsi
movl -0x34(%rbp), %eax
movl %eax, %edx
callq 0x44d0
cmpl $0x0, %eax
je 0x92b8
jmp 0x922d
movq 0x13da4(%rip), %rax     # 0x1cfd8
movq (%rax), %rdi
leaq 0xaf5d(%rip), %rsi      # 0x1419b
leaq 0xc858(%rip), %rdx      # 0x15a9d
leaq 0xc863(%rip), %rcx      # 0x15aaf
movl $0x321, %r8d            # imm = 0x321
movb $0x0, %al
callq 0x46e0
movq 0x13d78(%rip), %rax     # 0x1cfd8
movq (%rax), %rdi
leaq 0xc852(%rip), %rsi      # 0x15abc
movb $0x0, %al
callq 0x46e0
movq 0x13d60(%rip), %rax     # 0x1cfd8
movq (%rax), %rdi
leaq 0xca67(%rip), %rsi      # 0x15ce9
movb $0x0, %al
callq 0x46e0
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x48a0
movq -0x18(%rbp), %rdi
callq 0x4390
movq -0x30(%rbp), %rdi
callq 0x45f0
movq $0x0, -0x8(%rbp)
jmp 0x9394
movq -0x18(%rbp), %rax
movq 0x98(%rax), %rdi
callq 0x48a0
movq -0x30(%rbp), %rdi
callq 0x45f0
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x90(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4390
movq -0x48(%rbp), %rax
movq -0x18(%rbp), %rdi
callq *%rax
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
callq 0x4720
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0xb1e0
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0xb240
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xb210
testb $0x1, %al
jne 0x933d
jmp 0x9354
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
callq 0x4390
movq $0x0, -0x8(%rbp)
jmp 0x9394
movq -0x20(%rbp), %rdi
addq $0x28, %rdi
callq 0x4390
movq -0x18(%rbp), %rdi
callq 0x4720
movq -0x18(%rbp), %rax
movl $0x0, 0xa0(%rax)
jmp 0x9383
movq -0x30(%rbp), %rdi
callq 0x45f0
movq -0x18(%rbp), %rdi
callq 0x4390
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop