threads: use threadvars memory helpers

pull/15499/head
Victor Julien 2 months ago
parent ad1459df72
commit 730ff5075d

@ -941,18 +941,15 @@ ThreadVars *TmThreadCreate(const char *name, const char *inq_name, const char *i
const char *outq_name, const char *outqh_name, const char *slots, const char *outq_name, const char *outqh_name, const char *slots,
void * (*fn_p)(void *), int mucond) void * (*fn_p)(void *), int mucond)
{ {
ThreadVars *tv = NULL;
Tmq *tmq = NULL; Tmq *tmq = NULL;
Tmqh *tmqh = NULL; Tmqh *tmqh = NULL;
SCLogDebug("creating thread \"%s\"...", name); SCLogDebug("creating thread \"%s\"...", name);
/* XXX create separate function for this: allocate a thread container */ ThreadVars *tv = ThreadVarsAlloc();
tv = SCCalloc(1, sizeof(ThreadVars) + SCThreadStorageSize());
if (unlikely(tv == NULL)) if (unlikely(tv == NULL))
goto error; goto error;
SC_ATOMIC_INIT(tv->flags);
StatsThreadInit(&tv->stats); StatsThreadInit(&tv->stats);
strlcpy(tv->name, name, sizeof(tv->name)); strlcpy(tv->name, name, sizeof(tv->name));
@ -1046,8 +1043,7 @@ ThreadVars *TmThreadCreate(const char *name, const char *inq_name, const char *i
error: error:
SCLogError("failed to setup a thread"); SCLogError("failed to setup a thread");
if (tv != NULL) ThreadVarsFree(tv);
SCFree(tv);
return NULL; return NULL;
} }
@ -1675,7 +1671,7 @@ static void TmThreadFree(ThreadVars *tv)
} }
TmThreadsUnregisterThread(tv->id); TmThreadsUnregisterThread(tv->id);
SCFree(tv); ThreadVarsFree(tv);
} }
void TmThreadClearThreadsFamily(int family) void TmThreadClearThreadsFamily(int family)

Loading…
Cancel
Save