aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitlbee.c2
-rw-r--r--ipc.c3
-rw-r--r--irc.c45
-rw-r--r--unix.c2
4 files changed, 19 insertions, 33 deletions
diff --git a/bitlbee.c b/bitlbee.c
index 5ced6469..ac22932f 100644
--- a/bitlbee.c
+++ b/bitlbee.c
@@ -371,7 +371,7 @@ gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond )
{
/* Try to save data for all active connections (if desired). */
while( irc_connection_list != NULL )
- irc_abort( irc_connection_list->data, FALSE,
+ irc_abort( irc_connection_list->data, TRUE,
"BitlBee server shutting down" );
/* We'll only reach this point when not running in inetd mode: */
diff --git a/ipc.c b/ipc.c
index b327d717..681690de 100644
--- a/ipc.c
+++ b/ipc.c
@@ -420,10 +420,7 @@ static void ipc_child_cmd_takeover_yes( void *data )
irc_umode_set( irc, "-R", 1 );
if( old )
- {
- irc->status |= USTATUS_SHUTDOWN;
irc_abort( irc, FALSE, NULL );
- }
}
static void ipc_child_cmd_takeover_no( void *data )
diff --git a/irc.c b/irc.c
index 1d2b729c..b5487b38 100644
--- a/irc.c
+++ b/irc.c
@@ -160,47 +160,34 @@ irc_t *irc_new( int fd )
shouldn't try to write to it. */
void irc_abort( irc_t *irc, int immed, char *format, ... )
{
+ char *reason = NULL;
+
if( format != NULL )
{
va_list params;
- char *reason;
va_start( params, format );
reason = g_strdup_vprintf( format, params );
va_end( params );
-
- if( !immed )
- irc_write( irc, "ERROR :Closing link: %s", reason );
-
- ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n",
- irc->user->nick ? irc->user->nick : "(NONE)", irc->user->host, reason );
-
- g_free( reason );
- }
- else
- {
- if( !immed )
- irc_write( irc, "ERROR :Closing link" );
-
- ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n",
- irc->user->nick ? irc->user->nick : "(NONE)", irc->user->host, "No reason given" );
}
- irc->status |= USTATUS_SHUTDOWN;
- if( irc->sendbuffer && !immed )
+ irc_write( irc, "ERROR :Closing link: %s", reason ? : "" );
+
+ ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n",
+ irc->user->nick ? irc->user->nick : "(NONE)",
+ irc->user->host, reason ? : "" );
+
+ g_free( reason );
+
+ irc_flush( irc );
+ if( immed )
{
- /* 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 = 0;
-
- b_event_remove( irc->ping_source_id );
- irc->ping_source_id = b_timeout_add( 1000, (b_event_handler) irc_free, irc );
+ irc_free( irc );
}
else
{
- irc_free( irc );
+ b_event_remove( irc->ping_source_id );
+ irc->ping_source_id = b_timeout_add( 1, (b_event_handler) irc_free, irc );
}
}
@@ -208,6 +195,8 @@ static gboolean irc_free_hashkey( gpointer key, gpointer value, gpointer data );
void irc_free( irc_t * irc )
{
+ irc->status |= USTATUS_SHUTDOWN;
+
log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd );
if( irc->status & USTATUS_IDENTIFIED && set_getbool( &irc->b->set, "save_on_quit" ) )
diff --git a/unix.c b/unix.c
index a9045c44..38366111 100644
--- a/unix.c
+++ b/unix.c
@@ -238,7 +238,7 @@ static void sighandler( int signal )
{
/* FIXME: Calling log_message() here is not a very good idea! */
- if( signal == SIGTERM )
+ if( signal == SIGTERM || signal == SIGQUIT || signal == SIGINT )
{
static int first = 1;