From: Victor Julien Date: Thu, 15 Mar 2012 11:04:26 +0000 (+0100) Subject: Make sure stream debug code is only used in debug mode. X-Git-Tag: suricata-1.3beta1~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff8755af5c1b89a7f17b2150522bc9523d4c6a1c;p=thirdparty%2Fsuricata.git Make sure stream debug code is only used in debug mode. --- diff --git a/src/stream.c b/src/stream.c index d7f01f7a7c..bda9ad3c4f 100644 --- a/src/stream.c +++ b/src/stream.c @@ -31,9 +31,11 @@ #include "util-debug.h" #include "stream-tcp.h" +#ifdef DEBUG static SCMutex stream_pool_memuse_mutex; static uint64_t stream_pool_memuse = 0; static uint64_t stream_pool_memcnt = 0; +#endif /* per queue setting */ static uint16_t toserver_min_chunk_len = 2560; @@ -49,10 +51,12 @@ void *StreamMsgAlloc(void *null) { memset(s, 0, sizeof(StreamMsg)); +#ifdef DEBUG SCMutexLock(&stream_pool_memuse_mutex); stream_pool_memuse += sizeof(StreamMsg); stream_pool_memcnt ++; SCMutexUnlock(&stream_pool_memuse_mutex); +#endif return s; } @@ -151,8 +155,9 @@ void StreamMsgPutInQueue(StreamMsgQueue *q, StreamMsg *s) } void StreamMsgQueuesInit(void) { +#ifdef DEBUG SCMutexInit(&stream_pool_memuse_mutex, NULL); - +#endif SCMutexLock(&stream_msg_pool_mutex); stream_msg_pool = PoolInit(0,250,StreamMsgAlloc,NULL,StreamMsgFree); if (stream_msg_pool == NULL) @@ -165,10 +170,12 @@ void StreamMsgQueuesDeinit(char quiet) { PoolFree(stream_msg_pool); SCMutexUnlock(&stream_msg_pool_mutex); +#ifdef DEBUG SCMutexDestroy(&stream_pool_memuse_mutex); if (quiet == FALSE) SCLogDebug("stream_pool_memuse %"PRIu64", stream_pool_memcnt %"PRIu64"", stream_pool_memuse, stream_pool_memcnt); +#endif } /** \brief alloc a stream msg queue