Minimal changes (needed for merging resolver changes)

This commit is contained in:
Florian Westphal 2005-09-11 11:42:48 +00:00
parent 0aae3ec5d7
commit 4db29b0076
3 changed files with 21 additions and 38 deletions

View File

@ -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 <assert.h>
@ -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;

View File

@ -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 <assert.h>
@ -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( );
@ -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,9 +150,7 @@ 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( );
@ -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 );
}

View File

@ -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- */