|
suricata
|
#include "suricata-common.h"#include "suricata.h"#include "stream.h"#include "runmodes.h"#include "thread-callbacks.h"#include "threadvars.h"#include "thread-storage.h"#include "tm-queues.h"#include "tm-queuehandlers.h"#include "tm-threads.h"#include "capture-hooks.h"#include "tmqh-packetpool.h"#include "threads.h"#include "util-affinity.h"#include "util-debug.h"#include "util-privs.h"#include "util-cpu.h"#include "util-profiling.h"#include "util-signal.h"#include "queue.h"#include "util-validate.h"#include "source-pcap-file-helper.h"#include "util-unittest-helper.h"#include <pthread.h>
Go to the source code of this file.
Data Structures | |
| struct | Thread_ |
Macros | |
| #define | MIN_WAIT_TIME 100 |
| #define | MAX_WAIT_TIME 999999 |
| #define | STEP 32 |
Functions | |
| int | TmThreadsCheckFlag (ThreadVars *tv, uint32_t flag) |
| Check if a thread flag is set. More... | |
| void | TmThreadsSetFlag (ThreadVars *tv, uint32_t flag) |
| Set a thread flag. More... | |
| void | TmThreadsUnsetFlag (ThreadVars *tv, uint32_t flag) |
| Unset a thread flag. More... | |
| TmEcode | TmThreadsProcessDecodePseudoPackets (ThreadVars *tv, PacketQueueNoLock *decode_pq, TmSlot *slot) |
| TmEcode | TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot) |
| Separate run function so we can call it recursively. More... | |
| int | TmThreadTimeoutLoop (ThreadVars *tv, TmSlot *s) |
| bool | SCTmThreadsSlotPacketLoopFinish (ThreadVars *tv) |
| bool | TmThreadsWaitForUnpause (ThreadVars *tv) |
| Wait for a thread to become unpaused. More... | |
| void | TmSlotSetFuncAppend (ThreadVars *tv, TmModule *tm, const void *data) |
| Appends a new entry to the slots. More... | |
| TmEcode | TmThreadSetThreadPriority (ThreadVars *tv, int prio) |
| Set the thread options (thread priority). More... | |
| void | TmThreadSetPrio (ThreadVars *tv) |
| Adjusting nice value for threads. More... | |
| TmEcode | TmThreadSetCPUAffinity (ThreadVars *tv, uint16_t cpu) |
| Set the thread options (cpu affinity). More... | |
| TmEcode | TmThreadSetCPU (ThreadVars *tv, uint8_t type) |
| int | TmThreadGetNbThreads (uint8_t type) |
| TmEcode | TmThreadSetupOptions (ThreadVars *tv) |
| Set the thread options (cpu affinitythread). Priority should be already set by pthread_create. More... | |
| ThreadVars * | TmThreadCreate (const char *name, const char *inq_name, const char *inqh_name, const char *outq_name, const char *outqh_name, const char *slots, void *(*fn_p)(void *), int mucond) |
| Creates and returns the TV instance for a new thread. More... | |
| ThreadVars * | TmThreadCreatePacketHandler (const char *name, const char *inq_name, const char *inqh_name, const char *outq_name, const char *outqh_name, const char *slots) |
| Creates and returns a TV instance for a Packet Processing Thread. This function doesn't support custom slots, and hence shouldn't be supplied "custom" as its slot type. All PPT threads are created with a mucond(see TmThreadCreate declaration) of 0. Hence the tv conditional variables are not used to kill the thread. More... | |
| ThreadVars * | TmThreadCreateMgmtThread (const char *name, void *(fn_p)(void *), int mucond) |
| Creates and returns the TV instance for a Management thread(MGMT). This function supports only custom slot functions and hence a function pointer should be sent as an argument. More... | |
| ThreadVars * | TmThreadCreateMgmtThreadByName (const char *name, const char *module, int mucond) |
| Creates and returns the TV instance for a Management thread(MGMT). This function supports only custom slot functions and hence a function pointer should be sent as an argument. More... | |
| ThreadVars * | TmThreadCreateCmdThreadByName (const char *name, const char *module, int mucond) |
| Creates and returns the TV instance for a Command thread (CMD). This function supports only custom slot functions and hence a function pointer should be sent as an argument. More... | |
| void | TmThreadAppend (ThreadVars *tv, int type) |
| Appends this TV to tv_root based on its type. More... | |
| void | TmThreadDisableReceiveThreads (void) |
| Disable all threads having the specified TMs. More... | |
| void | TmThreadDisablePacketThreads (const uint16_t set, const uint16_t check, const uint8_t module_flags) |
| Disable all packet threads. More... | |
| void | TmThreadKillThreadsFamily (int family) |
| void | TmThreadKillThreads (void) |
| void | TmThreadClearThreadsFamily (int family) |
| TmEcode | TmThreadSpawn (ThreadVars *tv) |
| Spawns a thread associated with the ThreadVars instance tv. More... | |
| TmEcode | TmThreadLibSpawn (ThreadVars *tv) |
| Spawns a "fake" lib thread associated with the ThreadVars instance tv. More... | |
| void | TmThreadInitMC (ThreadVars *tv) |
| Initializes the mutex and condition variables for this TV. More... | |
| void | TmThreadWaitForFlag (ThreadVars *tv, uint32_t flags) |
| Waits till the specified flag(s) is(are) set. We don't bother if the kill flag has been set or not on the thread. More... | |
| void | TmThreadContinue (ThreadVars *tv) |
| Unpauses a thread. More... | |
| TmEcode | TmThreadWaitOnThreadRunning (void) |
| Waits for all threads to be in a running state. More... | |
| void | TmThreadContinueThreads (void) |
| Unpauses all threads present in tv_root. More... | |
| void | TmThreadCheckThreadState (void) |
| Used to check the thread for certain conditions of failure. More... | |
| TmEcode | TmThreadWaitOnThreadInit (void) |
| Used to check if all threads have finished their initialization. On finding an un-initialized thread, it waits till that thread completes its initialization, before proceeding to the next thread. More... | |
| uint32_t | TmThreadCountThreadsByTmmFlags (uint8_t flags) |
| returns a count of all the threads that match the flag More... | |
| struct Thread_ | __attribute__ ((aligned(CLS))) |
| SC_ATOMIC_DECLARE (SCTime_t, pktts) | |
| void | TmThreadsSealThreads (void) |
| void | TmThreadsUnsealThreads (void) |
| void | TmThreadsListThreads (void) |
| int | TmThreadsRegisterThread (ThreadVars *tv, const int type) |
| void | TmThreadsUnregisterThread (const int id) |
| void | TmThreadsSetThreadTimestamp (const int id, const SCTime_t ts) |
| bool | TmThreadsTimeSubsysIsReady (void) |
| void | TmThreadsInitThreadsTimestamp (const SCTime_t ts) |
| SCTime_t | TmThreadsGetThreadTime (const int idx) |
| void | TmThreadsGetMinimalTimestamp (struct timeval *ts) |
| uint16_t | TmThreadsGetWorkerThreadMax (void) |
| void | TmThreadsInjectFlowById (Flow *f, const int id) |
| inject a flow into a threads flow queue More... | |
| void | TmThreadsRegisterTests (void) |
Variables | |
| ThreadVars * | tv_root [TVT_MAX] = { NULL } |
| SCMutex | tv_root_lock = SCMUTEX_INITIALIZER |
| ThreadVars * | tv |
| const char * | name |
| int | type |
| int | in_use |
| SCTime_t | sys_sec_stamp |
| SCSpinlock | spin |
| Threads | |
Thread management functions.
Definition in file tm-threads.c.
| #define MAX_WAIT_TIME 999999 |
Definition at line 1602 of file tm-threads.c.
| #define MIN_WAIT_TIME 100 |
Definition at line 1601 of file tm-threads.c.
| #define STEP 32 |
Definition at line 2198 of file tm-threads.c.
Definition at line 2080 of file tm-threads.c.
| __attribute__::SC_ATOMIC_DECLARE | ( | SCTime_t | , |
| pktts | |||
| ) |
current packet time of this thread (offline mode)
| bool SCTmThreadsSlotPacketLoopFinish | ( | ThreadVars * | tv | ) |
Definition at line 274 of file tm-threads.c.
References PacketPoolDestroy(), SC_ATOMIC_GET, TmSlot_::slot_next, ThreadVars_::stats, StatsSyncCounters(), ThreadVars_::stream_pq, THV_CLOSED, THV_DEINIT, THV_FLOW_LOOP, THV_RUNNING_DONE, TM_ECODE_OK, ThreadVars_::tm_slots, TmThreadsSetFlag(), TmThreadTimeoutLoop(), TmThreadWaitForFlag(), and tv.

| void TmSlotSetFuncAppend | ( | ThreadVars * | tv, |
| TmModule * | tm, | ||
| const void * | data | ||
| ) |
Appends a new entry to the slots.
| tv | TV the slot is attached to. |
| tm | TM to append. |
| data | Data to be passed on to the slot init function. |
| The | allocated TmSlot or NULL if there is an error |
Definition at line 668 of file tm-threads.c.
References ThreadVars_::break_loop, TmModule_::cap_flags, ThreadVars_::cap_flags, TmModule_::flags, TmModule_::Func, TmSlot_::Management, TmModule_::Management, TmModule_::PktAcqBreakLoop, TmSlot_::PktAcqLoop, TmModule_::PktAcqLoop, SC_ATOMIC_INITPTR, SCCalloc, TmSlot_::slot_initdata, TmSlot_::slot_next, TmSlot_::SlotFunc, TmSlot_::SlotThreadDeinit, TmSlot_::SlotThreadExitPrintStats, TmSlot_::SlotThreadInit, TmModule_::ThreadDeinit, TmModule_::ThreadExitPrintStats, TmModule_::ThreadInit, TmSlot_::tm_flags, TmSlot_::tm_id, ThreadVars_::tm_slots, ThreadVars_::tmm_flags, TmModuleGetIDForTM(), tv, and unlikely.
Referenced by RunModeErfFileAutoFp(), RunModeErfFileSingle(), RunModeFilePcapAutoFp(), RunModeFilePcapSingle(), RunModeSetIPSAutoFp(), RunModeSetIPSWorker(), RunModeSetLiveCaptureAutoFp(), TmThreadCreateCmdThreadByName(), and TmThreadCreateMgmtThreadByName().


| void TmThreadAppend | ( | ThreadVars * | tv, |
| int | type | ||
| ) |
Appends this TV to tv_root based on its type.
| type | holds the type this TV belongs to. |
Definition at line 1190 of file tm-threads.c.
References ThreadVars_::next, SCMutexLock, SCMutexUnlock, tv, tv_root, tv_root_lock, and type.
Referenced by TmThreadSpawn().

| void TmThreadCheckThreadState | ( | void | ) |
Used to check the thread for certain conditions of failure.
Definition at line 1994 of file tm-threads.c.
References FatalError, ThreadVars_::name, ThreadVars_::next, SCMutexLock, SCMutexUnlock, THV_FAILED, TmThreadsCheckFlag(), tv, tv_root, tv_root_lock, and TVT_MAX.
Referenced by SuricataMainLoop().


| void TmThreadClearThreadsFamily | ( | int | family | ) |
Definition at line 1685 of file tm-threads.c.
References ThreadVars_::next, SCMutexLock, tv, tv_root, tv_root_lock, and TVT_MAX.
| void TmThreadContinue | ( | ThreadVars * | tv | ) |
Unpauses a thread.
| tv | Pointer to a TV instance that has to be unpaused |
Definition at line 1842 of file tm-threads.c.
References THV_PAUSE, TmThreadsUnsetFlag(), and tv.
Referenced by TmThreadContinueDetectLoaderThreads(), and TmThreadContinueThreads().


| void TmThreadContinueThreads | ( | void | ) |
Unpauses all threads present in tv_root.
Definition at line 1978 of file tm-threads.c.
References ThreadVars_::next, SCMutexLock, SCMutexUnlock, TmThreadContinue(), tv, tv_root, tv_root_lock, and TVT_MAX.
Referenced by SuricataPostInit().


| uint32_t TmThreadCountThreadsByTmmFlags | ( | uint8_t | flags | ) |
returns a count of all the threads that match the flag
Definition at line 2080 of file tm-threads.c.
References cnt, flags, ThreadVars_::next, SCMutexLock, SCMutexUnlock, ThreadVars_::tmm_flags, tv, tv_root, tv_root_lock, and TVT_MAX.
Referenced by PacketPoolPostRunmodes().

| ThreadVars* TmThreadCreate | ( | const char * | name, |
| const char * | inq_name, | ||
| const char * | inqh_name, | ||
| const char * | outq_name, | ||
| const char * | outqh_name, | ||
| const char * | slots, | ||
| void *(*)(void *) | fn_p, | ||
| int | mucond | ||
| ) |
Creates and returns the TV instance for a new thread.
| name | Name of this TV instance |
| inq_name | Incoming queue name |
| inqh_name | Incoming queue handler name as set by TmqhSetup() |
| outq_name | Outgoing queue name |
| outqh_name | Outgoing queue handler as set by TmqhSetup() |
| slots | String representation for the slot function to be used |
| fn_p | Pointer to function when "slots" is of type "custom" |
| mucond | Flag to indicate whether to initialize the condition and the mutex variables for this newly created TV. |
| the | newly created TV instance, or NULL on error |
Definition at line 948 of file tm-threads.c.
References Tmqh_::InHandler, ThreadVars_::inq, ThreadVars_::inq_id, ThreadVars_::name, name, ThreadVars_::outctx, Tmqh_::OutHandler, Tmqh_::OutHandlerCtxSetup, ThreadVars_::outq, ThreadVars_::outq_id, Tmq_::reader_cnt, SCLogDebug, ThreadVars_::stats, StatsThreadInit(), strlcpy(), ThreadVarsAlloc(), THV_PAUSE, TmqCreateQueue(), TmqGetQueueByName(), ThreadVars_::tmqh_in, ThreadVars_::tmqh_out, TmqhGetQueueHandlerByName(), TmqhNameToID(), TmThreadsSetFlag(), tv, unlikely, and Tmq_::writer_cnt.
Referenced by TmThreadCreateCmdThreadByName(), TmThreadCreateMgmtThread(), TmThreadCreateMgmtThreadByName(), and TmThreadCreatePacketHandler().


