Changed Handle_Write() to not close sockets itself but to call Conn_Close.
This commit is contained in:
parent
ff218617db
commit
bc09a3e487
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
|
|
||||||
ngIRCd CVSHEAD
|
ngIRCd CVSHEAD
|
||||||
|
|
||||||
|
- Fixed a bug that could cause the damon to crash when outgoing server
|
||||||
|
connections can't be established.
|
||||||
- Internal: Simplified resolver code.
|
- Internal: Simplified resolver code.
|
||||||
- Fixed a bug that caused the daemon to leak file descriptors when no
|
- Fixed a bug that caused the daemon to leak file descriptors when no
|
||||||
resolver subprocesses could be created.
|
resolver subprocesses could be created.
|
||||||
|
@ -641,4 +644,4 @@ ngIRCd 0.0.1, 31.12.2001
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
$Id: ChangeLog,v 1.295 2005/09/12 19:10:20 fw Exp $
|
$Id: ChangeLog,v 1.296 2005/10/11 19:29:23 alex Exp $
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: conf.c,v 1.87 2005/09/24 17:06:54 alex Exp $";
|
static char UNUSED id[] = "$Id: conf.c,v 1.88 2005/10/11 19:29:23 alex Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -254,6 +254,7 @@ Conf_UnsetServer( CONN_ID Idx )
|
||||||
* Non-Server-Connections will be silently ignored. */
|
* Non-Server-Connections will be silently ignored. */
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
/* Check all our configured servers */
|
/* Check all our configured servers */
|
||||||
for( i = 0; i < MAX_SERVERS; i++ ) {
|
for( i = 0; i < MAX_SERVERS; i++ ) {
|
||||||
|
@ -267,10 +268,14 @@ Conf_UnsetServer( CONN_ID Idx )
|
||||||
Init_Server_Struct( &Conf_Server[i] );
|
Init_Server_Struct( &Conf_Server[i] );
|
||||||
} else {
|
} else {
|
||||||
/* Set time for next connect attempt */
|
/* Set time for next connect attempt */
|
||||||
if( Conf_Server[i].lasttry < time( NULL ) - Conf_ConnectRetry ) {
|
t = time(NULL);
|
||||||
/* Okay, the connection was established "long enough": */
|
if (Conf_Server[i].lasttry < t - Conf_ConnectRetry) {
|
||||||
Conf_Server[i].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
|
/* The connection has been "long", so we don't
|
||||||
}
|
* require the next attempt to be delayed. */
|
||||||
|
Conf_Server[i].lasttry =
|
||||||
|
t - Conf_ConnectRetry + RECONNECT_DELAY;
|
||||||
|
} else
|
||||||
|
Conf_Server[i].lasttry = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* Conf_UnsetServer */
|
} /* Conf_UnsetServer */
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: conn.c,v 1.183 2005/09/24 02:48:46 fw Exp $";
|
static char UNUSED id[] = "$Id: conn.c,v 1.184 2005/10/11 19:29:23 alex Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -138,24 +138,29 @@ cb_connserver(int sock, UNUSED short what)
|
||||||
res = getsockopt( My_Connections[idx].sock, SOL_SOCKET, SO_ERROR, &err, &sock_len );
|
res = getsockopt( My_Connections[idx].sock, SOL_SOCKET, SO_ERROR, &err, &sock_len );
|
||||||
assert( sock_len == sizeof( err ));
|
assert( sock_len == sizeof( err ));
|
||||||
|
|
||||||
/* Fehler aufgetreten? */
|
/* Error while connecting? */
|
||||||
if(( res != 0 ) || ( err != 0 )) {
|
if ((res != 0) || (err != 0)) {
|
||||||
if ( res != 0 )
|
if (res != 0)
|
||||||
Log( LOG_CRIT, "getsockopt (connection %d): %s!", idx, strerror( errno ));
|
Log(LOG_CRIT, "getsockopt (connection %d): %s!",
|
||||||
|
idx, strerror(errno));
|
||||||
else
|
else
|
||||||
Log( LOG_CRIT, "Can't connect socket to \"%s:%d\" (connection %d): %s!",
|
Log(LOG_CRIT,
|
||||||
My_Connections[idx].host, Conf_Server[Conf_GetServer( idx )].port,
|
"Can't connect socket to \"%s:%d\" (connection %d): %s!",
|
||||||
idx, strerror( err ));
|
My_Connections[idx].host,
|
||||||
|
Conf_Server[Conf_GetServer(idx)].port,
|
||||||
|
idx, strerror(err));
|
||||||
|
|
||||||
/* Clean up socket, connection and client structures */
|
/* Clean up the CLIENT structure (to avoid silly log
|
||||||
c = Client_GetFromConn( idx );
|
* messages) and call Conn_Close() to do the rest. */
|
||||||
if( c ) Client_DestroyNow( c );
|
c = Client_GetFromConn(idx);
|
||||||
io_close( My_Connections[idx].sock );
|
if (c)
|
||||||
Init_Conn_Struct( idx );
|
Client_DestroyNow(c);
|
||||||
|
|
||||||
|
Conn_Close(idx, "Can't connect!", NULL, false);
|
||||||
|
|
||||||
|
/* Set the timestamp of the last connect attempt */
|
||||||
|
Conf_UnsetServer(idx);
|
||||||
|
|
||||||
/* Bei Server-Verbindungen lasttry-Zeitpunkt auf "jetzt" setzen */
|
|
||||||
Conf_Server[Conf_GetServer( idx )].lasttry = time( NULL );
|
|
||||||
Conf_UnsetServer( idx );
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,9 +736,15 @@ Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient )
|
||||||
Conn_WriteStr(Idx, "ERROR :Closing connection.");
|
Conn_WriteStr(Idx, "ERROR :Closing connection.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to write out the write buffer */
|
/* Try to write out the write buffer. Note: Handle_Write() eventually
|
||||||
|
* removes the CLIENT structure associated with this connection if an
|
||||||
|
* error occurs! So we have to re-check if there is still an valid
|
||||||
|
* CLIENT structure after calling Handle_Write() ...*/
|
||||||
(void)Handle_Write( Idx );
|
(void)Handle_Write( Idx );
|
||||||
|
|
||||||
|
/* Search client, if any (re-check!) */
|
||||||
|
c = Client_GetFromConn( Idx );
|
||||||
|
|
||||||
/* Shut down socket */
|
/* Shut down socket */
|
||||||
if( ! io_close( My_Connections[Idx].sock ))
|
if( ! io_close( My_Connections[Idx].sock ))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue