#include "portab.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.104 2002/12/12 12:24:18 alex Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.108 2002/12/26 16:48:14 alex Exp $";
#include "imp.h"
#include <assert.h>
LOCAL fd_set My_Connects;
LOCAL CONNECTION *My_Connections;
-LOCAL LONG Pool_Size;
+LOCAL LONG Pool_Size, WCounter;
GLOBAL VOID
Log( LOG_EMERG, "Can't allocate memory! [Conn_Init]" );
exit( 1 );
}
- Log( LOG_DEBUG, "Allocted connection pool for %ld items.", Pool_Size );
+ Log( LOG_DEBUG, "Allocted connection pool for %ld items (%ld bytes).", Pool_Size, sizeof( CONNECTION ) * Pool_Size );
/* zu Beginn haben wir keine Verbindungen */
FD_ZERO( &My_Listeners );
/* Connection-Struktur initialisieren */
for( i = 0; i < Pool_Size; i++ ) Init_Conn_Struct( i );
+
+ /* Global write counter */
+ WCounter = 0;
} /* Conn_Init */
}
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
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 */
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 */
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++;
My_Connections[Idx].bytes_out += Len;
}
+ /* Adjust global write counter */
+ WCounter += Len;
+
return TRUE;
} /* Conn_Write */
} /* 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 )
{
/* Struktur umkopieren ... */
memcpy( ptr, My_Connections, sizeof( CONNECTION ) * Pool_Size );
- Log( LOG_DEBUG, "Allocated new connection pool for %ld items. [malloc()/memcpy()]", new_size );
+ Log( LOG_DEBUG, "Allocated new connection pool for %ld items (%ld bytes). [malloc()/memcpy()]", new_size, sizeof( CONNECTION ) * new_size );
}
- else Log( LOG_DEBUG, "Allocated new connection pool for %ld items. [realloc()]", new_size );
+ else Log( LOG_DEBUG, "Allocated new connection pool for %ld items (%ld bytes). [realloc()]", new_size, sizeof( CONNECTION ) * new_size );
+ /* Adjust pointer to new block */
My_Connections = ptr;
+
+ /* Initialize new items */
+ for( idx = Pool_Size; idx < new_size; idx++ ) Init_Conn_Struct( idx );
+ idx = Pool_Size;
+
+ /* Adjust new pool size */
Pool_Size = new_size;
}