Exemple #1
0
int main(int argc, char **argv)
{
    /* locale */
    setlocale(LC_ALL, "C");
    /* signal */
    signal(SIGTERM, &lhttpd_stop);
    signal(SIGINT,  &lhttpd_stop);
    signal(SIGHUP,  SIG_IGN);
    signal(SIGPIPE, SIG_IGN);
    setrlimiter("RLIMIT_NOFILE", RLIMIT_NOFILE, 10240);
    if((sbase = sbase_init()) == NULL)
    {
        exit(EXIT_FAILURE);
    }
    if((lhttpd = service_init()) == NULL)
    {
        fprintf(stderr, "Initialize service failed, %s", strerror(errno));
        _exit(-1);
    }
    lhttpd->family = AF_INET;
    lhttpd->sock_type = SOCK_STREAM;
    lhttpd->ip = "0.0.0.0";
    lhttpd->port = 2080;
    lhttpd->use_cond_wait = 1;
    lhttpd->flag = SB_USE_COND|SB_USE_OUTDAEMON;
    lhttpd->working_mode = WORKING_THREAD;
    lhttpd->service_type = S_SERVICE;
    lhttpd->service_name = "lhttpd";
    lhttpd->nprocthreads = 8;
    lhttpd->niodaemons = 2;
    lhttpd->session.packet_type= PACKET_DELIMITER;
    lhttpd->session.packet_delimiter = "\r\n\r\n";
    lhttpd->session.packet_delimiter_length = strlen(lhttpd->session.packet_delimiter);
    lhttpd->session.buffer_size = SB_BUF_SIZE;
    lhttpd->session.packet_handler = &lhttpd_packet_handler;
    lhttpd->session.timeout_handler = &lhttpd_timeout_handler;
    lhttpd->set_log(lhttpd, "/tmp/lhttpd.log");
    lhttpd->set_log_level(lhttpd, 2);
    httpd_home = "/data/www";
    if(sbase->add_service(sbase, lhttpd) != 0)
    {
        fprintf(stderr, "add service lhttpd failed, %s\r\n", strerror(errno));
        _exit(-1);
    }
    fprintf(stdout, "Initialized successed\n");
    sbase->running(sbase, 0);
    //sbase->running(sbase, 60000000); sbase->stop(sbase);
    sbase->clean(sbase);
    return 0;
}
Exemple #2
0
int main(int argc, char **argv)
{
    pid_t pid;
    char *conf = NULL, *p = NULL, ch = 0;
    int is_daemon = 0;

    /* get configure file */
    while((ch = getopt(argc, argv, "c:d")) != (char)-1)
    {
        if(ch == 'c') conf = optarg;
        else if(ch == 'd') is_daemon = 1;
    }
    if(conf == NULL)
    {
        fprintf(stderr, "Usage:%s -d -c config_file\n", argv[0]);
        _exit(-1);
    }
    /* locale */
    setlocale(LC_ALL, "C");
    /* signal */
    signal(SIGTERM, &nowd_stop);
    signal(SIGINT,  &nowd_stop);
    signal(SIGHUP,  SIG_IGN);
    signal(SIGPIPE, SIG_IGN);
    //daemon
    if(is_daemon)
    {
        pid = fork();
        switch (pid) {
            case -1:
                perror("fork()");
                exit(EXIT_FAILURE);
                break;
            case 0: //child
                if(setsid() == -1)
                    exit(EXIT_FAILURE);
                break;
            default://parent
                _exit(EXIT_SUCCESS);
                break;
        }
    }
    setrlimiter("RLIMIT_NOFILE", RLIMIT_NOFILE, 10240);
    if((sbase = sbase_init()) == NULL)
    {
        exit(EXIT_FAILURE);
        return -1;
    }
    fprintf(stdout, "Initializing from configure file:%s\n", conf);
    /* Initialize sbase */
    if(sbase_initialize(sbase, conf) != 0 )
    {
        fprintf(stderr, "Initialize from configure file failed\n");
        exit(EXIT_FAILURE);
        return -1;
    }
    fprintf(stdout, "Initialized successed\n");
    sbase->running(sbase, 0);
    //sbase->running(sbase, 60000000); sbase->stop(sbase);
    //sbase->running(sbase, 90000000);sbase->stop(sbase);
    sbase->clean(sbase);
    if(dict)iniparser_free(dict);
    return 0;
}
Exemple #3
0
int main(int argc, char **argv)
{
    char *ip = NULL;
    int port = 0;
    int fd = 0;
    struct sockaddr_in sa, lsa;
    socklen_t sa_len, lsa_len = -1;
    int sock_type = 0;

    if(argc < 5)
    {
        fprintf(stderr, "Usage:%s sock_type(0/TCP|1/UDP) ip port domain\n", argv[0]);	
        _exit(-1);
    }	
    ev_sock_type = atoi(argv[1]);
    if(ev_sock_type < 0 || ev_sock_type > ev_sock_count)
    {
        fprintf(stderr, "sock_type must be 0/TCP OR 1/UDP\n");
        _exit(-1);
    }
    sock_type = ev_sock_list[ev_sock_type];
    ip = argv[2];
    port = atoi(argv[3]);
    domain = argv[4];
    /* Set resource limit */
    setrlimiter("RLIMIT_NOFILE", RLIMIT_NOFILE, CONN_MAX);	
    /* Initialize global vars */
    memset(events, 0, sizeof(EVENT) * CONN_MAX);
    /* Initialize inet */ 
    memset(&sa, 0, sizeof(struct sockaddr_in));	
    sa.sin_family = AF_INET;
    sa.sin_addr.s_addr = inet_addr(ip);
    sa.sin_port = htons(port);
    sa_len = sizeof(struct sockaddr);
    /* set evbase */
    if((evbase = evbase_init(0)))
    {
        TIMER_INIT(timer);
        //evbase->set_evops(evbase, EOP_POLL);
        if((fd = socket(AF_INET, sock_type, 0)) > 0)
        {
            /* Connect */
            if(connect(fd, (struct sockaddr *)&sa, sa_len) == 0 )
            {
                /* set FD NON-BLOCK */
                fcntl(fd, F_SETFL, O_NONBLOCK);
                if(sock_type == SOCK_STREAM)
                {
                    event_set(&events[fd], fd, E_READ|E_WRITE|E_PERSIST, 
                            (void *)&events[fd], &ev_handler);
                }
                else
                {
                    event_set(&events[fd], fd, E_READ|E_WRITE|E_PERSIST, 
                            (void *)&events[fd], &ev_udp_handler);
                }
                evbase->add(evbase, &events[fd]);
                sprintf(buffer[fd], "%d:client message\r\n", fd);
                lsa_len = sizeof(struct sockaddr);
                memset(&lsa, 0, lsa_len);
                getsockname(fd, (struct sockaddr *)&lsa, &lsa_len);
                SHOW_LOG("Connected to %s:%d via %d port:%d", ip, port, fd, ntohs(lsa.sin_port));
            }
            else
            {
                FATAL_LOG("Connect to %s:%d failed, %s", ip, port, strerror(errno));
                _exit(-1);
            }
        }
        while(1)
        {
            evbase->loop(evbase, 0, NULL);
            usleep(10);
        }
        //TIMER_CLEAN(timer);
    }
    return -1;
}
Exemple #4
0
int main(int argc, char **argv)
{
	char *ip = NULL;
	int port = 0;
	int fd = 0;
	struct sockaddr_in sa, lsa;
        socklen_t sa_len, lsa_len = -1;
	int opt = 1;
	int i = 0;
	int conn_num = 0;
	EVENT  *event = NULL;
	if(argc < 4)
	{
		fprintf(stderr, "Usage:%s ip port connection_number\n", argv[0]);	
		_exit(-1);
	}	
	ip = argv[1];
	port = atoi(argv[2]);
	conn_num = atoi(argv[3]);
	/* Set resource limit */
    setrlimiter("RLIMIT_NOFILE", RLIMIT_NOFILE, CONN_MAX);	
	/* Initialize global vars */
	memset(events, 0, sizeof(EVENT *) * CONN_MAX);
	/* Initialize inet */ 
	memset(&sa, 0, sizeof(struct sockaddr_in));	
	sa.sin_family = AF_INET;
	sa.sin_addr.s_addr = inet_addr(ip);
	sa.sin_port = htons(port);
	sa_len = sizeof(struct sockaddr);
    /* set evbase */
    if((evbase = evbase_init(0)))
	{
		LOGGER_INIT(evbase->logger, "/tmp/ev_client.log");
        evbase->set_evops(evbase, EOP_SELECT);
		while((fd = socket(AF_INET, SOCK_STREAM, 0)) > 0 && fd < conn_num)
		{
			/* Connect */
			if(connect(fd, (struct sockaddr *)&sa, sa_len) == 0 )
			{
				/* set FD NON-BLOCK */
                                fcntl(fd, F_SETFL, O_NONBLOCK);
				if((events[fd] = ev_init()))
				{
					events[fd]->set(events[fd], fd, E_READ|E_WRITE|E_PERSIST, 
						(void *)events[fd], &ev_handler);
					evbase->add(evbase, events[fd]);
					sprintf(buffer[fd], "%d:client message", fd);
				}
				lsa_len = sizeof(struct sockaddr_in);
                                memset(&lsa, 0, lsa_len);
                                getsockname(fd, (struct sockaddr *)&lsa, &lsa_len);
                                SHOW_LOG("Connected to %s:%d via %d port:%d", ip, port, fd, ntohs(lsa.sin_port));
			}
			else
			{
				FATAL_LOG("Connect to %s:%d failed, %s", ip, port, strerror(errno));
				break;
			}
		}
		while(1)
		{
			evbase->loop(evbase, 0, NULL);
			usleep(10);
		}
	}
}
Exemple #5
0
int main(int argc, char **argv)
{
    pid_t pid;
    char *url = NULL, *urllist = NULL, line[HTTP_BUF_SIZE], *s = NULL, *p = NULL, ch = 0;
    struct hostent *hent = NULL;
    int n = 0, log_level = 0, tcp_option = 0, socket_option = 0, niodaemons = 0, is_realtime = 0;

    /* get configure file */
    while((ch = getopt(argc, argv, "vqpkdr:i:s:x:w:l:c:t:n:e:")) != -1)
    {
        switch(ch)
        {
            case 'c': 
                concurrency = atoi(optarg);
                break;
            case 'n':
                ntasks = atoi(optarg);
                break;
            case 'l':
                urllist = optarg;
                break;
            case 'k':
                is_keepalive = 1;
                break;
            case 'w':
                if((n = atoi(optarg)) > 0) workers = n;
                break;
            case 'd':
                is_daemon = 1;
                break;
            case 'q':
                is_quiet = 1;
                break;
            case 'r':
                is_realtime = atoi(optarg);
                break;
            case 't':
                req_timeout = atoi(optarg);
                break;
            case 'p':
                is_post = 1;
                break;
            case 'x':
                tcp_option = atoi(optarg);
                break;
            case 's':
                socket_option = atoi(optarg);
                break;
            case 'i':
                niodaemons = atoi(optarg);
                break;
            case 'e':
                log_level = atoi(optarg);
                break;
            case 'v':
                is_verbosity = 1;
                break;
            case '?':
                url = argv[optind];
                break;
            default:
                break;
        }
    }
    if(url == NULL && optind < argc)
    {
        //fprintf(stdout, "opt:%c optind:%d arg:%s\n", ch, optind, argv[optind]);
        url = argv[optind];
    }
    //fprintf(stdout, "concurrency:%d nrequests:%d is_keepalive:%d is_daemon:%d\n",
    //       concurrency, ntasks, is_keepalive, is_daemon);
    if(url == NULL)
    {
        fprintf(stderr, "Usage:%s [options] http(s)://host:port/path\n"
                "Options:\n\t-c concurrency\n\t-n requests\n"
                "\t-w worker threads\n\t-e log level\n\t-x tcp_option 1:tcp_nodelay\n"
                "\t-s socket_option 1:socket_linger\n\t-i iodaemons\n"
                "\t-t timeout (microseconds, default 1000000)\n"
                "\t-r is_realtime_thread 1:SCHED_FIFO 2:SCHED_RR\n"
                "\t-p is_POST\n\t-v is_verbosity\n\t-l urllist file\n"
                "\t-k is_keepalive\n\t-d is_daemon\n ", argv[0]);
        _exit(-1);
    }
    p = url;
    s = line;
    while(*p != '\0')
    {
        if(*p >= 'A' && *p <= 'Z')
        {
            *s++ = *p++ + 'a' - 'A';
        }
        else if(*((unsigned char *)p) > 127 || *p == 0x20)
        {
            s += sprintf(s, "%%%02x", *((unsigned char *)p));
            ++p;
        }
        else *s++ = *p++;
    }
    *s = '\0';
    s = line;
    if(strncmp(s, "http://", 7) == 0)
    {
        s += 7;
        server_host = s;
    }
    else if(strncmp(s, "https://", 8) == 0)
    {
        s += 8;
        server_host = s;
        server_is_ssl = 1;
    }
    else goto invalid_url;
    while(*s != '\0' && *s != ':' && *s != '/')s++;
    if(*s == ':')
    {
        *s = '\0';
        ++s;
        server_port = atoi(s);          
        while(*s != '\0' && *s != '/')++s;
    }
    if(*s == '/')
    {
        *s = '\0';
        ++s;
        server_url = s;
    }
    while(*s != '\0' && *s != '?')++s;
    if(*s == '?')
    {
        *s = '\0';
        ++s;
        server_argv = s;
    }
invalid_url:
    if(server_host == NULL || server_port <= 0)
    {
        fprintf(stderr, "Invalid url:%s, url must be http://host:port/path?argv "
                " or https://host:port/path?argv\n", url);
        _exit(-1);
    }
    if(urllist) fp = fopen(urllist, "rd");
    if(is_post)
    {
        p = request;
        p += sprintf(p, "POST /%s HTTP/1.1\r\n", server_url);
        p += sprintf(p, "Host: %s:%d\r\n", server_host, server_port);
        if(is_keepalive) p += sprintf(p, "Connection: Keep-Alive\r\n");
        p += sprintf(p, "Content-Length: %d\r\n\r\n", (int)strlen(server_argv));
        p += sprintf(p, "\r\n");
        if(strlen(server_argv)) p += sprintf(p, "%s", server_argv);
        request_len = p - request;
    }
    else
    {
        p = request;
        if(strlen(server_argv) > 0)
            p += sprintf(p, "GET /%s?%s HTTP/1.1\r\n", server_url, server_argv);
        else 
            p += sprintf(p, "GET /%s HTTP/1.1\r\n", server_url);
        p += sprintf(p, "Host: %s:%d\r\n", server_host, server_port);
        if(is_keepalive) p += sprintf(p, "Connection: Keep-Alive\r\n");
        p += sprintf(p, "\r\n");
        request_len = p - request;
    }
    if((hent = gethostbyname(server_host)) == NULL)
    {
        fprintf(stderr, "resolve hostname:%s failed, %s\n", server_host, strerror(h_errno));
        _exit(-1);
    }
    else
    {
        //memcpy(&ip, &(hent->h_addr), sizeof(int));
        sprintf(server_ip, "%s", inet_ntoa(*((struct in_addr *)(hent->h_addr))));
        if(is_verbosity)
        {
            fprintf(stdout, "ip:%s request:%s\n", server_ip, request);
        }
    }
    //_exit(-1);
    /* locale */
    setlocale(LC_ALL, "C");
    /* signal */
    signal(SIGTERM, &benchmark_stop);
    signal(SIGINT,  &benchmark_stop);
    signal(SIGHUP,  &benchmark_stop);
    signal(SIGPIPE, SIG_IGN);
    signal(SIGCHLD, SIG_IGN);
    //daemon
    if(is_daemon)
    {
        pid = fork();
        switch (pid) {
            case -1:
                perror("fork()");
                exit(EXIT_FAILURE);
                break;
            case 0: //child
                if(setsid() == -1)
                    exit(EXIT_FAILURE);
                break;
            default://parent
                _exit(EXIT_SUCCESS);
                break;
        }
    }
    setrlimiter("RLIMIT_NOFILE", RLIMIT_NOFILE, 65536);
    if((sbase = sbase_init()) == NULL)
    {
        exit(EXIT_FAILURE);
        return -1;
    }
    sbase->nchilds = 0;
    sbase->usec_sleep = 1000;
    sbase->connections_limit = 65536;
    TIMER_INIT(timer);
    MUTEX_INIT(mutex);
    if(log_level > 1)sbase->set_evlog(sbase, "/tmp/benchmark_ev.log");
    if(log_level > 0) sbase->set_evlog_level(sbase, log_level);
    if((service = service_init()))
    {
        service->working_mode = 1;
        service->nprocthreads = workers;
        service->niodaemons = niodaemons;
        service->ndaemons = 0;
        service->use_cond_wait = 1;
        service->flag |= SB_USE_OUTDAEMON|SB_USE_COND;
        if(is_realtime) service->flag |= (SB_SCHED_FIFO|SB_SCHED_RR) & is_realtime;
        if(socket_option == 1) service->flag |= SB_SO_LINGER;
        if(tcp_option == 1) service->flag |= SB_TCP_NODELAY;
        service->service_type = C_SERVICE;
        service->family = AF_INET;
        service->sock_type = SOCK_STREAM;
        service->service_name = "benchmark";
        service->session.flags = SB_NONBLOCK;
        service->session.packet_type = PACKET_DELIMITER;
        service->session.packet_delimiter = "\r\n\r\n";
        service->session.packet_delimiter_length = 4;
        service->session.packet_handler = &benchmark_packet_handler;
        service->session.data_handler = &benchmark_data_handler;
        service->session.transaction_handler = &benchmark_trans_handler;
        service->session.error_handler = &benchmark_error_handler;
        service->session.timeout_handler = &benchmark_timeout_handler;
        service->session.ok_handler = &benchmark_ok_handler;
        service->session.buffer_size = 65536;
        service->set_heartbeat(service, 1000000, &benchmark_heartbeat_handler, NULL);
        //service->set_session(service, &session);
        service->set_log(service, "/tmp/benchmark.log");
        service->set_log_level(service, log_level);
        LOGGER_INIT(logger, "/tmp/benchmark_res.log");
        if(sbase->add_service(sbase, service) == 0)
        {
            sbase->running(sbase, 0);
            //sbase->running(sbase, 3600);
            //sbase->running(sbase, 90000000);sbase->stop(sbase);
        }
        else fprintf(stderr, "add service failed, %s", strerror(errno));
    }
    sbase->clean(sbase);
    MUTEX_DESTROY(mutex);
    return 0;
}
Exemple #6
0
int main(int argc, char **argv)
{
    char *ip = NULL;
    int port = 0;
    int fd = 0;
    struct sockaddr_in sa, lsa;
    socklen_t sa_len, lsa_len = -1;
    int i = 0;
    int conn_num = 0;
    int sock_type = 0;
    int flag = 0;

    if(argc < 5)
    {
        fprintf(stderr, "Usage:%s sock_type(0/TCP|1/UDP) ip port connection_number\n", argv[0]);	
        _exit(-1);
    }	
    ev_sock_type = atoi(argv[1]);
    if(ev_sock_type < 0 || ev_sock_type > ev_sock_count)
    {
        fprintf(stderr, "sock_type must be 0/TCP OR 1/UDP\n");
        _exit(-1);
    }
    sock_type = ev_sock_list[ev_sock_type];
    ip = argv[2];
    port = atoi(argv[3]);
    conn_num = atoi(argv[4]);
    /* Set resource limit */
    setrlimiter("RLIMIT_NOFILE", RLIMIT_NOFILE, CONN_MAX);	
    /* Initialize global vars */
    if((conns = (CONN *)calloc(CONN_MAX, sizeof(CONN))))
    {
        //memset(events, 0, sizeof(EVENT *) * CONN_MAX);
        /* Initialize inet */ 
        memset(&sa, 0, sizeof(struct sockaddr_in));	
        sa.sin_family = AF_INET;
        sa.sin_addr.s_addr = inet_addr(ip);
        sa.sin_port = htons(port);
        sa_len = sizeof(struct sockaddr);
        /* set evbase */
        if((evbase = evbase_init(0)))
        {
            LOGGER_INIT(evbase->logger, "/tmp/ev_client.log");
#ifdef USE_SSL
            SSL_library_init();
            OpenSSL_add_all_algorithms();
            SSL_load_error_strings();
            if((ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
            {
                ERR_print_errors_fp(stdout);
                _exit(-1);
            }
#endif
            //evbase->set_evops(evbase, EOP_POLL);
            while((fd = socket(AF_INET, sock_type, 0)) > 0 && i < conn_num)
            {
                conns[fd].fd = fd;
                /* Connect */
                if(connect(fd, (struct sockaddr *)&sa, sa_len) != 0)
                {
                    FATAL_LOG("Connect to %s:%d failed, %s", ip, port, strerror(errno));
                    break;
                }
                if(is_use_ssl && sock_type == SOCK_STREAM)
                {
#ifdef USE_SSL
                    conns[fd].ssl = SSL_new(ctx);
                    if(conns[fd].ssl == NULL )
                    {
                        FATAL_LOG("new SSL with created CTX failed:%s\n",
                                ERR_reason_error_string(ERR_get_error()));
                        break;
                    }
                    if((ret = SSL_set_fd(conns[fd].ssl, fd)) == 0)
                    {
                        FATAL_LOG("add SSL to tcp socket failed:%s\n",
                                ERR_reason_error_string(ERR_get_error()));
                        break;
                    }
                    /* SSL Connect */
                    if(SSL_connect(conns[fd].ssl) < 0)
                    {
                        FATAL_LOG("SSL connection failed:%s\n",
                                ERR_reason_error_string(ERR_get_error()));
                        break;
                    }
#endif
                }
                /* set FD NON-BLOCK */
                flag = fcntl(fd, F_GETFL, 0);
                flag |= O_NONBLOCK;
                fcntl(fd, F_SETFL, flag);
                    if(sock_type == SOCK_STREAM)
                    {
                        event_set(&conns[fd].event, fd, E_READ|E_WRITE|E_PERSIST, 
                                (void *)&conns[fd].event, &ev_handler);
                    }
                    else
                    {
                        event_set(&conns[fd].event, fd, E_READ|E_WRITE|E_PERSIST, 
                                (void *)&conns[fd].event, &ev_udp_handler);
                    }
                    evbase->add(evbase, &conns[fd].event);
                    sprintf(conns[fd].request, "GET / HTTP/1.0\r\n\r\n");
                lsa_len = sizeof(struct sockaddr);
                memset(&lsa, 0, lsa_len);
                getsockname(fd, (struct sockaddr *)&lsa, &lsa_len);
                SHOW_LOG("%d:Connected to %s:%d via %d port:%d", i, ip, port, fd, ntohs(lsa.sin_port));
                i++;
            }
            while(1)
            {
                evbase->loop(evbase, 0, NULL);
                usleep(1000);
            }
            for(i = 0; i < CONN_MAX; i++)
            {
                    shutdown(conns[i].fd, SHUT_RDWR);
                    close(conns[i].fd);
                    event_destroy(&conns[i].event);
#ifdef USE_SSL
                if(conns[i].ssl)
                {
                    SSL_shutdown(conns[i].ssl);
                    SSL_free(conns[i].ssl); 
                }
#endif
            }
#ifdef USE_SSL
            ERR_free_strings();
            SSL_CTX_free(ctx);
#endif
        }
        free(conns);
    }
    return -1;
}
Exemple #7
0
int main(int argc, char **argv)
{
    int i = 0;

    if(argc < 7)
    {
        fprintf(stderr, "Usage:%s sock_type(0/TCP|1/UDP) iskeepalive ip port concurrecy limit\n", argv[0]);	
        _exit(-1);
    }	
    ev_sock_type = atoi(argv[1]);
    if(ev_sock_type < 0 || ev_sock_type > ev_sock_count)
    {
        fprintf(stderr, "sock_type must be 0/TCP OR 1/UDP\n");
        _exit(-1);
    }
    sock_type = ev_sock_list[ev_sock_type];
    keepalive = atoi(argv[2]);
    ip = argv[3];
    port = atoi(argv[4]);
    conn_num = atoi(argv[5]);
    limit = atoi(argv[6]);
    TIMER_INIT(timer);
    /* Set resource limit */
    setrlimiter("RLIMIT_NOFILE", RLIMIT_NOFILE, CONN_MAX);	
    /* Initialize global vars */
    if((conns = (CONN *)calloc(CONN_MAX, sizeof(CONN))))
    {
        //memset(events, 0, sizeof(EVENT *) * CONN_MAX);
        /* Initialize inet */ 
        memset(&xsa, 0, sizeof(struct sockaddr_in));	
        xsa.sin_family = AF_INET;
        xsa.sin_addr.s_addr = inet_addr(ip);
        xsa.sin_port = htons(port);
        xsa_len = sizeof(struct sockaddr);
        /* set evbase */
        if((evbase = evbase_init(0)))
        {
            if(is_use_ssl)
            {
#ifdef USE_SSL
                SSL_library_init();
                OpenSSL_add_all_algorithms();
                SSL_load_error_strings();
                if((ctx = SSL_CTX_new(SSLv23_client_method())) == NULL)
                {
                    ERR_print_errors_fp(stdout);
                    _exit(-1);
                }
#endif
            }
            for(i = 0; i < conn_num; i++)
            {
                new_request();
                i++;
            }
            running_status = 1;
            do
            {
                evbase->loop(evbase, 0, NULL);
                //usleep(1000);
            }while(running_status);
            for(i = 0; i < CONN_MAX; i++)
            {
                if(conns[i].fd > 0)
                {
                    event_destroy(&conns[i].event);
                    shutdown(conns[i].fd, SHUT_RDWR);
                    close(conns[i].fd);
#ifdef USE_SSL
                    if(conns[i].ssl)
                    {
                        SSL_shutdown(conns[i].ssl);
                        SSL_free(conns[i].ssl); 
                    }
#endif
                }
            }
#ifdef USE_SSL
            ERR_free_strings();
            SSL_CTX_free(ctx);
#endif
        }
        free(conns);
        TIMER_CLEAN(timer);
    }
    return -1;
}