X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconn.c;h=324fa4219a9d204723572e1eeb8fbf8ea1badbee;hp=86aeb6524d4dc13382d23dd6b6d5bf386a57d4b5;hb=2cebfc54f5c450577e0a6d4f61a421ac2396e44e;hpb=8f5cbe51a79c786be30ebc93466988cf67a825e1 diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 86aeb652..324fa421 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -1181,8 +1181,8 @@ Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClie /* Is this link already shutting down? */ if( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ISCLOSING )) { /* Conn_Close() has been called recursively for this link; - * probabe reason: Handle_Write() failed -- see below. */ - LogDebug("Recursive request to close connection: %d", Idx ); + * probable reason: Handle_Write() failed -- see below. */ + LogDebug("Recursive request to close connection %d!", Idx ); return; } @@ -1228,7 +1228,7 @@ Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClie c = Conn_GetClient( Idx ); #ifdef SSL_SUPPORT if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_SSL )) { - Log(LOG_INFO, "SSL connection %d shutting down ...", Idx); + LogDebug("SSL connection %d shutting down ...", Idx); ConnSSL_Free(&My_Connections[Idx]); } #endif @@ -1450,8 +1450,13 @@ Handle_Write( CONN_ID Idx ) if (errno == EAGAIN || errno == EINTR) return true; - Log(LOG_ERR, "Write error on connection %d (socket %d): %s!", - Idx, My_Connections[Idx].sock, strerror(errno)); + if (!Conn_OPTION_ISSET(&My_Connections[Idx], CONN_ISCLOSING)) + Log(LOG_ERR, + "Write error on connection %d (socket %d): %s!", + Idx, My_Connections[Idx].sock, strerror(errno)); + else + LogDebug("Recursive write error on connection %d (socket %d): %s!", + Idx, My_Connections[Idx].sock, strerror(errno)); Conn_Close(Idx, "Write error", NULL, false); return false; } @@ -1663,7 +1668,11 @@ Conn_StartLogin(CONN_ID Idx) #endif (void)Conn_WriteStr(Idx, "NOTICE AUTH :*** Looking up your hostname"); - (void)Handle_Write(Idx); + /* Send buffered data to the client, but break on errors + * because Handle_Write() would have closed the connection + * again in this case! */ + if (!Handle_Write(Idx)) + return; } Resolve_Addr(&My_Connections[Idx].proc_stat, &My_Connections[Idx].addr, @@ -2122,6 +2131,7 @@ New_Server( int Server , ng_ipaddr_t *dest) if (!ng_ipaddr_tostr_r(dest, ip_str)) { Log(LOG_WARNING, "New_Server: Could not convert IP to string"); + Conf_Server[Server].conn_id = NONE; return; } @@ -2136,11 +2146,14 @@ New_Server( int Server , ng_ipaddr_t *dest) if (new_sock < 0) { Log(LOG_CRIT, "Can't create socket (af %d): %s!", af_dest, strerror(errno)); + Conf_Server[Server].conn_id = NONE; return; } - if (!Init_Socket(new_sock)) + if (!Init_Socket(new_sock)) { + Conf_Server[Server].conn_id = NONE; return; + } /* is a bind address configured? */ res = ng_ipaddr_af(&Conf_Server[Server].bind_addr); @@ -2156,6 +2169,7 @@ New_Server( int Server , ng_ipaddr_t *dest) if(( res != 0 ) && ( errno != EINPROGRESS )) { Log( LOG_CRIT, "Can't connect socket: %s!", strerror( errno )); close( new_sock ); + Conf_Server[Server].conn_id = NONE; return; } @@ -2164,12 +2178,14 @@ New_Server( int Server , ng_ipaddr_t *dest) "Cannot allocate memory for server connection (socket %d)", new_sock); close( new_sock ); + Conf_Server[Server].conn_id = NONE; return; } if (!io_event_create( new_sock, IO_WANTWRITE, cb_connserver)) { Log(LOG_ALERT, "io_event_create(): could not add fd %d", strerror(errno)); close(new_sock); + Conf_Server[Server].conn_id = NONE; return; } @@ -2184,6 +2200,7 @@ New_Server( int Server , ng_ipaddr_t *dest) if (!c) { Log( LOG_ALERT, "Can't establish connection: can't create client structure!" ); io_close(new_sock); + Conf_Server[Server].conn_id = NONE; return; } @@ -2445,21 +2462,27 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) *ptr ? "" : ": ", *ptr ? "" : identptr); } - } else { + } else if(Conf_Ident) { Log(LOG_INFO, "IDENT lookup for connection %d: no result.", i); - if (Conf_NoticeAuth && Conf_Ident) + if (Conf_NoticeAuth) (void)Conn_WriteStr(i, "NOTICE AUTH :*** No ident response"); } #endif - if (Conf_NoticeAuth) - (void)Handle_Write(i); + if (Conf_NoticeAuth) { + /* Send buffered data to the client, but break on + * errors because Handle_Write() would have closed + * the connection again in this case! */ + if (!Handle_Write(i)) + return; + } Class_HandleServerBans(c); } #ifdef DEBUG - else Log( LOG_DEBUG, "Resolver: discarding result for already registered connection %d.", i ); + else + LogDebug("Resolver: discarding result for already registered connection %d.", i); #endif } /* cb_Read_Resolver_Result */