| ThreadVars* TmThreadCreateCmdThreadByName | ( | const char * | name, |
| const char * | module, | ||
| int | mucond | ||
| ) |
Creates and returns the TV instance for a Command thread (CMD). This function supports only custom slot functions and hence a function pointer should be sent as an argument.
| name | Name of this TV instance |
| module | Name of TmModule with COMMAND flag set. |
| mucond | Flag to indicate whether to initialize the condition and the mutex variables for this newly created TV. |
| the | newly created TV instance, or NULL on error |
Definition at line 1164 of file tm-threads.c.
References ThreadVars_::id, m, MANAGEMENT_CPU_SET, name, TmModuleGetByName(), TmSlotSetFuncAppend(), TmThreadCreate(), TmThreadSetCPU(), TmThreadsRegisterThread(), tv, TVT_CMD, and ThreadVars_::type.

| ThreadVars* TmThreadCreateMgmtThread | ( | const char * | name, |
| void * | fn_p)(void *, | ||
| int | mucond | ||
| ) |
Creates and returns the TV instance for a Management thread(MGMT). This function supports only custom slot functions and hence a function pointer should be sent as an argument.
| name | Name of this TV instance |
| fn_p | Pointer to function when "slots" is of type "custom" |
| mucond | Flag to indicate whether to initialize the condition and the mutex variables for this newly created TV. |
| the | newly created TV instance, or NULL on error |
Definition at line 1103 of file tm-threads.c.
References ThreadVars_::id, MANAGEMENT_CPU_SET, name, TmThreadCreate(), TmThreadSetCPU(), TmThreadsRegisterThread(), tv, TVT_MGMT, and ThreadVars_::type.
Referenced by LogMaintenanceThreadSpawn().


| ThreadVars* TmThreadCreateMgmtThreadByName | ( | const char * | name, |
| const char * | module, | ||
| int | mucond | ||
| ) |
Creates and returns the TV instance for a Management thread(MGMT). This function supports only custom slot functions and hence a function pointer should be sent as an argument.
| name | Name of this TV instance |
| module | Name of TmModule with MANAGEMENT flag set. |
| mucond | Flag to indicate whether to initialize the condition and the mutex variables for this newly created TV. |
| the | newly created TV instance, or NULL on error |
Definition at line 1131 of file tm-threads.c.
References ThreadVars_::id, m, MANAGEMENT_CPU_SET, name, TmModuleGetByName(), TmSlotSetFuncAppend(), TmThreadCreate(), TmThreadSetCPU(), TmThreadsRegisterThread(), tv, TVT_MGMT, and ThreadVars_::type.
Referenced by BypassedFlowManagerThreadSpawn().


| ThreadVars* TmThreadCreatePacketHandler | ( | const char * | name, |
| const char * | inq_name, | ||
| const char * | inqh_name, | ||
| const char * | outq_name, | ||
| const char * | outqh_name, | ||
| const char * | slots | ||
| ) |
Creates and returns a TV instance for a Packet Processing Thread. This function doesn't support custom slots, and hence shouldn't be supplied "custom" as its slot type. All PPT threads are created with a mucond(see TmThreadCreate declaration) of 0. Hence the tv conditional variables are not used to kill the thread.
| name | Name of this TV instance |
| inq_name | Incoming queue name |
| inqh_name | Incoming queue handler name as set by TmqhSetup() |
| outq_name | Outgoing queue name |
| outqh_name | Outgoing queue handler as set by TmqhSetup() |
| slots | String representation for the slot function to be used |
| the | newly created TV instance, or NULL on error |
Definition at line 1074 of file tm-threads.c.
References ThreadVars_::id, name, TmThreadCreate(), TmThreadsRegisterThread(), tv, TVT_PPT, and ThreadVars_::type.
Referenced by RunModeErfFileAutoFp(), RunModeErfFileSingle(), RunModeFilePcapAutoFp(), RunModeFilePcapSingle(), RunModeSetIPSAutoFp(), RunModeSetIPSWorker(), and RunModeSetLiveCaptureAutoFp().


