mirror of
https://github.com/osmarks/ngircd.git
synced 2025-11-23 08:44:50 +00:00
Changed Handle_Write() to not close sockets itself but to call Conn_Close.
This commit is contained in:
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
ngIRCd 0.9.x
|
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
|
- Fixed a bug that caused the daemon to leak file descriptors when no
|
||||||
resolver subprocesses could be created.
|
resolver subprocesses could be created.
|
||||||
- Fixed server NOTICEs to users with "s" mode ("server messages").
|
- Fixed server NOTICEs to users with "s" mode ("server messages").
|
||||||
@@ -627,4 +629,4 @@ ngIRCd 0.0.1, 31.12.2001
|
|||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
$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 $
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "portab.h"
|
#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 "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -204,6 +204,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++ )
|
||||||
@@ -221,11 +222,14 @@ Conf_UnsetServer( CONN_ID Idx )
|
|||||||
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);
|
||||||
{
|
if (Conf_Server[i].lasttry < t - Conf_ConnectRetry) {
|
||||||
/* Okay, the connection was established "long enough": */
|
/* The connection has been "long", so we don't
|
||||||
Conf_Server[i].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
|
* 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 */
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "portab.h"
|
#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 "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -713,9 +713,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( close( My_Connections[Idx].sock ) != 0 )
|
if( close( My_Connections[Idx].sock ) != 0 )
|
||||||
{
|
{
|
||||||
@@ -859,23 +865,28 @@ Handle_Write( CONN_ID Idx )
|
|||||||
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)
|
||||||
/* Fehler! */
|
Log(LOG_CRIT, "getsockopt (connection %d): %s!",
|
||||||
if( res != 0 ) Log( LOG_CRIT, "getsockopt (connection %d): %s!", Idx, strerror( errno ));
|
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 ));
|
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 */
|
/* Clean up the CLIENT structure (to avoid silly log
|
||||||
FD_CLR( My_Connections[Idx].sock, &My_Sockets );
|
* messages) and call Conn_Close() to do the rest. */
|
||||||
c = Client_GetFromConn( Idx );
|
c = Client_GetFromConn(Idx);
|
||||||
if( c ) Client_DestroyNow( c );
|
if (c)
|
||||||
close( My_Connections[Idx].sock );
|
Client_DestroyNow(c);
|
||||||
Init_Conn_Struct( Idx );
|
|
||||||
|
|
||||||
/* Bei Server-Verbindungen lasttry-Zeitpunkt auf "jetzt" setzen */
|
Conn_Close(Idx, "Can't connect!", NULL, false);
|
||||||
Conf_Server[Conf_GetServer( Idx )].lasttry = time( NULL );
|
|
||||||
Conf_UnsetServer( Idx );
|
/* Set the timestamp of the last connect attempt */
|
||||||
|
Conf_UnsetServer(Idx);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user