From: Eric Leblond Date: Mon, 18 Mar 2013 10:05:52 +0000 (+0100) Subject: Host: use global free storage function X-Git-Tag: suricata-2.0beta2~472 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d08807b2d728f588a9201a956816ce25d88c91f;p=thirdparty%2Fsuricata.git Host: use global free storage function 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. --- diff --git a/src/detect-engine-tag.c b/src/detect-engine-tag.c index 8979d940a0..59db17d4e2 100644 --- a/src/detect-engine-tag.c +++ b/src/detect-engine-tag.c @@ -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)) { diff --git a/src/detect-engine-tag.h b/src/detect-engine-tag.h index 75693fa535..e9571b85d9 100644 --- a/src/detect-engine-tag.h +++ b/src/detect-engine-tag.h @@ -54,7 +54,6 @@ void TagRestartCtx(void); int TagTimeoutCheck(Host *, struct timeval *); -void DetectTagForceCleanup(Host *); int TagHostHasTag(Host *host); #endif /* __DETECT_ENGINE_TAG_H__ */ diff --git a/src/detect-engine-threshold.c b/src/detect-engine-threshold.c index 7b440b9895..51849c5883 100644 --- a/src/detect-engine-threshold.c +++ b/src/detect-engine-threshold.c @@ -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 * diff --git a/src/detect-engine-threshold.h b/src/detect-engine-threshold.h index b44538cd42..4ecc4f94aa 100644 --- a/src/detect-engine-threshold.h +++ b/src/detect-engine-threshold.h @@ -30,7 +30,6 @@ int ThresholdHostStorageId(void); int ThresholdHostHasThreshold(Host *); -void DetectThresholdForceCleanup(Host *); DetectThresholdData *SigGetThresholdType(Signature *, Packet *); DetectThresholdData *SigGetThresholdTypeIter(Signature *, Packet *, SigMatch **); diff --git a/src/host.c b/src/host.c index b231268d90..526f9f7509 100644 --- a/src/host.c +++ b/src/host.c @@ -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;