Changeset fc50d48


Ignore:
Timestamp:
2006-01-20T12:21:24Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
55ec2d6
Parents:
2fa825b
Message:

irc_abort() does logging (including a reason) now.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    r2fa825b rfc50d48  
    163163        if( condition & G_IO_ERR || condition & G_IO_HUP )
    164164        {
    165                 irc_free( irc );
     165                irc_abort( irc, 1, "Read error" );
    166166                return FALSE;
    167167        }
     
    170170        if( st == 0 )
    171171        {
    172                 irc_free( irc );
     172                irc_abort( irc, 1, "Connection reset by peer" );
    173173                return FALSE;
    174174        }
     
    181181                else
    182182                {
    183                         irc_free( irc );
     183                        irc_abort( irc, 1, "Read error: %s", strerror( errno ) );
    184184                        return FALSE;
    185185                }
     
    207207        if( irc->readbuffer && ( strlen( irc->readbuffer ) > 1024 ) )
    208208        {
    209                 log_message( LOGLVL_ERROR, "Maximum line length exceeded." );
    210                 irc_abort( irc );
     209                irc_abort( irc, 0, "Maximum line length exceeded" );
    211210                return FALSE;
    212211        }
     
    229228        if( st == 0 || ( st < 0 && !sockerr_again() ) )
    230229        {
    231                 irc_free( irc );
     230                irc_abort( irc, 1, "Write error: %s", strerror( errno ) );
    232231                return FALSE;
    233232        }
  • irc.c

    r2fa825b rfc50d48  
    151151}
    152152
    153 void irc_abort( irc_t *irc )
    154 {
     153void irc_abort( irc_t *irc, int immed, char *format, ... )
     154{
     155        va_list params;
     156       
     157        if( format != NULL )
     158        {
     159                char *reason;
     160               
     161                va_start( params, format );
     162                reason = g_strdup_printf( format, params );
     163                va_end( params );
     164               
     165                if( !immed )
     166                        irc_write( irc, "ERROR :Closing link: %s", reason );
     167               
     168                ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n",
     169                                   irc->nick, irc->host, reason" );
     170               
     171                g_free( reason );
     172        }
     173        else
     174        {
     175                if( !immed )
     176                        irc_write( irc, "ERROR :Closing link" );
     177               
     178                ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n",
     179                                   irc->nick, irc->host, "No reason given" );
     180        }
     181       
    155182        irc->status = USTATUS_SHUTDOWN;
    156         if( irc->sendbuffer )
    157         {
     183        if( irc->sendbuffer && !immed )
     184        {
     185                /* We won't read from this socket anymore. Instead, we'll connect a timer
     186                   to it that should shut down the connection in a second, just in case
     187                   bitlbee_.._write doesn't do it first. */
     188               
    158189                g_source_remove( irc->r_watch_source_id );
    159190                irc->r_watch_source_id = g_timeout_add_full( G_PRIORITY_HIGH, 1000, (GSourceFunc) irc_free, irc, NULL );
     
    16231654        if( rv > 0 )
    16241655        {
    1625                 irc_write( irc, "ERROR :Closing Link: Ping Timeout: %d seconds", rv );
    1626                 irc_free( irc );
     1656                irc_abort( irc, "ERROR :Closing Link: Ping Timeout: %d seconds", rv );
    16271657                return FALSE;
    16281658        }
  • irc.h

    r2fa825b rfc50d48  
    105105
    106106irc_t *irc_new( int fd );
    107 void irc_abort( irc_t *irc );
     107void irc_abort( irc_t *irc, int immed, char *format, ... );
    108108void irc_free( irc_t *irc );
    109109
Note: See TracChangeset for help on using the changeset viewer.