about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2003-03-27 01:20:22 +0000
committerAlexander Barton <alex@barton.de>2003-03-27 01:20:22 +0000
commit59a0fb8cd999d07ce46b1c5d071d9765af9ddbe8 (patch)
tree14d5be37389ca209748d7a4ded6d707df92f30a4
parentd383703b78f78a49f8bd44356e557d6efb346c9a (diff)
downloadngircd-59a0fb8cd999d07ce46b1c5d071d9765af9ddbe8.tar.gz
ngircd-59a0fb8cd999d07ce46b1c5d071d9765af9ddbe8.zip
New function Conn_SyncServerStruct().
-rw-r--r--src/ngircd/conn.c33
-rw-r--r--src/ngircd/conn.h3
2 files changed, 34 insertions, 2 deletions
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 882251bc..fa8b3053 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -16,7 +16,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conn.c,v 1.119 2003/03/07 17:16:49 alex Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.120 2003/03/27 01:20:22 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -683,6 +683,37 @@ Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient )
 } /* Conn_Close */
 
 
+GLOBAL VOID
+Conn_SyncServerStruct( VOID )
+{
+	/* Synchronize server structures (connection IDs):
+	 * connections <-> configuration */
+
+	CLIENT *client;
+	CONN_ID i;
+	INT c;
+
+	for( i = 0; i < Pool_Size; i++ )
+	{
+		/* Established connection? */
+		if( My_Connections[i].sock <= NONE ) continue;
+
+		/* Server connection? */
+		client = Client_GetFromConn( i );
+		if(( ! client ) || ( Client_Type( client ) != CLIENT_SERVER )) continue;
+
+		for( c = 0; c < MAX_SERVERS; c++ )
+		{
+			/* Configured server? */
+			if( ! Conf_Server[c].host[0] ) continue;
+
+			/* Duplicate? */
+			if( strcmp( Conf_Server[c].name, Client_ID( client )) == 0 ) Conf_Server[c].conn_id = i;
+		}
+	}
+} /* SyncServerStruct */
+
+
 LOCAL BOOLEAN
 Try_Write( CONN_ID Idx )
 {
diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h
index 2194f537..ffbfe64a 100644
--- a/src/ngircd/conn.h
+++ b/src/ngircd/conn.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conn.h,v 1.30 2003/02/21 19:18:48 alex Exp $
+ * $Id: conn.h,v 1.31 2003/03/27 01:20:22 alex Exp $
  *
  * Connection management (header)
  */
@@ -96,6 +96,7 @@ GLOBAL BOOLEAN Conn_WriteStr PARAMS(( CONN_ID Idx, CHAR *Format, ... ));
 
 GLOBAL VOID Conn_Close PARAMS(( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ));
 
+GLOBAL VOID Conn_SyncServerStruct PARAMS(( VOID ));
 
 GLOBAL INT Conn_MaxFD;