[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] multithreading problem



Hello,

I'm trying to write a simple https server which utilizes multiple cpu cores.
I call evthread_use_pthreads() and create several pthreads. My
acceptcb and the thread worker functions are below.
For some simple test cases it works. If I use a tool like apache ab
for a perfomance test, I get some weird problems. Running the server
on OS X 10.8.2 the system becomes unresponsive. I can scroll in open
windows, but opening new windows or killing the server isn't possible.
Testing it on an actual Debian Linux with gdb shows a "glibc detected
corrupted double-linked list" error and the server receives a SIGSEGV.
I tried 2.1.1 alpha and 2.1.2 alpha. (I need the 2.1 branch because of
the new EVLOOP_NO_EXIT_ON_EMPTY.)

Thanks,
Björn

=====
Code
=====

static void acceptcb(struct evconnlistener *listener, int sock, struct
sockaddr *sa, int sa_len, void *arg) {

    struct bufferevent *bev;
    SSL_CTX *server_ctx;
    SSL *client_ctx;

    server_ctx = (SSL_CTX *)arg;
    client_ctx = SSL_new(server_ctx);

    bev = bufferevent_openssl_socket_new(thread_base[nextFree(threads)],
sock, client_ctx,
                                         BUFFEREVENT_SSL_ACCEPTING,

BEV_OPT_CLOSE_ON_FREE|BEV_OPT_THREADSAFE);

    bufferevent_setcb(bev, readcb, NULL, NULL, NULL);
	bufferevent_enable(bev, EV_READ);

}


static void *worker(void *ptr) {

	struct event_base **evbase = (struct event_base **)ptr;
    *evbase = event_base_new();

    event_base_loop(*evbase, EVLOOP_NO_EXIT_ON_EMPTY);

	pthread_exit(NULL);

}
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.