Having a bit of trouble handling disconnects with libevent Right now, we disable the event from a worker and call bufferevent_free from there. However, as seen in the included back trace, there is a race between the event base trying to acquire another reference.
In general, how should this problem be solved? Is it possible to do without barrier all of the workers, or does the disconnect have to happen from the event base's thread? Seen below, Thread 1 is the event base and Thread 3 is the active worker running a disconnect job. ------ Thread 4 (Thread 0x7ffff59c2710 (LWP 32434)): #0 0x00007ffff6a967d3 in epoll_wait () from /lib/libc.so.6 #1 0x00007ffff79bc3e6 in ?? () from /usr/lib/libevent-2.0.so.5 #2 0x00007ffff79ab281 in event_base_loop () from /usr/lib/libevent-2.0.so.5 #3 0x0000000000418dad in CD_RunTimeLoop (self=<value optimized out>) at TimeLoop.c:76 #4 0x00007ffff6d248c4 in start_thread () from /lib/libpthread.so.0 #5 0x00007ffff6a961dd in clone () from /lib/libc.so.6 Thread 3 (Thread 0x7ffff61c3710 (LWP 32433)): #0 0x00007ffff6d2925c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 #1 0x00007ffff7bdcf75 in ?? () from /usr/lib/libevent_pthreads-2.0.so.5 #2 0x00007ffff79ac3d8 in ?? () from /usr/lib/libevent-2.0.so.5 #3 0x00007ffff79aa2ad in event_del () from /usr/lib/libevent-2.0.so.5 #4 0x00007ffff79b2d15 in ?? () from /usr/lib/libevent-2.0.so.5 #5 0x00007ffff79b1a0b in bufferevent_disable () from /usr/lib/libevent-2.0.so.5 #6 0x0000000000415a01 in CD_DestroyPlayer (self=0x7ffff0004190) at Player.c:67 #7 0x000000000041911a in CD_RunWorker (self=0x629400) at Worker.c:162 #8 0x00007ffff6d248c4 in start_thread () from /lib/libpthread.so.0 #9 0x00007ffff6a961dd in clone () from /lib/libc.so.6 Thread 2 (Thread 0x7ffff69c4710 (LWP 32432)): #0 0x00007ffff6d2925c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0 #1 0x0000000000419038 in CD_RunWorker (self=0x6292a0) at Worker.c:75 #2 0x00007ffff6d248c4 in start_thread () from /lib/libpthread.so.0 #3 0x00007ffff6a961dd in clone () from /lib/libc.so.6 Thread 1 (Thread 0x7ffff7fcb700 (LWP 32429)): #0 0x00007ffff6d2bc74 in __lll_lock_wait () from /lib/libpthread.so.0 #1 0x00007ffff6d271f4 in _L_lock_547 () from /lib/libpthread.so.0 #2 0x00007ffff6d27057 in pthread_mutex_lock () from /lib/libpthread.so.0 #3 0x00007ffff79ac472 in ?? () from /usr/lib/libevent-2.0.so.5 #4 0x00007ffff79b1aec in _bufferevent_incref_and_lock () from /usr/lib/libevent-2.0.so.5 #5 0x00007ffff79b2ead in ?? () from /usr/lib/libevent-2.0.so.5 #6 0x00007ffff79ab37c in event_base_loop () from /usr/lib/libevent-2.0.so.5 #7 0x0000000000417864 in CD_RunServer (self=0x626070) at Server.c:362 #8 0x000000000040fdaa in main (argc=5, argv=0x7fffffffde98) at craftd.c:145 Regards, Kevin *********************************************************************** To unsubscribe, send an e-mail to [email protected] with unsubscribe libevent-users in the body.
