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.
pull/466/head
Eric Leblond 13 years ago committed by Victor Julien
parent 27023872de
commit 6d08807b2d

@ -71,14 +71,6 @@ int TagHostHasTag(Host *host) {
return HostGetStorageById(host, tag_id) ? 1 : 0; 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) { static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd) {
DetectTagDataEntry *tde = SCMalloc(sizeof(DetectTagDataEntry)); DetectTagDataEntry *tde = SCMalloc(sizeof(DetectTagDataEntry));
if (unlikely(tde == NULL)) { if (unlikely(tde == NULL)) {

@ -54,7 +54,6 @@ void TagRestartCtx(void);
int TagTimeoutCheck(Host *, struct timeval *); int TagTimeoutCheck(Host *, struct timeval *);
void DetectTagForceCleanup(Host *);
int TagHostHasTag(Host *host); int TagHostHasTag(Host *host);
#endif /* __DETECT_ENGINE_TAG_H__ */ #endif /* __DETECT_ENGINE_TAG_H__ */

@ -80,15 +80,6 @@ int ThresholdHostHasThreshold(Host *host) {
return HostGetStorageById(host, threshold_id) ? 1 : 0; 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 * \brief Return next DetectThresholdData for signature
* *

@ -30,7 +30,6 @@
int ThresholdHostStorageId(void); int ThresholdHostStorageId(void);
int ThresholdHostHasThreshold(Host *); int ThresholdHostHasThreshold(Host *);
void DetectThresholdForceCleanup(Host *);
DetectThresholdData *SigGetThresholdType(Signature *, Packet *); DetectThresholdData *SigGetThresholdType(Signature *, Packet *);
DetectThresholdData *SigGetThresholdTypeIter(Signature *, Packet *, SigMatch **); DetectThresholdData *SigGetThresholdTypeIter(Signature *, Packet *, SigMatch **);

@ -301,9 +301,8 @@ void HostCleanup(void)
HRLOCK_LOCK(hb); HRLOCK_LOCK(hb);
while (h) { while (h) {
if ((SC_ATOMIC_GET(h->use_cnt) > 0) && (h->iprep != NULL)) { if ((SC_ATOMIC_GET(h->use_cnt) > 0) && (h->iprep != NULL)) {
/* iprep is attached to host only clear tag and threshold */ /* iprep is attached to host only clear local storage */
DetectTagForceCleanup(h); HostFreeStorage(h);
DetectThresholdForceCleanup(h);
h = h->hnext; h = h->hnext;
} else { } else {
Host *n = h->hnext; Host *n = h->hnext;

Loading…
Cancel
Save