X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconn.c;h=43625fe0d22c85ccb76f8226fdcc2cf7cad9629e;hp=ce245a981356a45ee561eb1736874141ffa9fcac;hb=6626395c88fc46eeb110942b17eb9245a1d0021b;hpb=902ad91212f3d756fa898239108128d2230bdc0c diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index ce245a98..43625fe0 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: conn.c,v 1.105 2002/12/17 11:46:54 alex Exp $"; +static char UNUSED id[] = "$Id: conn.c,v 1.108 2002/12/26 16:48:14 alex Exp $"; #include "imp.h" #include @@ -129,7 +129,7 @@ LOCAL fd_set My_Sockets; LOCAL fd_set My_Connects; LOCAL CONNECTION *My_Connections; -LOCAL LONG Pool_Size; +LOCAL LONG Pool_Size, WCounter; GLOBAL VOID @@ -165,6 +165,9 @@ Conn_Init( VOID ) /* Connection-Struktur initialisieren */ for( i = 0; i < Pool_Size; i++ ) Init_Conn_Struct( i ); + + /* Global write counter */ + WCounter = 0; } /* Conn_Init */ @@ -199,7 +202,7 @@ Conn_Exit( VOID ) } else if( idx < Pool_Size ) { - if( NGIRCd_Restart ) Conn_Close( idx, NULL, "Server going down (restarting)", TRUE ); + if( NGIRCd_SignalRestart ) Conn_Close( idx, NULL, "Server going down (restarting)", TRUE ); else Conn_Close( idx, NULL, "Server going down", TRUE ); } else @@ -329,12 +332,15 @@ Conn_Handler( VOID ) BOOLEAN timeout; start = time( NULL ); - while(( ! NGIRCd_Quit ) && ( ! NGIRCd_Restart )) + while(( ! NGIRCd_SignalQuit ) && ( ! NGIRCd_SignalRestart )) { timeout = TRUE; - - Check_Servers( ); + /* Should the configuration be reloaded? */ + if( NGIRCd_SignalRehash ) NGIRCd_Rehash( ); + + /* Check configured servers and established links */ + Check_Servers( ); Check_Connections( ); /* noch volle Lese-Buffer suchen */ @@ -445,6 +451,9 @@ Conn_Handler( VOID ) if( FD_ISSET( i, &read_sockets )) Handle_Read( i ); } } + + if( NGIRCd_SignalQuit ) Log( LOG_NOTICE|LOG_snotice, "Server going down NOW!" ); + else if( NGIRCd_SignalRestart ) Log( LOG_NOTICE|LOG_snotice, "Server restarting NOW!" ); } /* Conn_Handler */ @@ -486,7 +495,7 @@ va_dcl if( NGIRCd_Sniffer ) Log( LOG_DEBUG, " -> connection %d: '%s'.", Idx, buffer ); #endif - strcat( buffer, "\r\n" ); + strlcat( buffer, "\r\n", sizeof( buffer )); ok = Conn_Write( Idx, buffer, strlen( buffer )); My_Connections[Idx].msg_out++; @@ -548,6 +557,9 @@ Conn_Write( CONN_ID Idx, CHAR *Data, INT Len ) My_Connections[Idx].bytes_out += Len; } + /* Adjust global write counter */ + WCounter += Len; + return TRUE; } /* Conn_Write */ @@ -967,6 +979,20 @@ Conn_RecvBytes( CONN_ID Idx ) } /* Conn_RecvBytes */ +GLOBAL VOID +Conn_ResetWCounter( VOID ) +{ + WCounter = 0; +} /* Conn_ResetWCounter */ + + +GLOBAL LONG +Conn_WCounter( VOID ) +{ + return WCounter; +} /* Conn_WCounter */ + + LOCAL BOOLEAN Try_Write( CONN_ID Idx ) {