diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2008-04-02 22:36:02 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2008-04-02 22:36:02 +0100 |
commit | 883a398f059f98cb31da77dd6e632e4152dcf87e (patch) | |
tree | e08f8b2f53ce24b0647fe3a3d3cb3931b5d543f8 | |
parent | fa75134008bd9206ca02380927c27581feb65c3e (diff) |
Rearranged some event handling code.
-rw-r--r-- | bitlbee.c | 12 | ||||
-rw-r--r-- | irc.c | 13 |
2 files changed, 16 insertions, 9 deletions
@@ -225,12 +225,16 @@ gboolean bitlbee_io_current_client_write( gpointer data, gint fd, b_input_condit if( st == size ) { - g_free( irc->sendbuffer ); - irc->sendbuffer = NULL; - irc->w_watch_source_id = 0; - if( irc->status & USTATUS_SHUTDOWN ) + { irc_free( irc ); + } + else + { + g_free( irc->sendbuffer ); + irc->sendbuffer = NULL; + irc->w_watch_source_id = 0; + } return FALSE; } @@ -198,12 +198,14 @@ void irc_abort( irc_t *irc, int immed, char *format, ... ) irc->status |= USTATUS_SHUTDOWN; if( irc->sendbuffer && !immed ) { - /* We won't read from this socket anymore. Instead, we'll connect a timer - to it that should shut down the connection in a second, just in case - bitlbee_.._write doesn't do it first. */ + /* Set up a timeout event that should shut down the connection + in a second, just in case ..._write doesn't do it first. */ b_event_remove( irc->r_watch_source_id ); - irc->r_watch_source_id = b_timeout_add( 1000, (b_event_handler) irc_free, irc ); + irc->r_watch_source_id = 0; + + b_event_remove( irc->ping_source_id ); + irc->ping_source_id = b_timeout_add( 1000, (b_event_handler) irc_free, irc ); } else { @@ -273,7 +275,8 @@ void irc_free( irc_t * irc ) if( irc->ping_source_id > 0 ) b_event_remove( irc->ping_source_id ); - b_event_remove( irc->r_watch_source_id ); + if( irc->r_watch_source_id > 0 ) + b_event_remove( irc->r_watch_source_id ); if( irc->w_watch_source_id > 0 ) b_event_remove( irc->w_watch_source_id ); |