예제 #1
0
static ape_global *ape_init()
{
    ape_global *ape;
    struct _fdevent *fdev;

    if ((ape = malloc(sizeof(*ape))) == NULL) return NULL;

	inc_rlimit(64000);

    signal(SIGPIPE, SIG_IGN);
	signal(SIGINT, &signal_handler);
	signal(SIGTERM, &signal_handler);
	
    fdev = &ape->events;
    fdev->handler = EVENT_UNKNOWN;
    #ifdef USE_EPOLL_HANDLER
    fdev->handler = EVENT_EPOLL;
    #endif
    #ifdef USE_KQUEUE_HANDLER
    fdev->handler = EVENT_KQUEUE;
    #endif

    ape->basemem    = APE_BASEMEM;
    ape->is_running = 1;
    ape->timers.ntimers = 0;
    ape->timers.timers  = NULL;
	
	ape_ssl_init();
	
    if (ape_dns_init(ape) != 0) {
        goto error;
    }
    events_init(ape);

    ape->seed = _ape_seed = time(NULL) ^ (getpid() << 16);

    ape->hashs.servers    = hashtbl_init(APE_HASH_STR);
    ape->hashs.cmds       = hashtbl_init(APE_HASH_STR);
    ape->hashs.pipes.pub  = hashtbl_init(APE_HASH_INT);
    ape->hashs.pipes.priv = hashtbl_init(APE_HASH_INT);

    if ((ape->conf = ape_read_config("../../etc/ape.conf", ape)) == NULL) {
        goto error;
    }
    
    ape_cmd_init_core(ape);

    ape->extend = ape_array_new(8);
	
    return ape;

error:

    free(ape);

    return NULL;
}
예제 #2
0
static ape_global *ape_init()
{
    ape_global *ape;
    struct _fdevent *fdev;

    if ((ape = malloc(sizeof(*ape))) == NULL) return NULL;

    signal(SIGPIPE, SIG_IGN);

    fdev = &ape->events;
    fdev->handler = EVENT_UNKNOWN;
    #ifdef USE_EPOLL_HANDLER
    fdev->handler = EVENT_EPOLL;
    #endif
    #ifdef USE_KQUEUE_HANDLER
    fdev->handler = EVENT_ KQUEUE;
    #endif

    ape->basemem    = APE_BASEMEM;
    ape->is_running = 1;

    if (ape_dns_init(ape) != 0) {
        goto error;
    }
    events_init(ape);

    ape->seed = _ape_seed = time(NULL) ^ (getpid() << 16);

    ape->hashs.servers = hashtbl_init();

    if ((ape->conf = ape_read_config("../../etc/ape.conf", ape)) == NULL) {
        goto error;
    }

    return ape;

error:

    free(ape);

    return NULL;
}