commit - 0701afedee21b33e22f663ca265a7ca0f4c43974
commit + 66060dbce9bba48d2cd6f2e4feac1bf66752800c
blob - f6a3e7254e4f675554081e9848606324e3f210bd
blob + 1bf90137da270a90d46bcb7f31458261ad4cf0e8
--- src/ngircd/conn.c
+++ src/ngircd/conn.c
#include "portab.h"
#include "io.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.188 2006/02/08 15:20:21 fw Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.189 2006/02/08 17:33:28 fw Exp $";
#include "imp.h"
#include <assert.h>
CLIENT *c;
CONN_ID idx = Socket2Index( sock );
if (idx <= NONE) {
-#ifdef DEBUG
- Log(LOG_DEBUG, "cb_connserver wants to write on unknown socket?!");
-#endif
+ LogDebug("cb_connserver wants to write on unknown socket?!");
io_close(sock);
return;
}
Log( LOG_EMERG, "Can't allocate memory! [Conn_Init]" );
exit( 1 );
}
-#ifdef DEBUG
- Log( LOG_DEBUG, "Allocated connection pool for %d items (%ld bytes).", Pool_Size, sizeof( CONNECTION ) * Pool_Size );
-#endif
+ LogDebug("Allocated connection pool for %d items (%ld bytes).", Pool_Size,
+ sizeof( CONNECTION ) * Pool_Size );
array_free( &My_Listeners );
CONN_ID idx;
-#ifdef DEBUG
- Log( LOG_DEBUG, "Shutting down all connections ..." );
-#endif
+ LogDebug("Shutting down all connections ..." );
Conn_ExitListeners();
assert(fd);
assert(*fd >= 0);
io_close(*fd);
-#ifdef DEBUG
- Log( LOG_DEBUG, "Listening socket %d closed.", *fd );
-#endif
+ LogDebug("Listening socket %d closed.", *fd );
fd++;
}
array_free(&My_Listeners);
* "Handler-Durchlauf" kann es passieren, dass dem nicht mehr so
* ist, wenn einer von mehreren Conn_Write()'s fehlgeschlagen ist.
* In diesem Fall wird hier einfach ein Fehler geliefert. */
- if( My_Connections[Idx].sock <= NONE )
- {
-#ifdef DEBUG
- Log( LOG_DEBUG, "Skipped write on closed socket (connection %d).", Idx );
-#endif
+ if( My_Connections[Idx].sock <= NONE ) {
+ LogDebug("Skipped write on closed socket (connection %d).", Idx );
return false;
}
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. */
-#ifdef DEBUG
- Log( LOG_DEBUG, "Recursive request to close connection: %d", Idx );
-#endif
+ LogDebug("Recursive request to close connection: %d", Idx );
return;
}
Init_Conn_Struct( Idx );
#ifdef DEBUG
- Log( LOG_DEBUG, "Shutdown of connection %d completed.", Idx );
+ LogDebug("Shutdown of connection %d completed.", Idx );
#endif
} /* Conn_Close */
assert( Idx > NONE );
if ( My_Connections[Idx].sock < 0 ) {
-#ifdef DEBUG
- Log(LOG_DEBUG,
- "Handle_Write() on closed socket, connection %d", Idx);
-#endif
+ LogDebug("Handle_Write() on closed socket, connection %d", Idx);
return false;
}
assert( My_Connections[Idx].sock > NONE );
-#ifdef DEBUG
- Log(LOG_DEBUG, "Handle_Write() called for connection %d ...", Idx);
-#endif
+ LogDebug("Handle_Write() called for connection %d ...", Idx);
wdatalen = array_bytes(&My_Connections[Idx].wbuf );
#ifdef ZLIB
return -1;
}
-#ifdef DEBUG
- Log( LOG_DEBUG, "Allocated new connection pool for %ld items (%ld bytes). [realloc()]", new_size, sizeof( CONNECTION ) * new_size );
-#endif
+ LogDebug("Allocated new connection pool for %ld items (%ld bytes). [realloc()]",
+ new_size, sizeof( CONNECTION ) * new_size );
/* Adjust pointer to new block */
My_Connections = (CONNECTION *)ptr;
return -1;
}
- Log( LOG_INFO, "Accepted connection %d from %s:%d on socket %d.", new_sock,
+ LogDebug( "Accepted connection %d from %s:%d on socket %d.", new_sock,
inet_ntoa( new_addr.sin_addr ), ntohs( new_addr.sin_port), Sock );
/* Hostnamen ermitteln */
if( Sock >= Pool_Size || My_Connections[Sock].sock != Sock ) {
/* die Connection wurde vermutlich (wegen eines
* Fehlers) bereits wieder abgebaut ... */
-#ifdef DEBUG
- Log( LOG_DEBUG, "Socket2Index: can't get connection for socket %d!", Sock );
-#endif
+
+ LogDebug( "Socket2Index: can't get connection for socket %d!", Sock );
return NONE;
}
return Sock;
result = true;
array_moveleft(&My_Connections[Idx].rbuf, 1, len);
-#ifdef DEBUG
- Log(LOG_DEBUG,
- "Connection %d: %d bytes left in read buffer.",
- Idx, array_bytes(&My_Connections[Idx].rbuf));
-#endif
+
+ LogDebug("Connection %d: %d bytes left in read buffer.", Idx,
+ array_bytes(&My_Connections[Idx].rbuf));
#ifdef ZLIB
if(( ! old_z ) && ( My_Connections[Idx].options & CONN_ZIP ) &&
( array_bytes(&My_Connections[Idx].rbuf) > 0 ))
return false;
array_trunc(&My_Connections[Idx].rbuf);
-#ifdef DEBUG
- Log( LOG_DEBUG, "Moved already received data (%u bytes) to uncompression buffer.",
+
+ LogDebug("Moved already received data (%u bytes) to uncompression buffer.",
array_bytes(&My_Connections[Idx].zip.rbuf));
-#endif /* DEBUG */
}
#endif /* ZLIB */
}
/* we already sent a ping */
if( My_Connections[i].lastping < time( NULL ) - Conf_PongTimeout ) {
/* Timeout */
-#ifdef DEBUG
- Log( LOG_DEBUG, "Connection %d: Ping timeout: %d seconds.", i, Conf_PongTimeout );
-#endif
+
+ LogDebug("Connection %d: Ping timeout: %d seconds.", i,
+ Conf_PongTimeout );
Conn_Close( i, NULL, "Ping timeout", true );
}
}
else if( My_Connections[i].lastdata < time( NULL ) - Conf_PingTimeout ) {
/* we need to sent a PING */
-#ifdef DEBUG
- Log( LOG_DEBUG, "Connection %d: sending PING ...", i );
-#endif
+ LogDebug("Connection %d: sending PING ...", i );
My_Connections[i].lastping = time( NULL );
Conn_WriteStr( i, "PING :%s", Client_ID( Client_ThisServer( )));
}
if (My_Connections[i].lastdata <
time(NULL) - Conf_PongTimeout) {
-#ifdef DEBUG
- Log(LOG_DEBUG,
- "Unregistered connection %d timed out ...",
- i);
-#endif
+ LogDebug("Unregistered connection %d timed out ...", i);
Conn_Close(i, NULL, "Timeout", false);
}
}
Conf_Server[Server].conn_id = NONE;
}
-#ifdef DEBUG
- Log( LOG_DEBUG, "Registered new connection %d on socket %d.",
- new_sock, My_Connections[new_sock].sock );
-#endif
+ LogDebug("Registered new connection %d on socket %d.", new_sock, My_Connections[new_sock].sock );
Conn_OPTION_ADD( &My_Connections[new_sock], CONN_ISCONNECTING );
} /* New_Server */
/* Set type of service (TOS) */
#if defined(IP_TOS) && defined(IPTOS_LOWDELAY)
value = IPTOS_LOWDELAY;
-#ifdef DEBUG
- Log( LOG_DEBUG, "Setting option IP_TOS on socket %d to IPTOS_LOWDELAY (%d).", Sock, value );
-#endif
+
+ LogDebug("Setting option IP_TOS on socket %d to IPTOS_LOWDELAY (%d).", Sock, value );
if( setsockopt( Sock, SOL_IP, IP_TOS, &value, (socklen_t)sizeof( value )) != 0 )
{
Log( LOG_ERR, "Can't set socket option IP_TOS: %s!", strerror( errno ));
size_t len;
char readbuf[HOST_LEN + 1];
-#ifdef DEBUG
- Log( LOG_DEBUG, "Resolver: Got forward lookup callback on fd %d, events %d", fd, events);
-#endif
+ LogDebug("Resolver: Got forward lookup callback on fd %d, events %d", fd, events);
+
for (i=0; i < MAX_SERVERS; i++) {
if (Resolve_Getfd(&Conf_Server[i].res_stat) == fd )
break;
if( i >= MAX_SERVERS) {
/* Ops, no matching server found?! */
io_close( fd );
-#ifdef DEBUG
- Log( LOG_DEBUG, "Resolver: Got Forward Lookup callback for unknown server!?" );
-#endif
+ LogDebug("Resolver: Got Forward Lookup callback for unknown server!?" );
return;
}
return;
readbuf[len] = '\0';
-#ifdef DEBUG
- Log( LOG_DEBUG, "Got result from resolver: \"%s\" (%u bytes read).", readbuf, len);
-#endif
+ LogDebug("Got result from resolver: \"%s\" (%u bytes read).", readbuf, len);
strlcpy( Conf_Server[i].ip, readbuf, sizeof( Conf_Server[i].ip ));
/* connect() */
char readbuf[HOST_LEN + 1];
#endif
-#ifdef DEBUG
- Log( LOG_DEBUG, "Resolver: Got callback on fd %d, events %d", r_fd, events );
-#endif
+ LogDebug("Resolver: Got callback on fd %d, events %d", r_fd, events );
/* Search associated connection ... */
for( i = 0; i < Pool_Size; i++ ) {
/* Ops, none found? Probably the connection has already
* been closed!? We'll ignore that ... */
io_close( r_fd );
-#ifdef DEBUG
- Log( LOG_DEBUG, "Resolver: Got callback for unknown connection!?" );
-#endif
+ LogDebug("Resolver: Got callback for unknown connection!?");
return;
}
}
*identptr = '\0';
-#ifdef DEBUG
- Log( LOG_DEBUG, "Got result from resolver: \"%s\" (%u bytes read).", readbuf, len);
-#endif
+
+ LogDebug( "Got result from resolver: \"%s\" (%u bytes read).", readbuf, len);
+
/* Okay, we got a complete result: this is a host name for outgoing
* connections and a host name and IDENT user name (if enabled) for
* incoming connections.*/
blob - a29c40154d524113d46f4555090609e7248abdb2
blob + 396555ee73555e84fb58e4d85b7a779b450ca3b9
--- src/ngircd/log.c
+++ src/ngircd/log.c
#include "portab.h"
-static char UNUSED id[] = "$Id: log.c,v 1.59 2005/08/29 10:58:00 alex Exp $";
+static char UNUSED id[] = "$Id: log.c,v 1.60 2006/02/08 17:33:28 fw Exp $";
#include "imp.h"
#include <assert.h>
closelog( );
#endif
} /* Log_Exit */
+
+
+# ifdef PROTOTYPES
+GLOBAL void
+LogDebug( const char *Format, ... )
+# else
+GLOBAL void
+LogDebug( Format, va_alist )
+const char *Format;
+va_dcl
+# endif
+#ifdef DEBUG
+{
+ char msg[MAX_LOG_MSG_LEN];
+ va_list ap;
+ if (!NGIRCd_Debug) return;
+#ifdef PROTOTYPES
+ va_start( ap, Format );
+#else
+ va_start( ap );
+#endif
+ vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
+ va_end( ap );
+ Log(LOG_DEBUG, "%s", msg);
+}
+#else
+{ /* do nothing */ }
+#endif /* DEBUG */
+
#ifdef PROTOTYPES
GLOBAL void
Log( int Level, const char *Format, ... )
#endif
{
/* Eintrag in Logfile(s) schreiben */
-
char msg[MAX_LOG_MSG_LEN];
bool snotice;
va_list ap;
blob - a49375f4f51c089678424af3a26d94885cd92168
blob + 00a8a0f7276d62f252e04fe126c4d35b4e0d9652
--- src/ngircd/log.h
+++ src/ngircd/log.h
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
- * $Id: log.h,v 1.18 2005/06/24 19:55:10 alex Exp $
+ * $Id: log.h,v 1.19 2006/02/08 17:33:28 fw Exp $
*
* Logging functions (header)
*/
GLOBAL void Log_Exit PARAMS(( void ));
GLOBAL void Log PARAMS(( int Level, const char *Format, ... ));
+GLOBAL void LogDebug PARAMS(( const char *Format, ... ));
GLOBAL void Log_Init_Resolver PARAMS(( void ));
GLOBAL void Log_Exit_Resolver PARAMS(( void ));