Fix cleaning of threads where mutex and condition where not freed.
This fixes:
352 (192 direct, 160 indirect) bytes in 4 blocks are definitely lost in loss record 301 of 327
at 0x4C29C0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x909404: TmThreadInitMC (tm-threads.c:1764)
by 0x908DE7: TmThreadCreate (tm-threads.c:1120)
by 0x90A326: TmThreadCreateMgmtThread (tm-threads.c:1183)
by 0x4CA0AD: StatsSpawnThreads (counters.c:856)
by 0x87F254: UnixSocketPcapFilesCheck (runmode-unix-socket.c:396)
by 0x910330: UnixCommandBackgroundTasks (unix-manager.c:430)
by 0x9140DD: UnixManager (unix-manager.c:980)
by 0x9077F3: TmThreadsManagement (tm-threads.c:600)
by 0x68DE283: start_thread (pthread_create.c:333)
by 0x80A6A4C: clone (in /lib/x86_64-linux-gnu/libc-2.21.so)
/* prototypes */
static int SetCPUAffinity(uint16_t cpu);
+static void TmThreadDeinitMC(ThreadVars *tv);
+
/* root of the threadvars list */
ThreadVars *tv_root[TVT_MAX] = { NULL };
StatsThreadCleanup(tv);
+ TmThreadDeinitMC(tv);
+
s = (TmSlot *)tv->tm_slots;
while (s) {
ps = s;
return;
}
+static void TmThreadDeinitMC(ThreadVars *tv)
+{
+ if (tv->ctrl_mutex) {
+ SCCtrlMutexDestroy(tv->ctrl_mutex);
+ SCFree(tv->ctrl_mutex);
+ }
+ if (tv->ctrl_cond) {
+ SCCtrlCondDestroy(tv->ctrl_cond);
+ SCFree(tv->ctrl_cond);
+ }
+ return;
+}
+
/**
* \brief Tests if the thread represented in the arg has been unpaused or not.
*