X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconn.c;h=37c5c3819a49390a298bfcb80a33b7919595d1f8;hp=3975a920429dcb7b2bbf911bbd1b3272ffc1b3c9;hb=cf4ad8d6f7f9adffda596d67551811ac26f6a35a;hpb=b77dae34999581f42b3a436abdbe35c777b64b98 diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 3975a920..37c5c381 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -16,7 +16,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: conn.c,v 1.113 2002/12/30 17:14:59 alex Exp $"; +static char UNUSED id[] = "$Id: conn.c,v 1.116 2003/02/21 19:19:27 alex Exp $"; #include "imp.h" #include @@ -529,6 +529,17 @@ Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ) assert( Idx > NONE ); assert( My_Connections[Idx].sock > NONE ); + /* Is this link already shutting down? */ + if( My_Connections[Idx].options & CONN_ISCLOSING ) + { + /* Conn_Close() has been called recursively for this link; + * probabe reason: Try_Write() failed -- see below. */ + return; + } + + /* Mark link as "closing" */ + My_Connections[Idx].options |= CONN_ISCLOSING; + /* Search client, if any */ c = Client_GetFromConn( Idx ); @@ -550,7 +561,7 @@ Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ) } /* Try to write out the write buffer */ - Try_Write( Idx ); + (VOID)Try_Write( Idx ); /* Shut down socket */ if( close( My_Connections[Idx].sock ) != 0 ) @@ -698,6 +709,7 @@ Handle_Write( CONN_ID Idx ) /* Daten aus Schreibpuffer versenden bzw. Connection aufbauen */ INT len, res, err; + CLIENT *c; assert( Idx > NONE ); assert( My_Connections[Idx].sock > NONE ); @@ -721,8 +733,10 @@ Handle_Write( CONN_ID Idx ) if( res != 0 ) Log( LOG_CRIT, "getsockopt (connection %d): %s!", Idx, strerror( errno )); else Log( LOG_CRIT, "Can't connect socket to \"%s:%d\" (connection %d): %s!", My_Connections[Idx].host, Conf_Server[Conf_GetServer( Idx )].port, Idx, strerror( err )); - /* Socket etc. pp. aufraeumen */ + /* Clean up socket, connection and client structures */ FD_CLR( My_Connections[Idx].sock, &My_Sockets ); + c = Client_GetFromConn( Idx ); + if( c ) Client_DestroyNow( c ); close( My_Connections[Idx].sock ); Init_Conn_Struct( Idx ); @@ -1162,9 +1176,6 @@ Check_Servers( VOID ) CONN_ID idx; INT i, n; - /* Don't connect in "passive mode" */ - if( NGIRCd_Passive ) return; - /* Serach all connections, are there results from the resolver? */ for( idx = 0; idx < Pool_Size; idx++ ) { @@ -1177,8 +1188,8 @@ Check_Servers( VOID ) /* Check all configured servers */ for( i = 0; i < MAX_SERVERS; i++ ) { - /* Valid outgoing server which isn't already connected? */ - if(( ! Conf_Server[i].host[0] ) || ( ! Conf_Server[i].port > 0 ) || ( Conf_Server[i].conn_id > NONE )) continue; + /* Valid outgoing server which isn't already connected or disabled? */ + if(( ! Conf_Server[i].host[0] ) || ( ! Conf_Server[i].port > 0 ) || ( Conf_Server[i].conn_id > NONE ) || ( Conf_Server[i].flags & CONF_SFLAG_DISABLED )) continue; /* Is there already a connection in this group? */ if( Conf_Server[i].group > NONE )