diff options
-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 ); |