commit - c4bc2114c91a91ba8eac2c70914dff4ec3e2d8cf
commit + e7c2c86aee62c153c9d41fd414625a81e371946c
blob - f9ea1bcc167543e7059bcf73d3bccf593a96b44c
blob + d9d7d1db10db8a4555aa739721c1b2c4caccd6ae
--- src/ngircd/conn.c
+++ src/ngircd/conn.c
#include "portab.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.148 2005/04/16 20:50:03 fw Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.149 2005/04/23 14:28:44 fw Exp $";
#include "imp.h"
#include <assert.h>
LOCAL fd_set My_Listeners;
LOCAL fd_set My_Sockets;
-LOCAL fd_set My_Connects;
#ifdef TCPWRAP
int allow_severity = LOG_INFO;
/* zu Beginn haben wir keine Verbindungen */
FD_ZERO( &My_Listeners );
FD_ZERO( &My_Sockets );
- FD_ZERO( &My_Connects );
/* Groesster File-Descriptor fuer select() */
Conn_MaxFD = 0;
close( i );
#ifdef DEBUG
Log( LOG_DEBUG, "Listening socket %d closed.", i );
-#endif
- }
- else if( FD_ISSET( i, &My_Connects ))
- {
- close( i );
-#ifdef DEBUG
- Log( LOG_DEBUG, "Connection %d closed during creation (socket %d).", idx, i );
#endif
}
else if( idx < Pool_Size )
/* Sockets mit im Aufbau befindlichen ausgehenden Verbindungen suchen */
for( i = 0; i < Pool_Size; i++ )
{
- if(( My_Connections[i].sock > NONE ) && ( FD_ISSET( My_Connections[i].sock, &My_Connects ))) FD_SET( My_Connections[i].sock, &write_sockets );
+ if ( My_Connections[i].sock > NONE ) {
+ if ( Conn_OPTION_ISSET( &My_Connections[i], CONN_ISCONNECTING )) {
+ FD_SET( My_Connections[i].sock, &write_sockets );
+ }
+ }
+
}
/* von welchen Sockets koennte gelesen werden? */
read_sockets = My_Sockets;
for( i = 0; i < Pool_Size; i++ )
{
- if(( My_Connections[i].sock > NONE ) && ( My_Connections[i].host[0] == '\0' ))
- {
- /* Hier muss noch auf den Resolver Sub-Prozess gewartet werden */
- FD_CLR( My_Connections[i].sock, &read_sockets );
- }
- if(( My_Connections[i].sock > NONE ) && ( FD_ISSET( My_Connections[i].sock, &My_Connects )))
- {
- /* Hier laeuft noch ein asyncrones connect() */
- FD_CLR( My_Connections[i].sock, &read_sockets );
+ if ( My_Connections[i].sock > NONE ) {
+ if ( My_Connections[i].host[0] == '\0' ) {
+ /* wait for completion of Resolver Sub-Process */
+ FD_CLR( My_Connections[i].sock, &read_sockets );
+ continue;
+ }
+
+ if ( Conn_OPTION_ISSET( &My_Connections[i], CONN_ISCONNECTING )) {
+ /* wait for completion of connect() */
+ FD_CLR( My_Connections[i].sock, &read_sockets );
+ continue;
+ }
}
if( My_Connections[i].delaytime > t )
{
}
#ifdef ZLIB
- if( My_Connections[Idx].options & CONN_ZIP )
- {
+ if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
/* Daten komprimieren und in Puffer kopieren */
if( ! Zip_Buffer( Idx, Data, Len )) return false;
}
assert( Idx > NONE );
/* Is this link already shutting down? */
- if( My_Connections[Idx].options & CONN_ISCLOSING )
- {
+ if( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ISCLOSING )) {
/* Conn_Close() has been called recursively for this link;
* probabe reason: Try_Write() failed -- see below. */
#ifdef DEBUG
assert( My_Connections[Idx].sock > NONE );
/* Mark link as "closing" */
- My_Connections[Idx].options |= CONN_ISCLOSING;
+ Conn_OPTION_ADD( &My_Connections[Idx], CONN_ISCLOSING );
if( LogMsg ) txt = LogMsg;
else txt = FwdMsg;
/* Mark socket as invalid: */
FD_CLR( My_Connections[Idx].sock, &My_Sockets );
- FD_CLR( My_Connections[Idx].sock, &My_Connects );
My_Connections[Idx].sock = NONE;
/* If there is still a client, unregister it now */
in_k = (double)My_Connections[Idx].bytes_in / 1024;
out_k = (double)My_Connections[Idx].bytes_out / 1024;
#ifdef ZLIB
- if( My_Connections[Idx].options & CONN_ZIP )
- {
+ if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
in_z_k = (double)My_Connections[Idx].zip.bytes_in / 1024;
out_z_k = (double)My_Connections[Idx].zip.bytes_out / 1024;
in_p = (int)(( in_k * 100 ) / in_z_k );
#ifdef ZLIB
/* Clean up zlib, if link was compressed */
- if( Conn_Options( Idx ) & CONN_ZIP )
- {
+ if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
inflateEnd( &My_Connections[Idx].zip.in );
deflateEnd( &My_Connections[Idx].zip.out );
}
assert( Idx > NONE );
assert( My_Connections[Idx].sock > NONE );
- if( FD_ISSET( My_Connections[Idx].sock, &My_Connects ))
- {
- /* es soll nichts geschrieben werden, sondern ein
- * connect() hat ein Ergebnis geliefert */
+ if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ISCONNECTING )) {
+ /* connect() has finished, check result */
- FD_CLR( My_Connections[Idx].sock, &My_Connects );
+ Conn_OPTION_DEL( &My_Connections[Idx], CONN_ISCONNECTING );
/* Ergebnis des connect() ermitteln */
sock_len = sizeof( err );
}
#ifdef ZLIB
- if( My_Connections[Idx].options & CONN_ZIP )
- {
+ if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
len = recv( My_Connections[Idx].sock, My_Connections[Idx].zip.rbuf + My_Connections[Idx].zip.rdatalen, ( ZREADBUFFER_LEN - My_Connections[Idx].zip.rdatalen ), 0 );
if( len > 0 ) My_Connections[Idx].zip.rdatalen += len;
}
#ifdef ZLIB
/* ggf. noch unkomprimiete Daten weiter entpacken */
- if( My_Connections[Idx].options & CONN_ZIP )
- {
+ if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP ))
if( ! Unzip_Buffer( Idx )) return false;
- }
#endif
if( My_Connections[Idx].rdatalen < 1 ) break;
/* Register new socket */
FD_SET( new_sock, &My_Sockets );
- FD_SET( new_sock, &My_Connects );
+ Conn_OPTION_ADD( &My_Connections[Idx], CONN_ISCONNECTING );
+
if( new_sock > Conn_MaxFD ) Conn_MaxFD = new_sock;
#ifdef DEBUG