| void TmThreadDisablePacketThreads | ( | const uint16_t | set, |
| const uint16_t | check, | ||
| const uint8_t | module_flags | ||
| ) |
Disable all packet threads.
| set | flag to set |
| check | flag to check |
| module_flags | bitflags of TmModule's to apply the set flag to. |
Support 2 stages in shutting down the packet threads:
During step 1 the main loop is exited, and the flow loop logic is entered. During step 2, the flow loop logic is done and the thread closes.
module_flags limits which threads are disabled
Definition at line 1544 of file tm-threads.c.
Referenced by PostRunDeinit().

| void TmThreadDisableReceiveThreads | ( | void | ) |
Disable all threads having the specified TMs.
Breaks out of the packet acquisition loop, and bumps into the 'flow loop', where it will process packets from the flow engine's shutdown handling.
Definition at line 1392 of file tm-threads.c.
References FatalError, TmModule_::flags, ThreadVars_::name, SCMutexLock, TmSlot_::slot_next, TM_FLAG_RECEIVE_TM, TmSlot_::tm_id, ThreadVars_::tm_slots, TmModuleGetById(), tv, tv_root, tv_root_lock, and TVT_PPT.
Referenced by PostRunDeinit().


| int TmThreadGetNbThreads | ( | uint8_t | type | ) |
Definition at line 857 of file tm-threads.c.
References MAX_CPU_SET, ThreadsAffinityType_::nb_threads, SCLogError, thread_affinity, and type.
Referenced by RunModeErfFileAutoFp(), RunModeFilePcapAutoFp(), and TmThreadsGetWorkerThreadMax().

| void TmThreadInitMC | ( | ThreadVars * | tv | ) |
Initializes the mutex and condition variables for this TV.
It can be used by a thread to control a wait loop that can also be influenced by other threads.
| tv | Pointer to a TV instance |
Definition at line 1789 of file tm-threads.c.
References ThreadVars_::ctrl_cond, ThreadVars_::ctrl_mutex, FatalError, SCCtrlCondInit, SCCtrlMutexInit, SCMalloc, and tv.
| void TmThreadKillThreads | ( | void | ) |
Definition at line 1631 of file tm-threads.c.
References TmThreadKillThreadsFamily(), and TVT_MAX.
Referenced by SuricataShutdown().


| void TmThreadKillThreadsFamily | ( | int | family | ) |
Definition at line 1602 of file tm-threads.c.
References BUG_ON, MIN_WAIT_TIME, SCMutexLock, tv, tv_root, tv_root_lock, and TVT_MAX.
Referenced by TmThreadKillThreads().

| TmEcode TmThreadLibSpawn | ( | ThreadVars * | tv | ) |
Spawns a "fake" lib thread associated with the ThreadVars instance tv.
| TM_ECODE_OK | on success and TM_ECODE_FAILED on failure |
Definition at line 1765 of file tm-threads.c.
References THV_INIT_DONE, THV_RUNNING_DONE, TM_ECODE_FAILED, TM_ECODE_OK, ThreadVars_::tm_func, TmThreadWaitForFlag(), and tv.
Referenced by SCRunModeLibSpawnWorker().


| int TmThreadsCheckFlag | ( | ThreadVars * | tv, |
| uint32_t | flag | ||
| ) |
Check if a thread flag is set.
| 1 | flag is set. |
| 0 | flag is not set. |
Definition at line 94 of file tm-threads.c.
References SC_ATOMIC_GET, and tv.
Referenced by FlowDisableFlowManagerThread(), TmThreadCheckThreadState(), TmThreadsWaitForUnpause(), TmThreadWaitForFlag(), and TmThreadWaitOnThreadInit().

| TmEcode TmThreadSetCPU | ( | ThreadVars * | tv, |
| uint8_t | type | ||
| ) |
Definition at line 841 of file tm-threads.c.
References ThreadVars_::cpu_affinity, MAX_CPU_SET, SCLogError, THREAD_SET_AFFTYPE, ThreadVars_::thread_setup_flags, threading_set_cpu_affinity, TM_ECODE_FAILED, TM_ECODE_OK, tv, and type.
Referenced by RunModeFilePcapAutoFp(), RunModeFilePcapSingle(), RunModeSetIPSAutoFp(), RunModeSetIPSWorker(), RunModeSetLiveCaptureAutoFp(), TmThreadCreateCmdThreadByName(), TmThreadCreateMgmtThread(), and TmThreadCreateMgmtThreadByName().

| TmEcode TmThreadSetCPUAffinity | ( | ThreadVars * | tv, |
| uint16_t | cpu | ||
| ) |
Set the thread options (cpu affinity).
| tv | pointer to the ThreadVars to setup the affinity. |
| cpu | cpu on which affinity is set. |
| TM_ECODE_OK |
Definition at line 832 of file tm-threads.c.
References ThreadVars_::cpu_affinity, THREAD_SET_AFFINITY, ThreadVars_::thread_setup_flags, TM_ECODE_OK, and tv.
Referenced by RunModeErfFileAutoFp().

| void TmThreadSetPrio | ( | ThreadVars * | tv | ) |
Adjusting nice value for threads.
Definition at line 795 of file tm-threads.c.
References ThreadVars_::name, SCEnter, SCLogDebug, SCLogError, SCReturn, ThreadVars_::thread_priority, and tv.
| TmEcode TmThreadSetThreadPriority | ( | ThreadVars * | tv, |
| int | prio | ||
| ) |
Set the thread options (thread priority).
| tv | Pointer to the ThreadVars to setup the thread priority. |
| TM_ECODE_OK. |
Definition at line 784 of file tm-threads.c.
References ThreadVars_::thread_priority, THREAD_SET_PRIORITY, ThreadVars_::thread_setup_flags, TM_ECODE_OK, and tv.
Referenced by RunModeErfFileAutoFp().

| TmEcode TmThreadSetupOptions | ( | ThreadVars * | tv | ) |
Set the thread options (cpu affinitythread). Priority should be already set by pthread_create.
| tv | pointer to the ThreadVars of the calling thread. |
Definition at line 873 of file tm-threads.c.
References ThreadVars_::cpu_affinity, ThreadVars_::name, SCGetThreadIdLong, SCLogPerf, THREAD_SET_AFFINITY, ThreadVars_::thread_setup_flags, and tv.
| void TmThreadsGetMinimalTimestamp | ( | struct timeval * | ts | ) |
Definition at line 2357 of file tm-threads.c.
References SCTIME_INITIALIZER.
| SCTime_t TmThreadsGetThreadTime | ( | const int | idx | ) |
Definition at line 2349 of file tm-threads.c.
References DEBUG_VALIDATE_BUG_ON.
| uint16_t TmThreadsGetWorkerThreadMax | ( | void | ) |
Definition at line 2398 of file tm-threads.c.
References SCLogWarning, threading_detect_ratio, TmThreadGetNbThreads(), UtilCpuGetNumProcessorsOnline(), and WORKER_CPU_SET.
Referenced by RunModeSetIPSAutoFp(), and RunModeSetLiveCaptureAutoFp().


| void TmThreadsInitThreadsTimestamp | ( | const SCTime_t | ts | ) |
Definition at line 2330 of file tm-threads.c.
Referenced by PcapFileDispatch().

| void TmThreadsInjectFlowById | ( | Flow * | f, |
| const int | id | ||
| ) |
inject a flow into a threads flow queue
Definition at line 2416 of file tm-threads.c.
Referenced by FlowSendToLocalThread().

| void TmThreadsListThreads | ( | void | ) |
Definition at line 2177 of file tm-threads.c.
References SCMutexLock.
| TmEcode TmThreadSpawn | ( | ThreadVars * | tv | ) |
Spawns a thread associated with the ThreadVars instance tv.
| TM_ECODE_OK | on success and TM_ECODE_FAILED on failure |
Definition at line 1710 of file tm-threads.c.
References FatalError, ThreadVars_::name, SCLogDebug, ThreadVars_::t, threading_set_stack_size, THV_INIT_DONE, THV_RUNNING_DONE, TM_ECODE_OK, ThreadVars_::tm_func, TmThreadAppend(), TmThreadWaitForFlag(), tv, and ThreadVars_::type.
Referenced by BypassedFlowManagerThreadSpawn(), RunModeErfFileAutoFp(), RunModeErfFileSingle(), RunModeFilePcapAutoFp(), RunModeFilePcapSingle(), RunModeSetIPSAutoFp(), RunModeSetIPSWorker(), and RunModeSetLiveCaptureAutoFp().


| TmEcode TmThreadsProcessDecodePseudoPackets | ( | ThreadVars * | tv, |
| PacketQueueNoLock * | decode_pq, | ||
| TmSlot * | slot | ||
| ) |
Definition at line 115 of file tm-threads.c.
References DEBUG_VALIDATE_BUG_ON, Packet_::flow, PacketDequeueNoLock(), PacketQueueNoLock_::top, and unlikely.

| void TmThreadsRegisterTests | ( | void | ) |
Definition at line 2501 of file tm-threads.c.
References UtRegisterTest().

| int TmThreadsRegisterThread | ( | ThreadVars * | tv, |
| const int | type | ||
| ) |
| id | thread id, or 0 if not found |
Definition at line 2201 of file tm-threads.c.
References SCMutexLock.
Referenced by TmThreadCreateCmdThreadByName(), TmThreadCreateMgmtThread(), TmThreadCreateMgmtThreadByName(), and TmThreadCreatePacketHandler().

| void TmThreadsSealThreads | ( | void | ) |
Definition at line 2161 of file tm-threads.c.
References SCMutexLock.
| void TmThreadsSetFlag | ( | ThreadVars * | tv, |
| uint32_t | flag | ||
| ) |
Set a thread flag.
Definition at line 102 of file tm-threads.c.
References SC_ATOMIC_OR, and tv.
Referenced by FlowDisableFlowManagerThread(), ReceiveErfDagLoop(), ReceiveErfFileLoop(), SCRunModeLibSpawnWorker(), SCTmThreadsSlotPacketLoopFinish(), TmThreadCreate(), and TmThreadsWaitForUnpause().

| void TmThreadsSetThreadTimestamp | ( | const int | id, |
| const SCTime_t | ts | ||
| ) |
Definition at line 2285 of file tm-threads.c.
| TmEcode TmThreadsSlotVarRun | ( | ThreadVars * | tv, |
| Packet * | p, | ||
| TmSlot * | slot | ||
| ) |
Separate run function so we can call it recursively.
Definition at line 134 of file tm-threads.c.
References DEBUG_VALIDATE_BUG_ON, Packet_::flow, p, PACKET_PROFILING_TMM_END, PACKET_PROFILING_TMM_START, SC_ATOMIC_GET, TmSlot_::slot_next, TM_ECODE_FAILED, tv, and unlikely.
| bool TmThreadsTimeSubsysIsReady | ( | void | ) |
Definition at line 2306 of file tm-threads.c.
References SCTIME_INITIALIZER.
| void TmThreadsUnregisterThread | ( | const int | id | ) |
Definition at line 2251 of file tm-threads.c.
References SCMutexLock.
| void TmThreadsUnsealThreads | ( | void | ) |
Definition at line 2169 of file tm-threads.c.
References SCMutexLock.
Referenced by PostRunDeinit().

| void TmThreadsUnsetFlag | ( | ThreadVars * | tv, |
| uint32_t | flag | ||
| ) |
Unset a thread flag.
Definition at line 110 of file tm-threads.c.
References SC_ATOMIC_AND, and tv.
Referenced by TmThreadContinue(), and TmThreadsWaitForUnpause().

| bool TmThreadsWaitForUnpause | ( | ThreadVars * | tv | ) |
Wait for a thread to become unpaused.
Wait for the thread to be unpaused.
A thread killed while still in the initial pause skips its main loop, except mgmt threads (TVT_MGMT): they run one pass to do final work (e.g. the last stats output) - their loops test THV_KILL and exit after the pass. RX/worker loops have no top KILL test and would do real work during teardown (a pcap-file pass dispatches into a pipeline being torn down), so they keep skipping.
Definition at line 371 of file tm-threads.c.
References SleepUsec, THV_KILL, THV_PAUSE, THV_PAUSED, TmThreadsCheckFlag(), TmThreadsSetFlag(), TmThreadsUnsetFlag(), tv, TVT_MGMT, and ThreadVars_::type.

| int TmThreadTimeoutLoop | ( | ThreadVars * | tv, |
| TmSlot * | s | ||
| ) |
Definition at line 167 of file tm-threads.c.
References DEBUG_VALIDATE_BUG_ON, Packet_::flow, len, PacketQueue_::len, likely, PacketQueue_::mutex_q, p, PacketDequeue(), SCLogDebug, SCMutexLock, SCMutexUnlock, ThreadVars_::stream_pq, TM_ECODE_OK, ThreadVars_::tm_flowworker, and tv.
Referenced by SCTmThreadsSlotPacketLoopFinish().


| void TmThreadWaitForFlag | ( | ThreadVars * | tv, |
| uint32_t | flags | ||
| ) |
Waits till the specified flag(s) is(are) set. We don't bother if the kill flag has been set or not on the thread.
| tv | Pointer to the TV instance. |
Definition at line 1830 of file tm-threads.c.
References flags, SleepUsec, TmThreadsCheckFlag(), and tv.
Referenced by SCTmThreadsSlotPacketLoopFinish(), TmThreadLibSpawn(), and TmThreadSpawn().


| TmEcode TmThreadWaitOnThreadInit | ( | void | ) |
Used to check if all threads have finished their initialization. On finding an un-initialized thread, it waits till that thread completes its initialization, before proceeding to the next thread.
| TM_ECODE_OK | all initialized properly |
| TM_ECODE_FAILED | failure |
Definition at line 2017 of file tm-threads.c.
References ThreadVars_::name, ThreadVars_::next, SC_ATOMIC_GET, SCLogError, SCMutexLock, SCMutexUnlock, SleepUsec, THV_CLOSED, THV_DEAD, THV_FAILED, THV_INIT_DONE, TM_ECODE_FAILED, TM_ECODE_OK, TmThreadsCheckFlag(), tv, tv_root, tv_root_lock, and TVT_MAX.
Referenced by SuricataPostInit().


| TmEcode TmThreadWaitOnThreadRunning | ( | void | ) |
Waits for all threads to be in a running state.
| TM_ECODE_OK | if all are running or error if a thread failed |
Definition at line 1909 of file tm-threads.c.
References TVT_MAX.
Referenced by SuricataPostInit().

| int in_use |
bool to indicate this is in use
Definition at line 2153 of file tm-threads.c.
| const char* name |
Definition at line 2151 of file tm-threads.c.
Referenced by TmThreadCreate(), TmThreadCreateCmdThreadByName(), TmThreadCreateMgmtThread(), TmThreadCreateMgmtThreadByName(), and TmThreadCreatePacketHandler().
| SCSpinlock spin |
Definition at line 2159 of file tm-threads.c.
| SCTime_t sys_sec_stamp |
timestamp in real system time when the pktts was last updated.
Definition at line 2157 of file tm-threads.c.
| Threads |
Definition at line 2155 of file tm-threads.c.
| ThreadVars* tv |
threadvars structure
Definition at line 2150 of file tm-threads.c.
Referenced by SCTmThreadsSlotPacketLoopFinish(), TmSlotSetFuncAppend(), TmThreadAppend(), TmThreadCheckThreadState(), TmThreadClearThreadsFamily(), TmThreadContinue(), TmThreadContinueThreads(), TmThreadCountThreadsByTmmFlags(), TmThreadCreate(), TmThreadCreateCmdThreadByName(), TmThreadCreateMgmtThread(), TmThreadCreateMgmtThreadByName(), TmThreadCreatePacketHandler(), TmThreadDisableReceiveThreads(), TmThreadInitMC(), TmThreadKillThreadsFamily(), TmThreadLibSpawn(), TmThreadsCheckFlag(), TmThreadSetCPU(), TmThreadSetCPUAffinity(), TmThreadSetPrio(), TmThreadSetThreadPriority(), TmThreadSetupOptions(), TmThreadSpawn(), TmThreadsSetFlag(), TmThreadsSlotVarRun(), TmThreadsUnsetFlag(), TmThreadsWaitForUnpause(), TmThreadTimeoutLoop(), TmThreadWaitForFlag(), and TmThreadWaitOnThreadInit().
| ThreadVars* tv_root[TVT_MAX] = { NULL } |
Definition at line 83 of file tm-threads.c.
Referenced by FlowDisableFlowManagerThread(), TmThreadAppend(), TmThreadCheckThreadState(), TmThreadClearThreadsFamily(), TmThreadContinueDetectLoaderThreads(), TmThreadContinueThreads(), TmThreadCountThreadsByTmmFlags(), TmThreadDisableReceiveThreads(), TmThreadKillThreadsFamily(), and TmThreadWaitOnThreadInit().
| SCMutex tv_root_lock = SCMUTEX_INITIALIZER |
Definition at line 86 of file tm-threads.c.
Referenced by FlowDisableFlowManagerThread(), TmThreadAppend(), TmThreadCheckThreadState(), TmThreadClearThreadsFamily(), TmThreadContinueDetectLoaderThreads(), TmThreadContinueThreads(), TmThreadCountThreadsByTmmFlags(), TmThreadDisableReceiveThreads(), TmThreadKillThreadsFamily(), and TmThreadWaitOnThreadInit().
| int type |
Definition at line 2152 of file tm-threads.c.
Referenced by TmThreadAppend(), TmThreadGetNbThreads(), and TmThreadSetCPU().