]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conn.c
Fixed up some castings.
[ngircd-alex.git] / src / ngircd / conn.c
index 882251bcd80f5abf8fe776ed152647649543e4b9..d35a091791893ac6eb071c3b9f3a1a326ca69c95 100644 (file)
@@ -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.122 2003/04/21 10:52:26 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -429,7 +429,7 @@ Conn_Handler( VOID )
                        if( errno != EINTR )
                        {
                                Log( LOG_EMERG, "Conn_Handler(): select(): %s!", strerror( errno ));
-                               Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+                               Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                                exit( 1 );
                        }
                        continue;
@@ -626,7 +626,7 @@ Conn_Close( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient )
        {
                /* Oops, we can't close the socket!? This is fatal! */
                Log( LOG_EMERG, "Error closing connection %d (socket %d) with %s:%d - %s!", Idx, My_Connections[Idx].sock, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port), strerror( errno ));
-               Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+               Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                exit( 1 );
        }
 
@@ -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 )
 {
@@ -767,6 +798,7 @@ Handle_Write( CONN_ID Idx )
        /* Daten aus Schreibpuffer versenden bzw. Connection aufbauen */
 
        INT len, res, err;
+       socklen_t sock_len;
        CLIENT *c;
 
        assert( Idx > NONE );
@@ -780,9 +812,9 @@ Handle_Write( CONN_ID Idx )
                FD_CLR( My_Connections[Idx].sock, &My_Connects );
 
                /* Ergebnis des connect() ermitteln */
-               len = sizeof( err );
-               res = getsockopt( My_Connections[Idx].sock, SOL_SOCKET, SO_ERROR, &err, &len );
-               assert( len == sizeof( err ));
+               sock_len = sizeof( err );
+               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 ))
@@ -870,7 +902,7 @@ New_Connection( INT Sock )
        
 #ifdef USE_TCPWRAP
        /* Validate socket using TCP Wrappers */
-       request_init( &req, RQ_DAEMON, PACKAGE, RQ_FILE, new_sock, RQ_CLIENT_SIN, &new_addr, NULL );
+       request_init( &req, RQ_DAEMON, PACKAGE_NAME, RQ_FILE, new_sock, RQ_CLIENT_SIN, &new_addr, NULL );
        if( ! hosts_access( &req ))
        {
                /* Access denied! */