diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-01-20 13:21:24 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-01-20 13:21:24 +0100 | 
| commit | fc50d482ae5a7836fbf7c72df168b51d1cf714a5 (patch) | |
| tree | 985aa41b83b307649b6d7f135a0dafbf1ba7aa6a /irc.c | |
| parent | 2fa825ba7c79a0ab4ed9a534865974e918b49100 (diff) | |
irc_abort() does logging (including a reason) now.
Diffstat (limited to 'irc.c')
| -rw-r--r-- | irc.c | 38 | 
1 files changed, 34 insertions, 4 deletions
| @@ -150,11 +150,42 @@ irc_t *irc_new( int fd )  	return( irc );  } -void irc_abort( irc_t *irc ) +void irc_abort( irc_t *irc, int immed, char *format, ... )  { +	va_list params; +	 +	if( format != NULL ) +	{ +		char *reason; +		 +		va_start( params, format ); +		reason = g_strdup_printf( 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->nick, irc->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->nick, irc->host, "No reason given" ); +	} +	  	irc->status = USTATUS_SHUTDOWN; -	if( irc->sendbuffer ) +	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. */ +		  		g_source_remove( irc->r_watch_source_id );  		irc->r_watch_source_id = g_timeout_add_full( G_PRIORITY_HIGH, 1000, (GSourceFunc) irc_free, irc, NULL );  	} @@ -1622,8 +1653,7 @@ static gboolean irc_userping( gpointer _irc )  	if( rv > 0 )  	{ -		irc_write( irc, "ERROR :Closing Link: Ping Timeout: %d seconds", rv ); -		irc_free( irc ); +		irc_abort( irc, "ERROR :Closing Link: Ping Timeout: %d seconds", rv );  		return FALSE;  	} | 
