about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2005-08-27 23:33:10 +0000
committerAlexander Barton <alex@barton.de>2005-08-27 23:33:10 +0000
commite728bd2e1a5bcf69596b8c2a305cd6decbeaf42a (patch)
treeede2202264b797ec8df8cb7716d05f3ab009fafc
parent12e288c0625bde5aa5a56b6d813abbe2b22d2af5 (diff)
downloadngircd-e728bd2e1a5bcf69596b8c2a305cd6decbeaf42a.tar.gz
ngircd-e728bd2e1a5bcf69596b8c2a305cd6decbeaf42a.zip
Changed handling of timeouts for unregistered connections: don't reset
the counter if data is received and disconnect clients earlier.
-rw-r--r--ChangeLog4
-rw-r--r--src/ngircd/conn.c38
2 files changed, 29 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 2018a10f..a9c5e8c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,8 @@
 
 ngIRCd CVSHEAD
 
+  - Changed handling of timeouts for unregistered connections: don't reset
+    the counter if data is received and disconnect clients earlier.
   - Fixed a format string bug in "connection statistics" messages to clients.
   - Removed unnecessary #define of "LOCAL", now use plain C "static" instead.
   - Channel topics are no longer limited to 127 characters: now the only limit
@@ -632,4 +634,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: ChangeLog,v 1.288 2005/08/27 22:59:06 alex Exp $
+$Id: ChangeLog,v 1.289 2005/08/27 23:33:10 alex Exp $
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 714ebe6f..c1bc4c23 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -17,7 +17,7 @@
 #include "portab.h"
 #include "io.h"
 
-static char UNUSED id[] = "$Id: conn.c,v 1.170 2005/08/15 23:02:40 alex Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.171 2005/08/27 23:33:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -1078,6 +1078,7 @@ Read_Request( CONN_ID Idx )
 
 	int len;
 	char readbuf[1024];
+	CLIENT *c;
 
 	assert( Idx > NONE );
 	assert( My_Connections[Idx].sock > NONE );
@@ -1129,13 +1130,21 @@ Read_Request( CONN_ID Idx )
 		}
 	}
 
-	/* Connection-Statistik aktualisieren */
+	/* Update connection statistics */
 	My_Connections[Idx].bytes_in += len;
 
-	/* Timestamp aktualisieren */
-	My_Connections[Idx].lastdata = time( NULL );
-
-	Handle_Buffer( Idx );
+	/* Update timestamp of last data received if this connection is
+	 * registered as a user, server or service connection. Don't update
+	 * otherwise, so users have at least Conf_PongTimeout seconds time to
+	 * register with the IRC server -- see Check_Connections(). */
+	c = Client_GetFromConn(Idx);
+	if (c && (Client_Type(c) == CLIENT_USER
+		  || Client_Type(c) == CLIENT_SERVER
+		  || Client_Type(c) == CLIENT_SERVICE))
+		My_Connections[Idx].lastdata = time(NULL);
+
+	/* Look at the data in the (read-) buffer of this connection */
+	Handle_Buffer(Idx);
 } /* Read_Request */
 
 
@@ -1286,14 +1295,19 @@ Check_Connections( void )
 		}
 		else
 		{
-			/* connection is not fully established yet */
-			if( My_Connections[i].lastdata < time( NULL ) - Conf_PingTimeout )
-			{
-				/* Timeout */
+			/* The connection is not fully established yet, so
+			 * we don't do the PING-PONG game here but instead
+			 * disconnect the client after "a short time" if it's
+			 * still not registered. */
+
+			if (My_Connections[i].lastdata <
+			    time(NULL) - Conf_PongTimeout) {
 #ifdef DEBUG
-				Log( LOG_DEBUG, "Connection %d timed out ...", i );
+				Log(LOG_DEBUG,
+				    "Unregistered connection %d timed out ...",
+				    i);
 #endif
-				Conn_Close( i, NULL, "Timeout", false );
+				Conn_Close(i, NULL, "Timeout", false);
 			}
 		}
 	}