diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-27 17:33:58 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-05-27 17:33:58 +0200 |
commit | cdca30b360c09399f1e5a2556d83ec997006cd75 (patch) | |
tree | d464f065291461fb9464d13e69b11b21c7e99688 /protocols/events_libevent.c | |
parent | 68b518d6d9a536e2117b399fe4f7fdecdd5d7131 (diff) |
Making sure that event handlers don't get called anymore after a call to
b_main_quit().
Diffstat (limited to 'protocols/events_libevent.c')
-rw-r--r-- | protocols/events_libevent.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/protocols/events_libevent.c b/protocols/events_libevent.c index 3328f68b..1119c2ab 100644 --- a/protocols/events_libevent.c +++ b/protocols/events_libevent.c @@ -38,6 +38,7 @@ static guint id_next; static GHashTable *id_hash; +static int quitting = 0; /* Since libevent doesn't handle two event handlers for one fd-condition very well (which happens sometimes when BitlBee changes event handlers @@ -74,6 +75,10 @@ void b_main_quit() { struct timeval tv; + /* libevent sometimes generates events before really quitting, + we want to stop them. */ + quitting = 1; + memset( &tv, 0, sizeof( struct timeval ) ); event_loopexit( &tv ); } @@ -98,6 +103,12 @@ static void b_event_passthrough( int fd, short event, void *data ) (which free()s b_ev, we have to remember the ID here. */ id = b_ev->id; + if( quitting ) + { + b_event_remove( id ); + return; + } + if( !b_ev->function( b_ev->data, fd, cond ) ) { event_debug( "Handler returned FALSE: " ); |