#include "portab.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.114 2002/12/31 16:13:29 alex Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.116 2003/02/21 19:19:27 alex Exp $";
#include "imp.h"
#include <assert.h>
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 );
}
/* Try to write out the write buffer */
- Try_Write( Idx );
+ (VOID)Try_Write( Idx );
/* Shut down socket */
if( close( My_Connections[Idx].sock ) != 0 )
/* Daten aus Schreibpuffer versenden bzw. Connection aufbauen */
INT len, res, err;
+ CLIENT *c;
assert( Idx > NONE );
assert( My_Connections[Idx].sock > NONE );
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 );