Streamline DEBUG_ARRAY, DEBUG_BUFFER, DEBUG_IO, DEBUG_ZIP
Change all #define's to follow the form #define DEBUG_xxx {0|1} to disable (0, default) or enable (1) additional debug messages. And somewhat enhance some DEBUG_BUFFER messages.
This commit is contained in:
parent
b35f8916a5
commit
f547981188
|
@ -14,6 +14,9 @@
|
||||||
* Functions to dynamically allocate arrays.
|
* Functions to dynamically allocate arrays.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Additionan debug messages related to array handling: 0=off / 1=on */
|
||||||
|
#define DEBUG_ARRAY 0
|
||||||
|
|
||||||
#include "array.h"
|
#include "array.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -21,13 +24,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef DEBUG_ARRAY
|
#if DEBUG_ARRAY
|
||||||
# include "log.h"
|
# include "log.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable more Debug messages in alloc / append / memmove code. */
|
|
||||||
/* #define DEBUG_ARRAY */
|
|
||||||
|
|
||||||
#define array_UNUSABLE(x) ( !(x)->mem )
|
#define array_UNUSABLE(x) ( !(x)->mem )
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ array_alloc(array * a, size_t size, size_t pos)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (a->allocated < alloc) {
|
if (a->allocated < alloc) {
|
||||||
#ifdef DEBUG_ARRAY
|
#if DEBUG_ARRAY
|
||||||
Log(LOG_DEBUG, "array_alloc(): changing size from %u to %u bytes.",
|
Log(LOG_DEBUG, "array_alloc(): changing size from %u to %u bytes.",
|
||||||
a->allocated, alloc);
|
a->allocated, alloc);
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,7 +168,7 @@ array_catb(array * dest, const char *src, size_t len)
|
||||||
|
|
||||||
assert(ptr != NULL);
|
assert(ptr != NULL);
|
||||||
|
|
||||||
#ifdef DEBUG_ARRAY
|
#if DEBUG_ARRAY
|
||||||
Log(LOG_DEBUG,
|
Log(LOG_DEBUG,
|
||||||
"array_catb(): appending %u bytes to array (now %u bytes in array).",
|
"array_catb(): appending %u bytes to array (now %u bytes in array).",
|
||||||
len, tmp);
|
len, tmp);
|
||||||
|
@ -248,7 +248,7 @@ void
|
||||||
array_free(array * a)
|
array_free(array * a)
|
||||||
{
|
{
|
||||||
assert(a != NULL);
|
assert(a != NULL);
|
||||||
#ifdef DEBUG_ARRAY
|
#if DEBUG_ARRAY
|
||||||
Log(LOG_DEBUG,
|
Log(LOG_DEBUG,
|
||||||
"array_free(): %u bytes free'd (%u bytes still used at time of free()).",
|
"array_free(): %u bytes free'd (%u bytes still used at time of free()).",
|
||||||
a->allocated, a->used);
|
a->allocated, a->used);
|
||||||
|
@ -314,7 +314,7 @@ array_moveleft(array * a, size_t membersize, size_t pos)
|
||||||
if (!bytepos)
|
if (!bytepos)
|
||||||
return; /* nothing to do */
|
return; /* nothing to do */
|
||||||
|
|
||||||
#ifdef DEBUG_ARRAY
|
#if DEBUG_ARRAY
|
||||||
Log(LOG_DEBUG,
|
Log(LOG_DEBUG,
|
||||||
"array_moveleft(): %u bytes used in array, starting at position %u.",
|
"array_moveleft(): %u bytes used in array, starting at position %u.",
|
||||||
a->used, bytepos);
|
a->used, bytepos);
|
||||||
|
|
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define CONN_MODULE
|
||||||
|
|
||||||
#include "portab.h"
|
#include "portab.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,13 +18,11 @@
|
||||||
* Connection compression using ZLIB
|
* Connection compression using ZLIB
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CONN_MODULE
|
/* Additionan debug messages related to ZIP compression: 0=off / 1=on */
|
||||||
|
#define DEBUG_ZIP 0
|
||||||
|
|
||||||
#ifdef ZLIB
|
#ifdef ZLIB
|
||||||
|
|
||||||
/* enable more zlib related debug messages: */
|
|
||||||
/* #define DEBUG_ZLIB */
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
@ -141,7 +141,7 @@ Zip_Flush( CONN_ID Idx )
|
||||||
out->next_out = zipbuf;
|
out->next_out = zipbuf;
|
||||||
out->avail_out = (uInt)sizeof zipbuf;
|
out->avail_out = (uInt)sizeof zipbuf;
|
||||||
|
|
||||||
#ifdef DEBUG_ZIP
|
#if DEBUG_ZIP
|
||||||
Log(LOG_DEBUG, "out->avail_in %d, out->avail_out %d",
|
Log(LOG_DEBUG, "out->avail_in %d, out->avail_out %d",
|
||||||
out->avail_in, out->avail_out);
|
out->avail_in, out->avail_out);
|
||||||
#endif
|
#endif
|
||||||
|
@ -164,7 +164,7 @@ Zip_Flush( CONN_ID Idx )
|
||||||
assert(out->avail_out <= WRITEBUFFER_SLINK_LEN);
|
assert(out->avail_out <= WRITEBUFFER_SLINK_LEN);
|
||||||
|
|
||||||
zipbuf_used = WRITEBUFFER_SLINK_LEN - out->avail_out;
|
zipbuf_used = WRITEBUFFER_SLINK_LEN - out->avail_out;
|
||||||
#ifdef DEBUG_ZIP
|
#if DEBUG_ZIP
|
||||||
Log(LOG_DEBUG, "zipbuf_used: %d", zipbuf_used);
|
Log(LOG_DEBUG, "zipbuf_used: %d", zipbuf_used);
|
||||||
#endif
|
#endif
|
||||||
if (!array_catb(&My_Connections[Idx].wbuf,
|
if (!array_catb(&My_Connections[Idx].wbuf,
|
||||||
|
@ -216,7 +216,7 @@ Unzip_Buffer( CONN_ID Idx )
|
||||||
in->next_out = unzipbuf;
|
in->next_out = unzipbuf;
|
||||||
in->avail_out = (uInt)sizeof unzipbuf;
|
in->avail_out = (uInt)sizeof unzipbuf;
|
||||||
|
|
||||||
#ifdef DEBUG_ZIP
|
#if DEBUG_ZIP
|
||||||
Log(LOG_DEBUG, "in->avail_in %d, in->avail_out %d",
|
Log(LOG_DEBUG, "in->avail_in %d, in->avail_out %d",
|
||||||
in->avail_in, in->avail_out);
|
in->avail_in, in->avail_out);
|
||||||
#endif
|
#endif
|
||||||
|
@ -231,7 +231,7 @@ Unzip_Buffer( CONN_ID Idx )
|
||||||
assert(z_rdatalen >= in->avail_in);
|
assert(z_rdatalen >= in->avail_in);
|
||||||
in_len = z_rdatalen - in->avail_in;
|
in_len = z_rdatalen - in->avail_in;
|
||||||
unzipbuf_used = READBUFFER_LEN - in->avail_out;
|
unzipbuf_used = READBUFFER_LEN - in->avail_out;
|
||||||
#ifdef DEBUG_ZIP
|
#if DEBUG_ZIP
|
||||||
Log(LOG_DEBUG, "unzipbuf_used: %d - %d = %d", READBUFFER_LEN,
|
Log(LOG_DEBUG, "unzipbuf_used: %d - %d = %d", READBUFFER_LEN,
|
||||||
in->avail_out, unzipbuf_used);
|
in->avail_out, unzipbuf_used);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
* 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"
|
||||||
|
@ -20,6 +18,9 @@
|
||||||
* Connection management
|
* Connection management
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Additionan debug messages related to buffer handling: 0=off / 1=on */
|
||||||
|
#define DEBUG_BUFFER 0
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#ifdef PROTOTYPES
|
#ifdef PROTOTYPES
|
||||||
# include <stdarg.h>
|
# include <stdarg.h>
|
||||||
|
@ -1265,7 +1266,7 @@ Handle_Write( CONN_ID Idx )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_BUFFER
|
#if 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);
|
||||||
|
@ -1798,10 +1799,6 @@ 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.",
|
|
||||||
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)) {
|
||||||
|
@ -1824,6 +1821,12 @@ Handle_Buffer(CONN_ID Idx)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#if DEBUG_BUFFER
|
||||||
|
LogDebug("Connection %d: Processed %ld commands (max=%ld), %ld bytes. %ld bytes left in read buffer.",
|
||||||
|
Idx, i, maxcmd, len_processed,
|
||||||
|
array_bytes(&My_Connections[Idx].rbuf));
|
||||||
|
#endif
|
||||||
|
|
||||||
return len_processed;
|
return len_processed;
|
||||||
} /* Handle_Buffer */
|
} /* Handle_Buffer */
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
* I/O abstraction interface.
|
* I/O abstraction interface.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Extra debug messages in event add/delete/callback code: 0=off / 1=on */
|
||||||
|
#define DEBUG_IO 0
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -28,9 +31,6 @@
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
/* Enables extra debug messages in event add/delete/callback code. */
|
|
||||||
/* #define DEBUG_IO */
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#ifdef PROTOTYPES
|
#ifdef PROTOTYPES
|
||||||
void (*callback)(int, short);
|
void (*callback)(int, short);
|
||||||
|
@ -144,7 +144,7 @@ static array io_events;
|
||||||
|
|
||||||
static void io_docallback PARAMS((int fd, short what));
|
static void io_docallback PARAMS((int fd, short what));
|
||||||
|
|
||||||
#ifdef DEBUG_IO
|
#if DEBUG_IO
|
||||||
static void
|
static void
|
||||||
io_debug(const char *s, int fd, int what)
|
io_debug(const char *s, int fd, int what)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue