diff --git a/src/runmode-erf-dag.c b/src/runmode-erf-dag.c index 6b45beab70..0b97517fc9 100644 --- a/src/runmode-erf-dag.c +++ b/src/runmode-erf-dag.c @@ -101,7 +101,6 @@ int RunModeErfDagAuto(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } TmSlotSetFuncAppend(tv_receiveerf, tm_module, iface); - TmThreadMSRegisterSyncPt(tv_receiveerf, "ReceiveTMBeforeDeInit"); if (threading_set_cpu_affinity) { TmThreadSetCPUAffinity(tv_receiveerf, 0); diff --git a/src/runmode-erf-file.c b/src/runmode-erf-file.c index 68b1037a7b..7bfeb52ccf 100644 --- a/src/runmode-erf-file.c +++ b/src/runmode-erf-file.c @@ -90,7 +90,6 @@ int RunModeErfFileAuto(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } TmSlotSetFuncAppend(tv_receiveerf, tm_module, file); - TmThreadMSRegisterSyncPt(tv_receiveerf, "ReceiveTMBeforeDeInit"); if (threading_set_cpu_affinity) { TmThreadSetCPUAffinity(tv_receiveerf, 0); diff --git a/src/runmode-ipfw.c b/src/runmode-ipfw.c index 6fdc681ad7..a63b362938 100644 --- a/src/runmode-ipfw.c +++ b/src/runmode-ipfw.c @@ -102,7 +102,6 @@ int RunModeIpsIPFWAuto(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } TmSlotSetFuncAppend(tv_receiveipfw, tm_module, NULL); - TmThreadMSRegisterSyncPt(tv_receiveipfw, "ReceiveTMBeforeDeInit"); if (threading_set_cpu_affinity) { TmThreadSetCPUAffinity(tv_receiveipfw, 0); diff --git a/src/runmode-nfq.c b/src/runmode-nfq.c index 5d10003860..e78411386c 100644 --- a/src/runmode-nfq.c +++ b/src/runmode-nfq.c @@ -119,7 +119,6 @@ int RunModeIpsNFQAuto(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } TmSlotSetFuncAppend(tv_receivenfq, tm_module, (void *) NFQGetThread(i)); - TmThreadMSRegisterSyncPt(tv_receivenfq, "ReceiveTMBeforeDeInit"); TmThreadSetCPU(tv_receivenfq, RECEIVE_CPU_SET); diff --git a/src/runmode-pcap-file.c b/src/runmode-pcap-file.c index 25c8087abe..a1188c2291 100644 --- a/src/runmode-pcap-file.c +++ b/src/runmode-pcap-file.c @@ -94,7 +94,6 @@ int RunModeFilePcapSingle(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } TmSlotSetFuncAppend(tv, tm_module, file); - TmThreadMSRegisterSyncPt(tv, "ReceiveTMBeforeDeInit"); tm_module = TmModuleGetByName("DecodePcapFile"); if (tm_module == NULL) { @@ -188,7 +187,6 @@ int RunModeFilePcapAuto(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } TmSlotSetFuncAppend(tv_receivepcap, tm_module, file); - TmThreadMSRegisterSyncPt(tv_receivepcap, "ReceiveTMBeforeDeInit"); TmThreadSetCPU(tv_receivepcap, RECEIVE_CPU_SET); @@ -230,7 +228,6 @@ int RunModeFilePcapAuto(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } TmSlotSetFuncAppend(tv_receivepcap, tm_module, file); - TmThreadMSRegisterSyncPt(tv_receivepcap, "ReceiveTMBeforeDeInit"); TmThreadSetCPU(tv_receivepcap, RECEIVE_CPU_SET); @@ -436,7 +433,6 @@ int RunModeFilePcapAutoFp(DetectEngineCtx *de_ctx) exit(EXIT_FAILURE); } TmSlotSetFuncAppend(tv_receivepcap, tm_module, file); - TmThreadMSRegisterSyncPt(tv_receivepcap, "ReceiveTMBeforeDeInit"); tm_module = TmModuleGetByName("DecodePcapFile"); if (tm_module == NULL) { diff --git a/src/tm-threads.c b/src/tm-threads.c index da9e9c19b5..c768317e95 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -181,10 +181,6 @@ void *TmThreadsSlot1NoIn(void *td) usleep(100); } - /* wait for synchronization from master, if this TV has a synchronization - * point set by this name */ - //TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit"); - if (s->SlotThreadExitPrintStats != NULL) { s->SlotThreadExitPrintStats(tv, s->slot_data); } @@ -259,10 +255,6 @@ void *TmThreadsSlot1NoOut(void *td) usleep(100); } - /* wait for synchronization from master, if this TV has a synchronization - * point set by this name */ - //TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit"); - if (s->SlotThreadExitPrintStats != NULL) { s->SlotThreadExitPrintStats(tv, s->slot_data); } @@ -332,10 +324,6 @@ void *TmThreadsSlot1NoInOut(void *td) usleep(100); } - /* wait for synchronization from master, if this TV has a synchronization - * point set by this name */ - //TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit"); - if (s->SlotThreadExitPrintStats != NULL) { s->SlotThreadExitPrintStats(tv, s->slot_data); } @@ -440,10 +428,6 @@ void *TmThreadsSlot1(void *td) usleep(100); } - /* wait for synchronization from master, if this TV has a synchronization - * point set by this name */ - //TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit"); - if (s->SlotThreadExitPrintStats != NULL) { s->SlotThreadExitPrintStats(tv, s->slot_data); } @@ -601,10 +585,6 @@ void *TmThreadsSlotPktAcqLoop(void *td) { usleep(100); } - /* wait for synchronization from master, if this TV has a synchronization - * point set by this name */ - //TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit"); - for (slot = s; slot != NULL; slot = slot->slot_next) { if (slot->SlotThreadExitPrintStats != NULL) { slot->SlotThreadExitPrintStats(tv, slot->slot_data); @@ -729,10 +709,6 @@ void *TmThreadsSlotVar(void *td) usleep(100); } - /* wait for synchronization from master, if this TV has a synchronization - * point set by this name */ - //TmThreadsMSSlaveHitSyncPt(tv, "ReceiveTMBeforeDeInit"); - s = (TmSlot *)tv->tm_slots; for ( ; s != NULL; s = s->slot_next) { @@ -1538,8 +1514,6 @@ void TmThreadKillThreads(void) { TmThreadsSetFlag(tv, THV_DEINIT); SCLogDebug("told thread %s to stop", tv->name); - //TmThreadsMSMasterDisableSlaveAllSyncPts(tv); - if (tv->inq != NULL) { int i; @@ -1611,222 +1585,6 @@ void TmThreadKillThreads(void) { return; } -/** - * \brief Let a ThreadVars register a Master-Slave(MS) Synchronization point. - * - * \param tv Pointer to the ThreadVars. - * \param sync_pt_name Name of the new synchronization point. - * - * \retval 0 On success. - * \retval -1 On failure. - */ -int TmThreadMSRegisterSyncPt(ThreadVars *tv, const char *sync_pt_name) -{ - ThreadVarsMSSyncPt *ms_sync_pts = tv->ms_sync_pts; - ThreadVarsMSSyncPt *ms_sync_pts_prev = NULL; - - while (ms_sync_pts != NULL) { - ms_sync_pts_prev = ms_sync_pts; - if (strlen(ms_sync_pts->name) == strlen(sync_pt_name)) { - if (strcasecmp(ms_sync_pts->name, sync_pt_name) == 0) { - SCLogWarning(SC_ERR_TM_THREADS_ERROR, "This MS thread " - "synchronization point is already registered"); - return 0; - } - } - - ms_sync_pts = ms_sync_pts->next; - } - - ThreadVarsMSSyncPt *sync_pt = SCMalloc(sizeof(ThreadVarsMSSyncPt)); - if (sync_pt == NULL) - return -1; - memset(sync_pt, 0, sizeof(ThreadVarsMSSyncPt)); - SCMutexInit(&sync_pt->m, NULL); - SCCondInit(&sync_pt->cond, NULL); - if ((sync_pt->name = SCStrdup(sync_pt_name)) == NULL) { - return -1; - } - - if (ms_sync_pts_prev == NULL) { - tv->ms_sync_pts = sync_pt; - } else { - ms_sync_pts_prev->next = sync_pt; - } - - return 0; -} - -/** - * \brief Used by a Slave TV, to indicate that it has hit a MS - * synchronization point, specified by the name. - * - * \param tv Pointer to the slave TV. - * \param name Pointer to the name of the synchronization point. - */ -void TmThreadsMSSlaveHitSyncPt(ThreadVars *tv, const char *sync_pt_name) -{ - ThreadVarsMSSyncPt *ms_sync_pts = tv->ms_sync_pts; - - while (ms_sync_pts != NULL) { - if (strlen(ms_sync_pts->name) == strlen(sync_pt_name)) { - if (strcasecmp(ms_sync_pts->name, sync_pt_name) == 0) { - break; - } - } - ms_sync_pts = ms_sync_pts->next; - } - - if (ms_sync_pts == NULL) { - SCLogInfo("This TV - \"%s\", doesn't have a MSSyncPt by the name " - "\"%s\"", tv->name, sync_pt_name); - return; - } - - SCMutexLock(&ms_sync_pts->m); - { - if (!ms_sync_pts->disabled) { - ms_sync_pts->slave_hit = 1; - while (1) { - SCCondWait(&ms_sync_pts->cond, &ms_sync_pts->m); - - if (!ms_sync_pts->master_go) - continue; - - /* reset them */ - ms_sync_pts->slave_hit = 0; - ms_sync_pts->master_go = 0; - break; - } - } - } - SCMutexUnlock(&ms_sync_pts->m); - - return; -} - -/** - * \brief Used by a Mater thread, to release a slave TV if it has hit a - * synchronization point. - * - * \param tv Pointer to the slave TV to be released. - * \param name Pointer to the name of the synchronization point. - */ -void TmThreadsMSMasterReleaseSlaveAtSyncPt(ThreadVars *tv, - const char *sync_pt_name) -{ - ThreadVarsMSSyncPt *ms_sync_pts = tv->ms_sync_pts; - - while (ms_sync_pts != NULL) { - if (strlen(ms_sync_pts->name) == strlen(sync_pt_name)) { - if (strcasecmp(ms_sync_pts->name, sync_pt_name) == 0) { - break; - } - } - ms_sync_pts = ms_sync_pts->next; - } - - if (ms_sync_pts == NULL) { - SCLogInfo("This TV - \"%s\", doesn't have a MSSyncPt by the name " - "\"%s\"", tv->name, sync_pt_name); - return; - } - - SCMutexLock(&ms_sync_pts->m); - { - if (ms_sync_pts->slave_hit) { - ms_sync_pts->master_go = 1; - SCCondSignal(&ms_sync_pts->cond); - } - } - SCMutexUnlock(&ms_sync_pts->m); - - return; -} - -/** - * \brief Used by a Mater thread, to disable a slave TV's - * synchronization point. - * - * \param tv Pointer to the slave TV whose synchronization pt is to be - * disabled. - * \param name Pointer to the name of the synchronization point. - */ -void TmThreadsMSMasterDisableSlaveSyncPt(ThreadVars *tv, - const char *sync_pt_name) -{ - ThreadVarsMSSyncPt *ms_sync_pts = tv->ms_sync_pts; - - while (ms_sync_pts != NULL) { - if (strlen(ms_sync_pts->name) == strlen(sync_pt_name)) { - if (strcasecmp(ms_sync_pts->name, sync_pt_name) == 0) { - break; - } - } - ms_sync_pts = ms_sync_pts->next; - } - - if (ms_sync_pts == NULL) { - SCLogInfo("This TV - \"%s\", doesn't have a MSSyncPt by the name " - "\"%s\"", tv->name, sync_pt_name); - return; - } - - SCMutexLock(&ms_sync_pts->m); - { - ms_sync_pts->disabled = 1; - if (ms_sync_pts->slave_hit) { - ms_sync_pts->master_go = 1; - SCCondSignal(&ms_sync_pts->cond); - } - } - SCMutexUnlock(&ms_sync_pts->m); - - return; -} - -void TmThreadsMSMasterReleaseSlaveAllSyncPts(ThreadVars *tv) -{ - ThreadVarsMSSyncPt *ms_sync_pts = tv->ms_sync_pts; - - while (ms_sync_pts != NULL) { - SCMutexLock(&ms_sync_pts->m); - { - if (ms_sync_pts->slave_hit) { - ms_sync_pts->master_go = 1; - SCCondSignal(&ms_sync_pts->cond); - } - } - SCMutexUnlock(&ms_sync_pts->m); - - ms_sync_pts = ms_sync_pts->next; - } - - return; -} - -void TmThreadsMSMasterDisableSlaveAllSyncPts(ThreadVars *tv) -{ - ThreadVarsMSSyncPt *ms_sync_pts = tv->ms_sync_pts; - - while (ms_sync_pts != NULL) { - SCMutexLock(&ms_sync_pts->m); - { - ms_sync_pts->disabled = 1; - - if (ms_sync_pts->slave_hit) { - ms_sync_pts->master_go = 1; - SCCondSignal(&ms_sync_pts->cond); - } - } - SCMutexUnlock(&ms_sync_pts->m); - - ms_sync_pts = ms_sync_pts->next; - } - - return; -} - /** * \brief Spawns a thread associated with the ThreadVars instance tv * diff --git a/src/tm-threads.h b/src/tm-threads.h index 474f7c1837..af634a7f91 100644 --- a/src/tm-threads.h +++ b/src/tm-threads.h @@ -114,13 +114,6 @@ void TmThreadsUnsetFlag(ThreadVars *, uint8_t); TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot); -int TmThreadMSRegisterSyncPt(ThreadVars *, const char *); -void TmThreadsMSSlaveHitSyncPt(ThreadVars *, const char *); -void TmThreadsMSMasterReleaseSlaveAtSyncPt(ThreadVars *, const char *); -void TmThreadsMSMasterDisableSlaveSyncPt(ThreadVars *, const char *); -void TmThreadsMSMasterReleaseSlaveAllSyncPts(ThreadVars *); -void TmThreadsMSMasterDisableSlaveAllSyncPts(ThreadVars *tv); - ThreadVars *TmThreadsGetTVContainingSlot(TmSlot *); void TmThreadDisableReceiveThreads(void); TmSlot *TmThreadGetFirstTmSlotForPartialPattern(const char *);