Introduce DEBUG_BUFFER, rework some debug messages

DEBUG_BUFFER is off by default and therefore disables these messages:
 - "Handle_Write() called for connection XX, YY bytes pending ..."
 - "Connection XX: ZZ bytes left in read buffer."
This commit is contained in:
Alexander Barton 2011-08-23 12:28:04 +02:00
parent d3036c74e9
commit 1361b3742d
1 changed files with 11 additions and 2 deletions

View File

@ -9,6 +9,8 @@
* Please read the file COPYING, README and AUTHORS for more information. * Please read the file COPYING, README and AUTHORS for more information.
*/ */
#undef DEBUG_BUFFER
#define CONN_MODULE #define CONN_MODULE
#include "portab.h" #include "portab.h"
@ -1255,9 +1257,11 @@ Handle_Write( CONN_ID Idx )
return true; return true;
} }
#ifdef DEBUG_BUFFER
LogDebug LogDebug
("Handle_Write() called for connection %d, %ld bytes pending ...", ("Handle_Write() called for connection %d, %ld bytes pending ...",
Idx, wdatalen); Idx, wdatalen);
#endif
#ifdef SSL_SUPPORT #ifdef SSL_SUPPORT
if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_SSL )) { if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_SSL )) {
@ -1326,6 +1330,8 @@ New_Connection(int Sock)
assert(Sock > NONE); assert(Sock > NONE);
LogDebug("Accepting new connection on socket %d ...", Sock);
new_sock_len = (int)sizeof(new_addr); new_sock_len = (int)sizeof(new_addr);
new_sock = accept(Sock, (struct sockaddr *)&new_addr, new_sock = accept(Sock, (struct sockaddr *)&new_addr,
(socklen_t *)&new_sock_len); (socklen_t *)&new_sock_len);
@ -1753,8 +1759,10 @@ Handle_Buffer(CONN_ID Idx)
return 0; /* error -> connection has been closed */ return 0; /* error -> connection has been closed */
array_moveleft(&My_Connections[Idx].rbuf, 1, len); array_moveleft(&My_Connections[Idx].rbuf, 1, len);
#ifdef DEBUG_BUFFER
LogDebug("Connection %d: %d bytes left in read buffer.", LogDebug("Connection %d: %d bytes left in read buffer.",
Idx, array_bytes(&My_Connections[Idx].rbuf)); Idx, array_bytes(&My_Connections[Idx].rbuf));
#endif
#ifdef ZLIB #ifdef ZLIB
if ((!old_z) && (My_Connections[Idx].options & CONN_ZIP) && if ((!old_z) && (My_Connections[Idx].options & CONN_ZIP) &&
(array_bytes(&My_Connections[Idx].rbuf) > 0)) { (array_bytes(&My_Connections[Idx].rbuf) > 0)) {
@ -2051,13 +2059,14 @@ Init_Socket( int Sock )
/* Set type of service (TOS) */ /* Set type of service (TOS) */
#if defined(IPPROTO_IP) && defined(IPTOS_LOWDELAY) #if defined(IPPROTO_IP) && defined(IPTOS_LOWDELAY)
value = IPTOS_LOWDELAY; value = IPTOS_LOWDELAY;
LogDebug("Setting IP_TOS on socket %d to IPTOS_LOWDELAY.", Sock);
if (setsockopt(Sock, IPPROTO_IP, IP_TOS, &value, if (setsockopt(Sock, IPPROTO_IP, IP_TOS, &value,
(socklen_t) sizeof(value))) { (socklen_t) sizeof(value))) {
LogDebug("Can't set socket option IP_TOS: %s!", LogDebug("Can't set socket option IP_TOS: %s!",
strerror(errno)); strerror(errno));
/* ignore this error */ /* ignore this error */
} } else
LogDebug("IP_TOS on socket %d has been set to IPTOS_LOWDELAY.",
Sock);
#endif #endif
return true; return true;