// File: /workspace/github_c_makefile_star2_O1/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 0x9b27(%rip), %rax      # 0x11460
cmpq $0x0, (%rax)
je 0x7acc
movq %rdi, %r15
testq %rdi, %rdi
je 0x7a9a
movq %rsi, %r14
movl $0xc0, %edi
callq 0x35a0
testq %rax, %rax
je 0x7aa1
movq %rax, %rbx
movl $0xc0, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x3250
movq %r15, 0x58(%rbx)
movl $0x0, 0x84(%rbx)
leaq 0x9ab8(%rip), %rax      # 0x11444
movl (%rax), %edi
leaq 0x9aab(%rip), %rax      # 0x11440
movl (%rax), %esi
callq 0x85c0
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x7aaa
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3630
testl %eax, %eax
jne 0x7ab1
leaq 0x28(%rbx), %rdi
xorl %esi, %esi
callq 0x3630
testl %eax, %eax
jne 0x7ab8
movl $0x30, %edi
callq 0x3440
leaq 0x8(%rax), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq %rax, 0x50(%rbx)
leaq 0x10(%rsp), %r9
movaps %xmm0, (%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        # 0x7adb
movq %r15, %rdi
movq %rbx, %rdx
movl $0xa, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x33c0
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x7abf
movzwl (%r14), %ecx
movl %ecx, 0x80(%rbx)
leaq -0x418b(%rip), %rsi     # 0x38d5
movq %rax, %rdi
callq 0x37a0
movq 0x60(%rbx), %rdi
callq 0x85bc
movq %rax, 0x70(%rbx)
movq %rbx, %rdi
addq $0x78, %rdi
leaq -0x8e6(%rip), %rdx      # 0x719d
xorl %esi, %esi
movq %rbx, %rcx
callq 0x3770
testl %eax, %eax
je 0x7ace
movl %eax, %edi
callq 0x3a34
jmp 0x7ac4
callq 0x3b56
jmp 0x7aa6
callq 0x3b13
xorl %ebx, %ebx
jmp 0x7ac4
callq 0x3ad0
jmp 0x7ac4
callq 0x39ae
jmp 0x7ac4
callq 0x39f1
jmp 0x7ac4
callq 0x3a8c
movq %rbx, %rdi
callq 0x3b99
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq