// File: /workspace/github_c_makefile_star2_O3/sszllzss[P]webSocket_Libevent_ThreadPool/ev_httpd.cpp
// Function: startHttpServe(event_base*, unsigned short*)
httpServer_t * startHttpServe(struct event_base* base, u_short *port)
{
    httpServer_t * httpServer = NULL;
    struct sockaddr_in addr;
#ifdef DYNAMIC_CONFING
    if(SERVER_STRING_VARIALE == NULL)
        return NULL;
#endif
    do
    {
        if(base == NULL)
        {
            De_fprintf(stderr, "event_base == NULL\r\n");
            break;
        }
        httpServer = (httpServer_t *) malloc(sizeof(httpServer_t));
        if(httpServer == NULL)
        {
            De_fprintf(stderr, "httpServer_t mallocl fail!");
            break;
        }
        memset(httpServer, 0, (sizeof(httpServer_t)));

        httpServer->http_listener_base = base;
        httpServer->shutdown = false;

        httpServer->evb_thpool =  evbase_threadpool_new(HTTPSERVER_BASE_MAX_MONITOR_NUM, HTTPSERVER_MIN_THREAD_NUM);
        if(httpServer->evb_thpool == NULL)
        {
            De_fprintf(stderr, "new evbase_threadpool fail!\r\n");
            break;
        }
        if(pthread_mutex_init(&httpServer->lock, NULL) != 0)
        {
            De_fprintf(stderr, "httpServer->lock init fail\r\n");
            break;
        }
        if(pthread_mutex_init(&httpServer->clientMap_lock, NULL) != 0)
        {
            De_fprintf(stderr, "httpServer->clientMap_lock init fail\r\n");
            break;
        }
        httpServer->clientMap = new BufferevMap();
        if(httpServer->clientMap == NULL)
        {
            De_fprintf(stderr, "httpServer->clientMap new fail\r\n");
            break;    
        }
        memset(&addr, 0, sizeof(addr));
        addr.sin_family = AF_INET;
        addr.sin_port = htons(*port);
        addr.sin_addr.s_addr = htonl(INADDR_ANY);
        if ((httpServer->http_listeber = evconnlistener_new_bind(base , listener_cd , httpServer, LEV_OPT_REUSEABLE | LEV_OPT_CLOSE_ON_FREE, -1,(struct sockaddr *)&addr, sizeof(addr))) == NULL)
        {
            De_fprintf(stderr, "evconnlistener_new_bind fail!\r\n");
            break;
        }
        httpServer->port = *port; 
        evconnlistener_set_error_cb(httpServer->http_listeber, accpt_error_cb);
        httpServer->pool = evbase_threadpool_get_threadpool(httpServer->evb_thpool);
        int ret = pthread_create(&httpServer->http_supervise_thread, NULL, http_supervise_thread, httpServer);
        if(ret != 0)
        {
            De_fprintf(stderr, "creatd thread fail:%s\r\n", strerror(ret));
            break;
        }
        return httpServer;
    }while(0);
    httpServer_free(httpServer);
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
leaq 0x9b63(%rip), %rax      # 0x11460
cmpq $0x0, (%rax)
je 0x7a76
movq %rdi, %r15
testq %rdi, %rdi
je 0x7a44
movq %rsi, %r14
movl $0x1, %edi
movl $0xc0, %esi
callq 0x32b0
testq %rax, %rax
je 0x7a4b
movq %rax, %rbx
movq %r15, 0x58(%rax)
leaq 0x9b08(%rip), %rax      # 0x11444
movl (%rax), %edi
leaq 0x9afb(%rip), %rax      # 0x11440
movl (%rax), %esi
callq 0x8560
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x7a54
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3630
testl %eax, %eax
jne 0x7a5b
leaq 0x28(%rbx), %rdi
xorl %esi, %esi
callq 0x3630
testl %eax, %eax
jne 0x7a62
movl $0x30, %edi
callq 0x3440
leaq 0x8(%rax), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
xorl %ecx, %ecx
movq %rcx, 0x28(%rax)
movq %rax, 0x50(%rbx)
leaq 0x10(%rsp), %r9
movq %rcx, 0x8(%r9)
movw $0x2, (%r9)
movzwl (%r14), %eax
rolw $0x8, %ax
movw %ax, 0x2(%r9)
movl $0x0, 0x4(%r9)
movl $0x10, (%rsp)
leaq 0xab(%rip), %rsi        # 0x7a85
movq %r15, %rdi
movq %rbx, %rdx
movl $0xa, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x33c0
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x7a69
movzwl (%r14), %ecx
movl %ecx, 0x80(%rbx)
leaq -0x4135(%rip), %rsi     # 0x38d5
movq %rax, %rdi
callq 0x37a0
movq 0x60(%rbx), %rdi
callq 0x855c
movq %rax, 0x70(%rbx)
movq %rbx, %rdi
addq $0x78, %rdi
leaq -0x8a4(%rip), %rdx      # 0x7189
xorl %esi, %esi
movq %rbx, %rcx
callq 0x3770
testl %eax, %eax
je 0x7a78
movl %eax, %edi
callq 0x3a76
jmp 0x7a6e
callq 0x3c0f
jmp 0x7a50
callq 0x3bab
xorl %ebx, %ebx
jmp 0x7a6e
callq 0x3b47
jmp 0x7a6e
callq 0x39ae
jmp 0x7a6e
callq 0x3a12
jmp 0x7a6e
callq 0x3ae2
movq %rbx, %rdi
callq 0x77c9
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq