1
0
mirror of https://github.com/osmarks/ngircd.git synced 2025-11-12 19:53:00 +00:00

removed "my_connects" fd_set.

This commit is contained in:
Florian Westphal
2005-04-23 14:28:44 +00:00
parent c4bc2114c9
commit e7c2c86aee

View File

@@ -16,7 +16,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: conn.c,v 1.148 2005/04/16 20:50:03 fw Exp $"; static char UNUSED id[] = "$Id: conn.c,v 1.149 2005/04/23 14:28:44 fw Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@@ -99,7 +99,6 @@ LOCAL int Count_Connections PARAMS(( struct sockaddr_in addr ));
LOCAL fd_set My_Listeners; LOCAL fd_set My_Listeners;
LOCAL fd_set My_Sockets; LOCAL fd_set My_Sockets;
LOCAL fd_set My_Connects;
#ifdef TCPWRAP #ifdef TCPWRAP
int allow_severity = LOG_INFO; int allow_severity = LOG_INFO;
@@ -135,7 +134,6 @@ Conn_Init( void )
/* zu Beginn haben wir keine Verbindungen */ /* zu Beginn haben wir keine Verbindungen */
FD_ZERO( &My_Listeners ); FD_ZERO( &My_Listeners );
FD_ZERO( &My_Sockets ); FD_ZERO( &My_Sockets );
FD_ZERO( &My_Connects );
/* Groesster File-Descriptor fuer select() */ /* Groesster File-Descriptor fuer select() */
Conn_MaxFD = 0; Conn_MaxFD = 0;
@@ -179,13 +177,6 @@ Conn_Exit( void )
close( i ); close( i );
#ifdef DEBUG #ifdef DEBUG
Log( LOG_DEBUG, "Listening socket %d closed.", i ); Log( LOG_DEBUG, "Listening socket %d closed.", i );
#endif
}
else if( FD_ISSET( i, &My_Connects ))
{
close( i );
#ifdef DEBUG
Log( LOG_DEBUG, "Connection %d closed during creation (socket %d).", idx, i );
#endif #endif
} }
else if( idx < Pool_Size ) else if( idx < Pool_Size )
@@ -417,22 +408,30 @@ Conn_Handler( void )
/* Sockets mit im Aufbau befindlichen ausgehenden Verbindungen suchen */ /* Sockets mit im Aufbau befindlichen ausgehenden Verbindungen suchen */
for( i = 0; i < Pool_Size; i++ ) for( i = 0; i < Pool_Size; i++ )
{ {
if(( My_Connections[i].sock > NONE ) && ( FD_ISSET( My_Connections[i].sock, &My_Connects ))) FD_SET( My_Connections[i].sock, &write_sockets ); if ( My_Connections[i].sock > NONE ) {
if ( Conn_OPTION_ISSET( &My_Connections[i], CONN_ISCONNECTING )) {
FD_SET( My_Connections[i].sock, &write_sockets );
}
}
} }
/* von welchen Sockets koennte gelesen werden? */ /* von welchen Sockets koennte gelesen werden? */
read_sockets = My_Sockets; read_sockets = My_Sockets;
for( i = 0; i < Pool_Size; i++ ) for( i = 0; i < Pool_Size; i++ )
{ {
if(( My_Connections[i].sock > NONE ) && ( My_Connections[i].host[0] == '\0' )) if ( My_Connections[i].sock > NONE ) {
{ if ( My_Connections[i].host[0] == '\0' ) {
/* Hier muss noch auf den Resolver Sub-Prozess gewartet werden */ /* wait for completion of Resolver Sub-Process */
FD_CLR( My_Connections[i].sock, &read_sockets ); FD_CLR( My_Connections[i].sock, &read_sockets );
} continue;
if(( My_Connections[i].sock > NONE ) && ( FD_ISSET( My_Connections[i].sock, &My_Connects ))) }
{
/* Hier laeuft noch ein asyncrones connect() */ if ( Conn_OPTION_ISSET( &My_Connections[i], CONN_ISCONNECTING )) {
FD_CLR( My_Connections[i].sock, &read_sockets ); /* wait for completion of connect() */
FD_CLR( My_Connections[i].sock, &read_sockets );
continue;
}
} }
if( My_Connections[i].delaytime > t ) if( My_Connections[i].delaytime > t )
{ {
@@ -590,8 +589,7 @@ Conn_Write( CONN_ID Idx, char *Data, int Len )
} }
#ifdef ZLIB #ifdef ZLIB
if( My_Connections[Idx].options & CONN_ZIP ) if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
{
/* Daten komprimieren und in Puffer kopieren */ /* Daten komprimieren und in Puffer kopieren */
if( ! Zip_Buffer( Idx, Data, Len )) return false; if( ! Zip_Buffer( Idx, Data, Len )) return false;
} }
@@ -628,8 +626,7 @@ Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient )
assert( Idx > NONE ); assert( Idx > NONE );
/* Is this link already shutting down? */ /* Is this link already shutting down? */
if( My_Connections[Idx].options & CONN_ISCLOSING ) if( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ISCLOSING )) {
{
/* Conn_Close() has been called recursively for this link; /* Conn_Close() has been called recursively for this link;
* probabe reason: Try_Write() failed -- see below. */ * probabe reason: Try_Write() failed -- see below. */
#ifdef DEBUG #ifdef DEBUG
@@ -641,7 +638,7 @@ Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient )
assert( My_Connections[Idx].sock > NONE ); assert( My_Connections[Idx].sock > NONE );
/* Mark link as "closing" */ /* Mark link as "closing" */
My_Connections[Idx].options |= CONN_ISCLOSING; Conn_OPTION_ADD( &My_Connections[Idx], CONN_ISCLOSING );
if( LogMsg ) txt = LogMsg; if( LogMsg ) txt = LogMsg;
else txt = FwdMsg; else txt = FwdMsg;
@@ -682,7 +679,6 @@ Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient )
/* Mark socket as invalid: */ /* Mark socket as invalid: */
FD_CLR( My_Connections[Idx].sock, &My_Sockets ); FD_CLR( My_Connections[Idx].sock, &My_Sockets );
FD_CLR( My_Connections[Idx].sock, &My_Connects );
My_Connections[Idx].sock = NONE; My_Connections[Idx].sock = NONE;
/* If there is still a client, unregister it now */ /* If there is still a client, unregister it now */
@@ -692,8 +688,7 @@ Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient )
in_k = (double)My_Connections[Idx].bytes_in / 1024; in_k = (double)My_Connections[Idx].bytes_in / 1024;
out_k = (double)My_Connections[Idx].bytes_out / 1024; out_k = (double)My_Connections[Idx].bytes_out / 1024;
#ifdef ZLIB #ifdef ZLIB
if( My_Connections[Idx].options & CONN_ZIP ) if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
{
in_z_k = (double)My_Connections[Idx].zip.bytes_in / 1024; in_z_k = (double)My_Connections[Idx].zip.bytes_in / 1024;
out_z_k = (double)My_Connections[Idx].zip.bytes_out / 1024; out_z_k = (double)My_Connections[Idx].zip.bytes_out / 1024;
in_p = (int)(( in_k * 100 ) / in_z_k ); in_p = (int)(( in_k * 100 ) / in_z_k );
@@ -721,8 +716,7 @@ Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient )
#ifdef ZLIB #ifdef ZLIB
/* Clean up zlib, if link was compressed */ /* Clean up zlib, if link was compressed */
if( Conn_Options( Idx ) & CONN_ZIP ) if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
{
inflateEnd( &My_Connections[Idx].zip.in ); inflateEnd( &My_Connections[Idx].zip.in );
deflateEnd( &My_Connections[Idx].zip.out ); deflateEnd( &My_Connections[Idx].zip.out );
} }
@@ -858,12 +852,10 @@ Handle_Write( CONN_ID Idx )
assert( Idx > NONE ); assert( Idx > NONE );
assert( My_Connections[Idx].sock > NONE ); assert( My_Connections[Idx].sock > NONE );
if( FD_ISSET( My_Connections[Idx].sock, &My_Connects )) if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ISCONNECTING )) {
{ /* connect() has finished, check result */
/* es soll nichts geschrieben werden, sondern ein
* connect() hat ein Ergebnis geliefert */
FD_CLR( My_Connections[Idx].sock, &My_Connects ); Conn_OPTION_DEL( &My_Connections[Idx], CONN_ISCONNECTING );
/* Ergebnis des connect() ermitteln */ /* Ergebnis des connect() ermitteln */
sock_len = sizeof( err ); sock_len = sizeof( err );
@@ -1135,8 +1127,7 @@ Read_Request( CONN_ID Idx )
} }
#ifdef ZLIB #ifdef ZLIB
if( My_Connections[Idx].options & CONN_ZIP ) if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
{
len = recv( My_Connections[Idx].sock, My_Connections[Idx].zip.rbuf + My_Connections[Idx].zip.rdatalen, ( ZREADBUFFER_LEN - My_Connections[Idx].zip.rdatalen ), 0 ); len = recv( My_Connections[Idx].sock, My_Connections[Idx].zip.rbuf + My_Connections[Idx].zip.rdatalen, ( ZREADBUFFER_LEN - My_Connections[Idx].zip.rdatalen ), 0 );
if( len > 0 ) My_Connections[Idx].zip.rdatalen += len; if( len > 0 ) My_Connections[Idx].zip.rdatalen += len;
} }
@@ -1201,10 +1192,8 @@ Handle_Buffer( CONN_ID Idx )
#ifdef ZLIB #ifdef ZLIB
/* ggf. noch unkomprimiete Daten weiter entpacken */ /* ggf. noch unkomprimiete Daten weiter entpacken */
if( My_Connections[Idx].options & CONN_ZIP ) if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP ))
{
if( ! Unzip_Buffer( Idx )) return false; if( ! Unzip_Buffer( Idx )) return false;
}
#endif #endif
if( My_Connections[Idx].rdatalen < 1 ) break; if( My_Connections[Idx].rdatalen < 1 ) break;
@@ -1506,7 +1495,8 @@ New_Server( int Server, CONN_ID Idx )
/* Register new socket */ /* Register new socket */
FD_SET( new_sock, &My_Sockets ); FD_SET( new_sock, &My_Sockets );
FD_SET( new_sock, &My_Connects ); Conn_OPTION_ADD( &My_Connections[Idx], CONN_ISCONNECTING );
if( new_sock > Conn_MaxFD ) Conn_MaxFD = new_sock; if( new_sock > Conn_MaxFD ) Conn_MaxFD = new_sock;
#ifdef DEBUG #ifdef DEBUG