// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
leaq 0x9859(%rip), %rax      # 0x10478
cmpq $0x0, (%rax)
je 0x6f4c
movq %rdi, %r15
testq %rdi, %rdi
je 0x6dbb
movq %rsi, %r14
pushq $0x1
popq %rdi
movl $0xc0, %esi
callq 0x32c0
testq %rax, %rax
je 0x6dfa
movq %rax, %rbx
movq %r15, 0x58(%rax)
leaq 0x9800(%rip), %rax      # 0x1045c
movl (%rax), %edi
leaq 0x97f3(%rip), %rax      # 0x10458
movl (%rax), %esi
callq 0x7c7c
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x6e39
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3660
testl %eax, %eax
jne 0x6e76
leaq 0x28(%rbx), %rdi
xorl %esi, %esi
callq 0x3660
testl %eax, %eax
jne 0x6eb0
pushq $0x30
popq %rdi
callq 0x3450
leaq 0x8(%rax), %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rax)
movaps %xmm0, (%rax)
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
andq $0x0, 0x28(%rax)
movq %rax, 0x50(%rbx)
leaq 0x8(%rsp), %r9
andq $0x0, 0x8(%r9)
movw $0x2, (%r9)
movzwl (%r14), %eax
rolw $0x8, %ax
movw %ax, 0x2(%r9)
andl $0x0, 0x4(%r9)
movl $0x10, (%rsp)
leaq 0x267(%rip), %rsi       # 0x6f5c
pushq $0xa
popq %rcx
pushq $-0x1
popq %r8
movq %r15, %rdi
movq %rbx, %rdx
callq 0x33d0
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x6eea
movzwl (%r14), %ecx
movl %ecx, 0x80(%rbx)
leaq 0x5bc(%rip), %rsi       # 0x72e1
movq %rax, %rdi
callq 0x37d0
movq 0x60(%rbx), %rdi
callq 0x7c78
movq %rax, 0x70(%rbx)
movq %rbx, %rdi
addq $0x78, %rdi
leaq -0x846(%rip), %rdx      # 0x6502
xorl %esi, %esi
movq %rbx, %rcx
callq 0x37a0
testl %eax, %eax
je 0x6f4e
movl %eax, %ebp
movq 0x9275(%rip), %r15      # 0xffd8
movq (%r15), %rdi
leaq 0x343e(%rip), %rsi      # 0xa1ab
leaq 0x4dbe(%rip), %rdx      # 0xbb32
leaq 0x4d63(%rip), %rcx      # 0xbade
movl $0x4fd, %r8d            # imm = 0x4FD
xorl %eax, %eax
callq 0x3610
movq (%r15), %r14
movl %ebp, %edi
callq 0x3170
leaq 0x4e5a(%rip), %rsi      # 0xbbf3
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3610
movq (%r15), %rcx
leaq 0x4ef4(%rip), %rdi      # 0xbca4
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
jmp 0x6f3f
movq 0x9216(%rip), %r15      # 0xffd8
movq (%r15), %rdi
leaq 0x33df(%rip), %rsi      # 0xa1ab
leaq 0x4d5f(%rip), %rdx      # 0xbb32
leaq 0x4d04(%rip), %rcx      # 0xbade
xorl %ebx, %ebx
movl $0x4ca, %r8d            # imm = 0x4CA
xorl %eax, %eax
callq 0x3610
movq (%r15), %rcx
leaq 0x4d4e(%rip), %rdi      # 0xbb41
pushq $0x14
jmp 0x6f22
movq 0x91d7(%rip), %r15      # 0xffd8
movq (%r15), %rdi
leaq 0x33a0(%rip), %rsi      # 0xa1ab
leaq 0x4d20(%rip), %rdx      # 0xbb32
leaq 0x4cc5(%rip), %rcx      # 0xbade
xorl %ebx, %ebx
movl $0x4d0, %r8d            # imm = 0x4D0
xorl %eax, %eax
callq 0x3610
movq (%r15), %rcx
leaq 0x4d24(%rip), %rdi      # 0xbb56
pushq $0x1a
jmp 0x6f22
movq 0x9198(%rip), %r15      # 0xffd8
movq (%r15), %rdi
leaq 0x3361(%rip), %rsi      # 0xa1ab
leaq 0x4ce1(%rip), %rdx      # 0xbb32
leaq 0x4c86(%rip), %rcx      # 0xbade
movl $0x4db, %r8d            # imm = 0x4DB
xorl %eax, %eax
callq 0x3610
movq (%r15), %rcx
leaq 0x4d02(%rip), %rdi      # 0xbb71
pushq $0x1d
jmp 0x6f22
movq 0x915b(%rip), %r15      # 0xffd8
movq (%r15), %rdi
leaq 0x3324(%rip), %rsi      # 0xa1ab
leaq 0x4ca4(%rip), %rdx      # 0xbb32
leaq 0x4c49(%rip), %rcx      # 0xbade
movl $0x4e0, %r8d            # imm = 0x4E0
xorl %eax, %eax
callq 0x3610
movq (%r15), %rcx
leaq 0x4ce3(%rip), %rdi      # 0xbb8f
pushq $0x1c
jmp 0x6f22
movq 0x9121(%rip), %r15      # 0xffd8
movq (%r15), %rdi
leaq 0x32ea(%rip), %rsi      # 0xa1ab
leaq 0x4c6a(%rip), %rdx      # 0xbb32
leaq 0x4c0f(%rip), %rcx      # 0xbade
movl $0x4e5, %r8d            # imm = 0x4E5
xorl %eax, %eax
callq 0x3610
movq (%r15), %rcx
leaq 0x4cc6(%rip), %rdi      # 0xbbac
pushq $0x26
jmp 0x6f22
movq 0x90e7(%rip), %r15      # 0xffd8
movq (%r15), %rdi
leaq 0x32b0(%rip), %rsi      # 0xa1ab
leaq 0x4c30(%rip), %rdx      # 0xbb32
leaq 0x4bd5(%rip), %rcx      # 0xbade
movl $0x4f4, %r8d            # imm = 0x4F4
xorl %eax, %eax
callq 0x3610
movq (%r15), %rcx
leaq 0x4cb3(%rip), %rdi      # 0xbbd3
pushq $0x1f
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
callq 0x3800
movq (%r15), %rcx
leaq 0x4d6b(%rip), %rdi      # 0xbca4
pushq $0x2
popq %rsi
movq %r14, %rdx
callq 0x3800
movq %rbx, %rdi
callq 0x6afa
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq