]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Update suricata to use FlowReference/FlowDeReference for the ones left out
authorAnoop Saldanha <anoopsaldanha@gmail.com>
Fri, 5 Oct 2012 09:37:27 +0000 (15:07 +0530)
committerVictor Julien <victor@inliniac.net>
Wed, 10 Oct 2012 12:48:36 +0000 (14:48 +0200)
from last update.

src/decode.h
src/flow-util.h
src/stream-tcp.c
src/stream.c
src/tmqh-packetpool.c

index 50036192ba87a3f4fba236f2e60021dcceff7d49..4b097a2123c3ed44be507e88d9f9376b6f3cc2db 100644 (file)
@@ -627,6 +627,16 @@ typedef struct DecodeThreadVars_
 #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.
  *  \todo the mutex destroy & init is necessary because of the memset, reconsider
@@ -641,7 +651,7 @@ typedef struct DecodeThreadVars_
         (p)->flags = 0;                         \
         (p)->flowflags = 0;                     \
         (p)->pkt_src = 0;                       \
-        (p)->flow = NULL;                       \
+        FlowDeReference(&((p)->flow));          \
         (p)->ts.tv_sec = 0;                     \
         (p)->ts.tv_usec = 0;                    \
         (p)->datalink = 0;                      \
index 21768bd3278fc942fb720d96c8ab42138ed4cf20..c6e15b3e21408b2c9d3cb89e033171fdc423888c 100644 (file)
         }                                           \
     } 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 {               \
         if (*(src_f_ptr) != NULL) {                   \
             FlowDecrUsecnt(*(src_f_ptr));             \
index dbc6ab85c5e6fb161118ebb83b121a6b4e6b3244..8c9d6e5b41fcc40d4d02cb1d3de1c741d723acb1 100644 (file)
@@ -190,7 +190,7 @@ void StreamTcpSessionClear(void *ssnptr)
         SCLogDebug("returning smsg %p to pool", smsg);
         smsg->next = NULL;
         smsg->prev = NULL;
-        smsg->flow = NULL;
+        FlowDeReference(&smsg->flow);
         StreamMsgReturnToPool(smsg);
         smsg = smsg_next;
     }
@@ -202,7 +202,7 @@ void StreamTcpSessionClear(void *ssnptr)
         SCLogDebug("returning smsg %p to pool", smsg);
         smsg->next = NULL;
         smsg->prev = NULL;
-        smsg->flow = NULL;
+        FlowDeReference(&smsg->flow);
         StreamMsgReturnToPool(smsg);
         smsg = smsg_next;
     }
@@ -289,7 +289,7 @@ void StreamTcpSessionPoolCleanup(void *s)
         SCLogDebug("returning smsg %p to pool", smsg);
         smsg->next = NULL;
         smsg->prev = NULL;
-        smsg->flow = NULL;
+        FlowDeReference(&smsg->flow);
         StreamMsgReturnToPool(smsg);
         smsg = smsg_next;
     }
@@ -301,7 +301,7 @@ void StreamTcpSessionPoolCleanup(void *s)
         SCLogDebug("returning smsg %p to pool", smsg);
         smsg->next = NULL;
         smsg->prev = NULL;
-        smsg->flow = NULL;
+        FlowDeReference(&smsg->flow);
         StreamMsgReturnToPool(smsg);
         smsg = smsg_next;
     }
index d6f8a9a79cfa6d073f00fce90209e9dfd02e5345..6bb43dfea7936da0f97f51c2e8f5b80647e7b21e 100644 (file)
@@ -30,6 +30,7 @@
 #include "util-pool.h"
 #include "util-debug.h"
 #include "stream-tcp.h"
+#include "flow-util.h"
 
 #ifdef DEBUG
 static SCMutex stream_pool_memuse_mutex;
@@ -215,7 +216,7 @@ void StreamMsgReturnListToPool(void *list) {
         SCLogDebug("returning smsg %p to pool", smsg);
         smsg->next = NULL;
         smsg->prev = NULL;
-        smsg->flow = NULL;
+        FlowDeReference(&smsg->flow);
         StreamMsgReturnToPool(smsg);
         smsg = smsg_next;
     }
index 84a7f6a02113347c50ea74331e77da682fd385e5..9310f880755268311dfa3a86557058594d9844aa 100644 (file)
@@ -36,6 +36,7 @@
 #include "threads.h"
 #include "threadvars.h"
 #include "flow.h"
+#include "flow-util.h"
 
 #include "stream.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);
     }
 
-    FlowDecrUsecnt(p->flow);
+    FlowDeReference(&p->flow);
 
     /* we're done with the tunnel root now as well */
     if (proot == 1) {
         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->ReleaseData) {
             if (p->root->ReleaseData(t, p->root) == TM_ECODE_FAILED) {