void HostClearMemory(Host *h)
{
if (h->iprep != NULL) {
- SCFree(h->iprep);
- h->iprep = NULL;
+ SRepFreeHostData(h);
}
if (HostStorageSize() > 0)
HostFreeStorage(h);
+
+ BUG_ON(SC_ATOMIC_GET(h->use_cnt) > 0);
}
#define HOST_DEFAULT_HASHSIZE 4096
/* free spare queue */
while((h = HostDequeue(&host_spare_q))) {
- BUG_ON(SC_ATOMIC_GET(h->use_cnt) > 0);
HostFree(h);
}
#include "conf.h"
#include "detect.h"
#include "reputation.h"
+#include "util-validate.h"
/** effective reputation version, atomic as the host
* time out code will use it to check if a host's
SCLogDebug("effective Reputation version %u", SRepGetEffectiveVersion());
}
+void SRepFreeHostData(Host *h)
+{
+ SCFree(h->iprep);
+ h->iprep = NULL;
+ DEBUG_VALIDATE_BUG_ON(SC_ATOMIC_GET(h->use_cnt) != 1);
+ HostDecrUsecnt(h);
+}
+
/** \brief Set effective reputation version after
* reputation initialization is complete. */
static void SRepInitComplete(void)
if (r->version < eversion) {
SCLogDebug("host %p has reputation version %u, "
"effective version is %u", h, r->version, eversion);
-
- SCFree(h->iprep);
- h->iprep = NULL;
-
- HostDecrUsecnt(h);
+ SRepFreeHostData(h);
return 1;
}
uint8_t rep[SREP_MAX_CATS];
} SReputation;
+void SRepFreeHostData(Host *h);
uint8_t SRepCatGetByShortname(char *shortname);
int SRepInit(struct DetectEngineCtx_ *de_ctx);
void SRepDestroy(struct DetectEngineCtx_ *de_ctx);