From 4db29b007689d34adeaca8cbe8676f7c2aedc2ab Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Sun, 11 Sep 2005 11:42:48 +0000 Subject: [PATCH] Minimal changes (needed for merging resolver changes) --- src/ngircd/conn.c | 20 ++++++++++---------- src/ngircd/resolve.c | 30 ++++++++++-------------------- src/ngircd/resolve.h | 9 +-------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index a60fd8e6..8f04a1bb 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.179 2005/09/05 09:10:08 fw Exp $"; +static char UNUSED id[] = "$Id: conn.c,v 1.180 2005/09/11 11:42:48 fw Exp $"; #include "imp.h" #include @@ -1283,7 +1283,8 @@ Check_Connections( void ) CONN_ID i; for( i = 0; i < Pool_Size; i++ ) { - if( My_Connections[i].sock == NONE ) continue; + if (My_Connections[i].sock < 0) + continue; c = Client_GetFromConn( i ); if( c && (( Client_Type( c ) == CLIENT_USER ) || ( Client_Type( c ) == CLIENT_SERVER ) || ( Client_Type( c ) == CLIENT_SERVICE ))) @@ -1365,16 +1366,17 @@ Check_Servers( void ) } /* Check last connect attempt? */ - if( Conf_Server[i].lasttry > time( NULL ) - Conf_ConnectRetry ) continue; + if( Conf_Server[i].lasttry > time( NULL ) - Conf_ConnectRetry ) + continue; /* Okay, try to connect now */ Conf_Server[i].lasttry = time( NULL ); /* Search free connection structure */ for( idx = 0; idx < Pool_Size; idx++ ) if( My_Connections[idx].sock == NONE ) break; - if( idx >= Pool_Size ) - { - Log( LOG_ALERT, "Can't establist server connection: connection limit reached (%d)!", Pool_Size ); + if (idx >= Pool_Size) { + Log( LOG_ALERT, "Can't establist server connection: connection limit reached (%d)!", + Pool_Size ); return; } #ifdef DEBUG @@ -1566,8 +1568,7 @@ void Read_Resolver_Result( int r_fd ) && ( My_Connections[i].res_stat->pipe[0] == r_fd )) break; } - if( i >= Pool_Size ) - { + if( i >= Pool_Size ) { /* Ops, none found? Probably the connection has already * been closed!? We'll ignore that ... */ io_close( r_fd ); @@ -1706,8 +1707,7 @@ Count_Connections( struct sockaddr_in addr_in ) int i, cnt; cnt = 0; - for( i = 0; i < Pool_Size; i++ ) - { + for( i = 0; i < Pool_Size; i++ ) { if(( My_Connections[i].sock > NONE ) && ( My_Connections[i].addr.sin_addr.s_addr == addr_in.sin_addr.s_addr )) cnt++; } return cnt; diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index 3ce055c8..4a6f2e14 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: resolve.c,v 1.19 2005/09/03 11:17:16 fw Exp $"; +static char UNUSED id[] = "$Id: resolve.c,v 1.20 2005/09/11 11:42:48 fw Exp $"; #include "imp.h" #include @@ -83,8 +83,7 @@ Resolve_Addr( struct sockaddr_in *Addr ) /* For sub-process */ pid = fork( ); - if( pid > 0 ) - { + if (pid > 0) { close( s->pipe[1] ); /* Main process */ Log( LOG_DEBUG, "Resolver for %s created (PID %d).", inet_ntoa( Addr->sin_addr ), pid ); @@ -99,9 +98,7 @@ Resolve_Addr( struct sockaddr_in *Addr ) } s->pid = pid; return s; - } - else if( pid == 0 ) - { + } else if( pid == 0 ) { close( s->pipe[0] ); /* Sub process */ Log_Init_Resolver( ); @@ -111,7 +108,7 @@ Resolve_Addr( struct sockaddr_in *Addr ) Do_ResolveAddr( Addr, s->pipe[1] ); #endif Log_Exit_Resolver( ); - exit( 0 ); + exit(0); } Log( LOG_CRIT, "Resolver: Can't fork: %s!", strerror( errno )); @@ -138,8 +135,7 @@ Resolve_Name( char *Host ) /* Fork sub-process */ pid = fork( ); - if( pid > 0 ) - { + if (pid > 0) { close( s->pipe[1] ); /* Main process */ Log( LOG_DEBUG, "Resolver for \"%s\" created (PID %d).", Host, pid ); @@ -154,15 +150,13 @@ Resolve_Name( char *Host ) } s->pid = pid; return s; - } - else if( pid == 0 ) - { + } else if( pid == 0 ) { close( s->pipe[0] ); /* Sub process */ Log_Init_Resolver( ); Do_ResolveName( Host, s->pipe[1] ); Log_Exit_Resolver( ); - exit( 0 ); + exit(0); } Log( LOG_CRIT, "Resolver: Can't fork: %s!", strerror( errno )); @@ -286,13 +280,10 @@ Do_ResolveName( char *Host, int w_fd ) /* Resolve hostname */ h = gethostbyname( Host ); - if( h ) - { + if( h ) { addr = (struct in_addr *)h->h_addr; strlcpy( ip, inet_ntoa( *addr ), sizeof( ip )); - } - else - { + } else { #ifdef h_errno Log_Resolver( LOG_WARNING, "Can't resolve \"%s\": %s!", Host, Get_Error( h_errno )); #else @@ -305,8 +296,7 @@ Do_ResolveName( char *Host, int w_fd ) /* Write result into pipe to parent */ len = strlen( ip ); ip[len] = '\n'; len++; - if( (size_t)write( w_fd, ip, len ) != (size_t)len ) - { + if( (size_t)write( w_fd, ip, len ) != (size_t)len ) { Log_Resolver( LOG_CRIT, "Resolver: Can't write to parent: %s!", strerror( errno )); close( w_fd ); } diff --git a/src/ngircd/resolve.h b/src/ngircd/resolve.h index b13962a8..07912291 100644 --- a/src/ngircd/resolve.h +++ b/src/ngircd/resolve.h @@ -8,7 +8,7 @@ * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: resolve.h,v 1.9 2005/07/28 16:13:09 fw Exp $ + * $Id: resolve.h,v 1.10 2005/09/11 11:42:48 fw Exp $ * * Asynchronous resolver (header) */ @@ -35,11 +35,6 @@ typedef struct _Res_Stat } RES_STAT; -GLOBAL fd_set Resolver_FDs; - - -GLOBAL void Resolve_Init PARAMS(( void )); - #ifdef IDENTAUTH GLOBAL RES_STAT *Resolve_Addr PARAMS(( struct sockaddr_in *Addr, int Sock )); #else @@ -50,6 +45,4 @@ GLOBAL RES_STAT *Resolve_Name PARAMS(( char *Host )); #endif - - /* -eof- */ -- 2.39.2