]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conn.c
- angenommene Socketes werden nun korrekt auf "non-blocking" gestellt;
[ngircd-alex.git] / src / ngircd / conn.c
index 15a0b28beccdf0b63eb735e11540579a8925465c..70ce5d1bc8e1ec316fd57a690b90cb550fea9ed2 100644 (file)
@@ -9,7 +9,7 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: conn.c,v 1.88 2002/11/05 14:18:39 alex Exp $
+ * $Id: conn.c,v 1.91 2002/11/20 15:48:41 alex Exp $
  *
  * connect.h: Verwaltung aller Netz-Verbindungen ("connections")
  */
@@ -779,7 +779,7 @@ Handle_Write( CONN_ID Idx )
                Log( LOG_DEBUG, "Connection %d with \"%s:%d\" established, now sendig PASS and SERVER ...", Idx, My_Connections[Idx].host, Conf_Server[My_Connections[Idx].our_server].port );
 
                /* PASS und SERVER verschicken */
-               Conn_WriteStr( Idx, "PASS %s %s", Conf_Server[My_Connections[Idx].our_server].pwd, NGIRCd_ProtoID );
+               Conn_WriteStr( Idx, "PASS %s %s", Conf_Server[My_Connections[Idx].our_server].pwd_out, NGIRCd_ProtoID );
                return Conn_WriteStr( Idx, "SERVER %s :%s", Conf_ServerName, Conf_ServerInfo );
        }
 
@@ -789,6 +789,9 @@ Handle_Write( CONN_ID Idx )
        len = send( My_Connections[Idx].sock, My_Connections[Idx].wbuf, My_Connections[Idx].wdatalen, 0 );
        if( len < 0 )
        {
+               /* Operation haette Socket "nur" blockiert ... */
+               if( errno == EAGAIN ) return TRUE;
+
                /* Oops, ein Fehler! */
                Log( LOG_ERR, "Write error on connection %d (socket %d): %s!", Idx, My_Connections[Idx].sock, strerror( errno ));
                Conn_Close( Idx, "Write error!", NULL, FALSE );
@@ -822,6 +825,7 @@ New_Connection( INT Sock )
 
        assert( Sock > NONE );
 
+       /* Connection auf Listen-Socket annehmen */
        new_sock_len = sizeof( new_addr );
        new_sock = accept( Sock, (struct sockaddr *)&new_addr, (socklen_t *)&new_sock_len );
        if( new_sock < 0 )
@@ -830,6 +834,9 @@ New_Connection( INT Sock )
                return;
        }
 
+       /* Socket initialisieren */
+       Init_Socket( new_sock );
+
        /* Freie Connection-Struktur suchen */
        for( idx = 0; idx < Pool_Size; idx++ ) if( My_Connections[idx].sock == NONE ) break;
        if( idx >= Pool_Size )
@@ -972,6 +979,9 @@ Read_Request( CONN_ID Idx )
 
        if( len < 0 )
        {
+               /* Operation haette Socket "nur" blockiert ... */
+               if( errno == EAGAIN ) return;
+
                /* Fehler beim Lesen */
                Log( LOG_ERR, "Read error on connection %d (socket %d): %s!", Idx, My_Connections[Idx].sock, strerror( errno ));
                Conn_Close( Idx, "Read error!", "Client closed connection", FALSE );
@@ -1186,7 +1196,7 @@ New_Server( INT Server, CONN_ID Idx )
 
        struct sockaddr_in new_addr;
        struct in_addr inaddr;
-       INT new_sock;
+       INT res, new_sock;
        CLIENT *c;
 
        assert( Server > NONE );
@@ -1232,13 +1242,12 @@ New_Server( INT Server, CONN_ID Idx )
 
        if( ! Init_Socket( new_sock )) return;
 
-       connect( new_sock, (struct sockaddr *)&new_addr, sizeof( new_addr ));
-       if( errno != EINPROGRESS )
+       res = connect( new_sock, (struct sockaddr *)&new_addr, sizeof( new_addr ));
+       if(( res != 0 ) && ( errno != EINPROGRESS ))
        {
-
+               Log( LOG_CRIT, "Can't connect socket: %s!", strerror( errno ));
                close( new_sock );
                Init_Conn_Struct( Idx );
-               Log( LOG_CRIT, "Can't connect socket: %s!", strerror( errno ));
                return;
        }