Update suricata to use FlowReference/FlowDeReference for the ones left out

from last update.
pull/133/merge
Anoop Saldanha 13 years ago committed by Victor Julien
parent bb14cf899b
commit 67981d1c5c

@ -627,6 +627,16 @@ typedef struct DecodeThreadVars_
#endif #endif
/* \todo there is another copy of this same macro inside flow-util.h. The
* reason we have this duplicate is because we couldn't solve endless
* header files cross-reference. */
#define FlowDeReference(src_f_ptr) do { \
if (*(src_f_ptr) != NULL) { \
FlowDecrUsecnt(*(src_f_ptr)); \
*(src_f_ptr) = NULL; \
} \
} while (0)
/** /**
* \brief Recycle a packet structure for reuse. * \brief Recycle a packet structure for reuse.
* \todo the mutex destroy & init is necessary because of the memset, reconsider * \todo the mutex destroy & init is necessary because of the memset, reconsider
@ -641,7 +651,7 @@ typedef struct DecodeThreadVars_
(p)->flags = 0; \ (p)->flags = 0; \
(p)->flowflags = 0; \ (p)->flowflags = 0; \
(p)->pkt_src = 0; \ (p)->pkt_src = 0; \
(p)->flow = NULL; \ FlowDeReference(&((p)->flow)); \
(p)->ts.tv_sec = 0; \ (p)->ts.tv_sec = 0; \
(p)->ts.tv_usec = 0; \ (p)->ts.tv_usec = 0; \
(p)->datalink = 0; \ (p)->datalink = 0; \

@ -134,6 +134,9 @@
} \ } \
} while (0) } while (0)
/* \todo there is another copy of this same macro inside decode.h. The reason
* we have this duplicate is because we couldn't solve endless header
* files cross-reference. */
#define FlowDeReference(src_f_ptr) do { \ #define FlowDeReference(src_f_ptr) do { \
if (*(src_f_ptr) != NULL) { \ if (*(src_f_ptr) != NULL) { \
FlowDecrUsecnt(*(src_f_ptr)); \ FlowDecrUsecnt(*(src_f_ptr)); \

@ -190,7 +190,7 @@ void StreamTcpSessionClear(void *ssnptr)
SCLogDebug("returning smsg %p to pool", smsg); SCLogDebug("returning smsg %p to pool", smsg);
smsg->next = NULL; smsg->next = NULL;
smsg->prev = NULL; smsg->prev = NULL;
smsg->flow = NULL; FlowDeReference(&smsg->flow);
StreamMsgReturnToPool(smsg); StreamMsgReturnToPool(smsg);
smsg = smsg_next; smsg = smsg_next;
} }
@ -202,7 +202,7 @@ void StreamTcpSessionClear(void *ssnptr)
SCLogDebug("returning smsg %p to pool", smsg); SCLogDebug("returning smsg %p to pool", smsg);
smsg->next = NULL; smsg->next = NULL;
smsg->prev = NULL; smsg->prev = NULL;
smsg->flow = NULL; FlowDeReference(&smsg->flow);
StreamMsgReturnToPool(smsg); StreamMsgReturnToPool(smsg);
smsg = smsg_next; smsg = smsg_next;
} }
@ -289,7 +289,7 @@ void StreamTcpSessionPoolCleanup(void *s)
SCLogDebug("returning smsg %p to pool", smsg); SCLogDebug("returning smsg %p to pool", smsg);
smsg->next = NULL; smsg->next = NULL;
smsg->prev = NULL; smsg->prev = NULL;
smsg->flow = NULL; FlowDeReference(&smsg->flow);
StreamMsgReturnToPool(smsg); StreamMsgReturnToPool(smsg);
smsg = smsg_next; smsg = smsg_next;
} }
@ -301,7 +301,7 @@ void StreamTcpSessionPoolCleanup(void *s)
SCLogDebug("returning smsg %p to pool", smsg); SCLogDebug("returning smsg %p to pool", smsg);
smsg->next = NULL; smsg->next = NULL;
smsg->prev = NULL; smsg->prev = NULL;
smsg->flow = NULL; FlowDeReference(&smsg->flow);
StreamMsgReturnToPool(smsg); StreamMsgReturnToPool(smsg);
smsg = smsg_next; smsg = smsg_next;
} }

@ -30,6 +30,7 @@
#include "util-pool.h" #include "util-pool.h"
#include "util-debug.h" #include "util-debug.h"
#include "stream-tcp.h" #include "stream-tcp.h"
#include "flow-util.h"
#ifdef DEBUG #ifdef DEBUG
static SCMutex stream_pool_memuse_mutex; static SCMutex stream_pool_memuse_mutex;
@ -215,7 +216,7 @@ void StreamMsgReturnListToPool(void *list) {
SCLogDebug("returning smsg %p to pool", smsg); SCLogDebug("returning smsg %p to pool", smsg);
smsg->next = NULL; smsg->next = NULL;
smsg->prev = NULL; smsg->prev = NULL;
smsg->flow = NULL; FlowDeReference(&smsg->flow);
StreamMsgReturnToPool(smsg); StreamMsgReturnToPool(smsg);
smsg = smsg_next; smsg = smsg_next;
} }

@ -36,6 +36,7 @@
#include "threads.h" #include "threads.h"
#include "threadvars.h" #include "threadvars.h"
#include "flow.h" #include "flow.h"
#include "flow-util.h"
#include "stream.h" #include "stream.h"
#include "stream-tcp-reassemble.h" #include "stream-tcp-reassemble.h"
@ -242,13 +243,13 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
SCLogDebug("tunnel stuff done, move on (proot %d)", proot); SCLogDebug("tunnel stuff done, move on (proot %d)", proot);
} }
FlowDecrUsecnt(p->flow); FlowDeReference(&p->flow);
/* we're done with the tunnel root now as well */ /* we're done with the tunnel root now as well */
if (proot == 1) { if (proot == 1) {
SCLogDebug("getting rid of root pkt... alloc'd %s", p->root->flags & PKT_ALLOC ? "true" : "false"); SCLogDebug("getting rid of root pkt... alloc'd %s", p->root->flags & PKT_ALLOC ? "true" : "false");
FlowDecrUsecnt(p->root->flow); FlowDeReference(&p->root->flow);
/* if p->root uses extended data, free them */ /* if p->root uses extended data, free them */
if (p->root->ReleaseData) { if (p->root->ReleaseData) {
if (p->root->ReleaseData(t, p->root) == TM_ECODE_FAILED) { if (p->root->ReleaseData(t, p->root) == TM_ECODE_FAILED) {

Loading…
Cancel
Save