The server tried to connect to other servers only once when DNS or socket
failures occured.
This commit is contained in:
parent
a1ff081b8a
commit
83194a23a3
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
static char UNUSED id[] = "$Id: conn.c,v 1.122 2003/04/21 10:52:26 alex Exp $";
|
static char UNUSED id[] = "$Id: conn.c,v 1.123 2003/04/25 16:47:52 alex Exp $";
|
||||||
|
|
||||||
#include "imp.h"
|
#include "imp.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -1348,7 +1348,7 @@ Check_Servers( VOID )
|
||||||
LOCAL VOID
|
LOCAL VOID
|
||||||
New_Server( INT Server, CONN_ID Idx )
|
New_Server( INT Server, CONN_ID Idx )
|
||||||
{
|
{
|
||||||
/* Neue Server-Verbindung aufbauen */
|
/* Establish new server link */
|
||||||
|
|
||||||
struct sockaddr_in new_addr;
|
struct sockaddr_in new_addr;
|
||||||
struct in_addr inaddr;
|
struct in_addr inaddr;
|
||||||
|
@ -1358,11 +1358,12 @@ New_Server( INT Server, CONN_ID Idx )
|
||||||
assert( Server > NONE );
|
assert( Server > NONE );
|
||||||
assert( Idx > NONE );
|
assert( Idx > NONE );
|
||||||
|
|
||||||
/* Wurde eine gueltige IP-Adresse gefunden? */
|
/* Did we get a valid IP address? */
|
||||||
if( ! Conf_Server[Server].ip[0] )
|
if( ! Conf_Server[Server].ip[0] )
|
||||||
{
|
{
|
||||||
/* Nein. Verbindung wieder freigeben: */
|
/* No. Free connection structure and abort: */
|
||||||
Init_Conn_Struct( Idx );
|
Init_Conn_Struct( Idx );
|
||||||
|
Conf_Server[Server].conn_id = NONE;
|
||||||
Log( LOG_ERR, "Can't connect to \"%s\" (connection %d): ip address unknown!", Conf_Server[Server].host, Idx );
|
Log( LOG_ERR, "Can't connect to \"%s\" (connection %d): ip address unknown!", Conf_Server[Server].host, Idx );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1377,8 +1378,9 @@ New_Server( INT Server, CONN_ID Idx )
|
||||||
if( inaddr.s_addr == (unsigned)-1 )
|
if( inaddr.s_addr == (unsigned)-1 )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Konnte Adresse nicht konvertieren */
|
/* Can't convert IP address */
|
||||||
Init_Conn_Struct( Idx );
|
Init_Conn_Struct( Idx );
|
||||||
|
Conf_Server[Server].conn_id = NONE;
|
||||||
Log( LOG_ERR, "Can't connect to \"%s\" (connection %d): can't convert ip address %s!", Conf_Server[Server].host, Idx, Conf_Server[Server].ip );
|
Log( LOG_ERR, "Can't connect to \"%s\" (connection %d): can't convert ip address %s!", Conf_Server[Server].host, Idx, Conf_Server[Server].ip );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1391,7 +1393,9 @@ New_Server( INT Server, CONN_ID Idx )
|
||||||
new_sock = socket( PF_INET, SOCK_STREAM, 0 );
|
new_sock = socket( PF_INET, SOCK_STREAM, 0 );
|
||||||
if ( new_sock < 0 )
|
if ( new_sock < 0 )
|
||||||
{
|
{
|
||||||
|
/* Can't create socket */
|
||||||
Init_Conn_Struct( Idx );
|
Init_Conn_Struct( Idx );
|
||||||
|
Conf_Server[Server].conn_id = NONE;
|
||||||
Log( LOG_CRIT, "Can't create socket: %s!", strerror( errno ));
|
Log( LOG_CRIT, "Can't create socket: %s!", strerror( errno ));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1401,9 +1405,11 @@ New_Server( INT Server, CONN_ID Idx )
|
||||||
res = connect( new_sock, (struct sockaddr *)&new_addr, sizeof( new_addr ));
|
res = connect( new_sock, (struct sockaddr *)&new_addr, sizeof( new_addr ));
|
||||||
if(( res != 0 ) && ( errno != EINPROGRESS ))
|
if(( res != 0 ) && ( errno != EINPROGRESS ))
|
||||||
{
|
{
|
||||||
|
/* Can't connect socket */
|
||||||
Log( LOG_CRIT, "Can't connect socket: %s!", strerror( errno ));
|
Log( LOG_CRIT, "Can't connect socket: %s!", strerror( errno ));
|
||||||
close( new_sock );
|
close( new_sock );
|
||||||
Init_Conn_Struct( Idx );
|
Init_Conn_Struct( Idx );
|
||||||
|
Conf_Server[Server].conn_id = NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1411,20 +1417,22 @@ New_Server( INT Server, CONN_ID Idx )
|
||||||
c = Client_NewLocal( Idx, inet_ntoa( new_addr.sin_addr ), CLIENT_UNKNOWNSERVER, FALSE );
|
c = Client_NewLocal( Idx, inet_ntoa( new_addr.sin_addr ), CLIENT_UNKNOWNSERVER, FALSE );
|
||||||
if( ! c )
|
if( ! c )
|
||||||
{
|
{
|
||||||
|
/* Can't create new client structure */
|
||||||
close( new_sock );
|
close( new_sock );
|
||||||
Init_Conn_Struct( Idx );
|
Init_Conn_Struct( Idx );
|
||||||
|
Conf_Server[Server].conn_id = NONE;
|
||||||
Log( LOG_ALERT, "Can't establish connection: can't create client structure!" );
|
Log( LOG_ALERT, "Can't establish connection: can't create client structure!" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Client_SetIntroducer( c, c );
|
Client_SetIntroducer( c, c );
|
||||||
Client_SetToken( c, TOKEN_OUTBOUND );
|
Client_SetToken( c, TOKEN_OUTBOUND );
|
||||||
|
|
||||||
/* Verbindung registrieren */
|
/* Register connection */
|
||||||
My_Connections[Idx].sock = new_sock;
|
My_Connections[Idx].sock = new_sock;
|
||||||
My_Connections[Idx].addr = new_addr;
|
My_Connections[Idx].addr = new_addr;
|
||||||
strlcpy( My_Connections[Idx].host, Conf_Server[Server].host, sizeof( My_Connections[Idx].host ));
|
strlcpy( My_Connections[Idx].host, Conf_Server[Server].host, sizeof( My_Connections[Idx].host ));
|
||||||
|
|
||||||
/* Neuen Socket registrieren */
|
/* Register new socket */
|
||||||
FD_SET( new_sock, &My_Sockets );
|
FD_SET( new_sock, &My_Sockets );
|
||||||
FD_SET( new_sock, &My_Connects );
|
FD_SET( new_sock, &My_Connects );
|
||||||
if( new_sock > Conn_MaxFD ) Conn_MaxFD = new_sock;
|
if( new_sock > Conn_MaxFD ) Conn_MaxFD = new_sock;
|
||||||
|
|
Loading…
Reference in New Issue