]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Host: use global free storage function
authorEric Leblond <eric@regit.org>
Mon, 18 Mar 2013 10:05:52 +0000 (11:05 +0100)
committerVictor Julien <victor@inliniac.net>
Sun, 28 Jul 2013 21:41:11 +0000 (23:41 +0200)
This patch is here to avoid that all modules using a local storage
have to update host code to add their free function. It modifies
previous behavior by calling HostFreeStorage in any case.

src/detect-engine-tag.c
src/detect-engine-tag.h
src/detect-engine-threshold.c
src/detect-engine-threshold.h
src/host.c

index 8979d940a0a15509e786e87bb3942aeb702a3f0e..59db17d4e2142782be14f5e153f6a53b23123b29 100644 (file)
@@ -71,14 +71,6 @@ int TagHostHasTag(Host *host) {
     return HostGetStorageById(host, tag_id) ? 1 : 0;
 }
 
-void DetectTagForceCleanup(Host *host) {
-    void *tag = HostGetStorageById(host, tag_id);
-    if (tag != NULL) {
-        DetectTagDataListFree(tag);
-        HostSetStorageById(host, tag_id, NULL);
-    }
-}
-
 static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd) {
     DetectTagDataEntry *tde = SCMalloc(sizeof(DetectTagDataEntry));
     if (unlikely(tde == NULL)) {
index 75693fa535c11b3f221d15c73823c8ed95832a28..e9571b85d9d27d036d1d17a4eaaabd19c0f7ea48 100644 (file)
@@ -54,7 +54,6 @@ void TagRestartCtx(void);
 
 int TagTimeoutCheck(Host *, struct timeval *);
 
-void DetectTagForceCleanup(Host *);
 int TagHostHasTag(Host *host);
 
 #endif /* __DETECT_ENGINE_TAG_H__ */
index 7b440b9895ee6e222c302f4ee42ceb1f8095f973..51849c588317f520fb34493643f358de61715880 100644 (file)
@@ -80,15 +80,6 @@ int ThresholdHostHasThreshold(Host *host) {
     return HostGetStorageById(host, threshold_id) ? 1 : 0;
 }
 
-void DetectThresholdForceCleanup(Host *host) {
-    void *t = HostGetStorageById(host, threshold_id);
-    if (t != NULL) {
-        ThresholdListFree(t);
-        HostSetStorageById(host, threshold_id, NULL);
-    }
-
-}
-
 /**
  * \brief Return next DetectThresholdData for signature
  *
index b44538cd422a1cdbe6a94a928f371e18dacb5bff..4ecc4f94aa2ba25a2a2f1d32ba70b3e7eb47c184 100644 (file)
@@ -30,7 +30,6 @@
 
 int ThresholdHostStorageId(void);
 int ThresholdHostHasThreshold(Host *);
-void DetectThresholdForceCleanup(Host *);
 
 DetectThresholdData *SigGetThresholdType(Signature *, Packet *);
 DetectThresholdData *SigGetThresholdTypeIter(Signature *, Packet *, SigMatch **);
index b231268d90a2d2224ea92d91a40d5200fce026a2..526f9f7509fb6f4c92890b2ecace2ad3f0ad5188 100644 (file)
@@ -301,9 +301,8 @@ void HostCleanup(void)
             HRLOCK_LOCK(hb);
             while (h) {
                 if ((SC_ATOMIC_GET(h->use_cnt) > 0) && (h->iprep != NULL)) {
-                    /* iprep is attached to host only clear tag and threshold */
-                    DetectTagForceCleanup(h);
-                    DetectThresholdForceCleanup(h);
+                    /* iprep is attached to host only clear local storage */
+                    HostFreeStorage(h);
                     h = h->hnext;
                 } else {
                     Host *n = h->hnext;