commit - ff91c6db38ba2ea4bd3134e58366ebd16fa14698
commit + 216eb30c73dfbdf6ba5586ed74c5b8d5d212765c
blob - 1ed41407f241336cd61fc1bd278e5e64c2eb713b
blob + b10c1d55e2c41cbe094f51dd8c07755fefe22d47
--- ChangeLog
+++ ChangeLog
ngIRCd 0.9.x
+ - Fixed a bug that could cause the damon to crash when outgoing server
+ connections can't be established.
- Fixed a bug that caused the daemon to leak file descriptors when no
resolver subprocesses could be created.
- Fixed server NOTICEs to users with "s" mode ("server messages").
--
-$Id: ChangeLog,v 1.276.2.10 2005/09/02 22:10:58 alex Exp $
+$Id: ChangeLog,v 1.276.2.11 2005/10/11 19:28:47 alex Exp $
blob - 77e52cb69b571d2863d54243276130fd4956a900
blob + 575f283dcf153be392cdbffb55ca800210e56da1
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
#include "portab.h"
-static char UNUSED id[] = "$Id: conf.c,v 1.77 2005/06/17 19:16:53 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.77.2.1 2005/10/11 19:28:47 alex Exp $";
#include "imp.h"
#include <assert.h>
* Non-Server-Connections will be silently ignored. */
int i;
+ time_t t;
/* Check all our configured servers */
for( i = 0; i < MAX_SERVERS; i++ )
else
{
/* Set time for next connect attempt */
- if( Conf_Server[i].lasttry < time( NULL ) - Conf_ConnectRetry )
- {
- /* Okay, the connection was established "long enough": */
- Conf_Server[i].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
- }
+ t = time(NULL);
+ if (Conf_Server[i].lasttry < t - Conf_ConnectRetry) {
+ /* 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 */
blob - 258885ecc7f829a9bf06d01f2d6b81ecb5db78f8
blob + 660cca01e490f8dce57407ca6c004fdcab55a5d2
--- src/ngircd/conn.c
+++ src/ngircd/conn.c
#include "portab.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.155.2.2 2005/08/25 09:04:23 alex Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.155.2.3 2005/10/11 19:28:47 alex Exp $";
#include "imp.h"
#include <assert.h>
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 );
+ /* Search client, if any (re-check!) */
+ c = Client_GetFromConn( Idx );
+
/* Shut down socket */
if( close( My_Connections[Idx].sock ) != 0 )
{
res = getsockopt( My_Connections[Idx].sock, SOL_SOCKET, SO_ERROR, &err, &sock_len );
assert( sock_len == sizeof( err ));
- /* Fehler aufgetreten? */
- if(( res != 0 ) || ( err != 0 ))
- {
- /* Fehler! */
- 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 ));
-
- /* 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 );
+ /* Error while connecting? */
+ if ((res != 0) || (err != 0)) {
+ 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));
- /* Bei Server-Verbindungen lasttry-Zeitpunkt auf "jetzt" setzen */
- Conf_Server[Conf_GetServer( Idx )].lasttry = time( NULL );
- Conf_UnsetServer( Idx );
+ /* Clean up the CLIENT structure (to avoid silly log
+ * messages) and call Conn_Close() to do the rest. */
+ c = Client_GetFromConn(Idx);
+ if (c)
+ Client_DestroyNow(c);
+ Conn_Close(Idx, "Can't connect!", NULL, false);
+
+ /* Set the timestamp of the last connect attempt */
+ Conf_UnsetServer(Idx);
+
return false;
}
Log( LOG_INFO, "Connection %d with \"%s:%d\" established. Now logging in ...", Idx, My_Connections[Idx].host, Conf_Server[Conf_GetServer( Idx )].port );