suricata
tm-threads.h File Reference
#include "tmqh-packetpool.h"
#include "tm-threads-common.h"
#include "tm-modules.h"
Include dependency graph for tm-threads.h:

Go to the source code of this file.

Data Structures

struct  TmSlot_
 

Macros

#define SleepUsec(usec)   usleep((usec))
 
#define SleepMsec(msec)   usleep((msec) * 1000)
 
#define TM_QUEUE_NAME_MAX   16
 
#define TM_THREAD_NAME_MAX   16
 

Typedefs

typedef TmEcode(* TmSlotFunc) (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *)
 
typedef struct TmSlot_ TmSlot
 

Functions

void TmSlotSetFuncAppend (ThreadVars *, TmModule *, const void *)
 Appends a new entry to the slots. More...
 
TmSlotTmSlotGetSlotForTM (int)
 Returns the slot holding a TM with the particular tm_id. More...
 
ThreadVarsTmThreadCreate (const char *, const char *, const char *, const char *, const char *, const char *, void *(fn_p)(void *), int)
 
ThreadVarsTmThreadCreatePacketHandler (const char *, const char *, const char *, const char *, const char *, const char *)
 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...
 
ThreadVarsTmThreadCreateMgmtThread (const char *name, void *(fn_p)(void *), int)
 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...
 
ThreadVarsTmThreadCreateMgmtThreadByName (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...
 
ThreadVarsTmThreadCreateCmdThreadByName (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...
 
TmEcode TmThreadSpawn (ThreadVars *)
 Spawns a thread associated with the ThreadVars instance tv. More...
 
void TmThreadSetFlags (ThreadVars *, uint8_t)
 
void TmThreadKillThreadsFamily (int family)
 
void TmThreadKillThreads (void)
 
void TmThreadClearThreadsFamily (int family)
 
void TmThreadAppend (ThreadVars *, int)
 Appends this TV to tv_root based on its type. More...
 
void TmThreadRemove (ThreadVars *, int)
 Removes this TV from tv_root based on its type. More...
 
void TmThreadSetGroupName (ThreadVars *tv, const char *name)
 
void TmThreadDumpThreads (void)
 
TmEcode TmThreadSetCPUAffinity (ThreadVars *, uint16_t)
 Set the thread options (cpu affinity). More...
 
TmEcode TmThreadSetThreadPriority (ThreadVars *, int)
 Set the thread options (thread priority). More...
 
TmEcode TmThreadSetCPU (ThreadVars *, uint8_t)
 
TmEcode TmThreadSetupOptions (ThreadVars *)
 Set the thread options (cpu affinitythread). Priority should be already set by pthread_create. More...
 
void TmThreadSetPrio (ThreadVars *)
 Adjusting nice value for threads. More...
 
int TmThreadGetNbThreads (uint8_t type)
 
void TmThreadInitMC (ThreadVars *)
 Sets the thread flags for a thread instance(tv) More...
 
void TmThreadTestThreadUnPaused (ThreadVars *)
 Tests if the thread represented in the arg has been unpaused or not. More...
 
void TmThreadContinue (ThreadVars *)
 Unpauses a thread. More...
 
void TmThreadContinueThreads (void)
 Unpauses all threads present in tv_root. More...
 
void TmThreadPause (ThreadVars *)
 Pauses a thread. More...
 
void TmThreadPauseThreads (void)
 Pauses 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...
 
ThreadVarsTmThreadsGetCallingThread (void)
 Returns the TV for the calling thread. More...
 
int TmThreadsCheckFlag (ThreadVars *, uint16_t)
 Check if a thread flag is set. More...
 
void TmThreadsSetFlag (ThreadVars *, uint16_t)
 Set a thread flag. More...
 
void TmThreadsUnsetFlag (ThreadVars *, uint16_t)
 Unset a thread flag. More...
 
void TmThreadWaitForFlag (ThreadVars *, uint16_t)
 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...
 
TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot)
 Separate run function so we can call it recursively. More...
 
ThreadVarsTmThreadsGetTVContainingSlot (TmSlot *)
 
void TmThreadDisablePacketThreads (void)
 Disable all threads having the specified TMs. More...
 
void TmThreadDisableReceiveThreads (void)
 Disable all threads having the specified TMs. More...
 
TmSlotTmThreadGetFirstTmSlotForPartialPattern (const char *)
 
uint32_t TmThreadCountThreadsByTmmFlags (uint8_t flags)
 returns a count of all the threads that match the flag More...
 
void TmThreadsListThreads (void)
 
int TmThreadsRegisterThread (ThreadVars *tv, const int type)
 
void TmThreadsUnregisterThread (const int id)
 
int TmThreadsInjectPacketsById (Packet **, int id)
 
void TmThreadsSetThreadTimestamp (const int id, const struct timeval *ts)
 
void TmreadsGetMinimalTimestamp (struct timeval *ts)
 

Variables

ThreadVarstv_root [TVT_MAX]
 
SCMutex tv_root_lock
 

Detailed Description

Macro Definition Documentation

#define SleepMsec (   msec)    usleep((msec) * 1000)
#define SleepUsec (   usec)    usleep((usec))

Typedef Documentation

typedef struct TmSlot_ TmSlot
typedef TmEcode(* TmSlotFunc) (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *)

Definition at line 50 of file tm-threads.h.

Function Documentation

void TmreadsGetMinimalTimestamp ( struct timeval *  ts)

Definition at line 2402 of file tm-threads.c.

References COPY_TIMESTAMP, Thread_::in_use, SCLogDebug, SCMutexLock, SCMutexUnlock, Threads_::threads, Threads_::threads_size, and Thread_::ts.

Referenced by TimeGet().

Here is the caller graph for this function:

TmSlot* TmSlotGetSlotForTM ( int  tm_id)

Returns the slot holding a TM with the particular tm_id.

Parameters
tm_idTM id of the TM whose slot has to be returned.
Return values
slotsPointer to the slot.

Definition at line 881 of file tm-threads.c.

References ThreadVars_::next, SCGetThreadIdLong, SCLogDebug, SCMutexLock, SCMutexUnlock, TmSlot_::slot_next, TmSlot_::tm_id, ThreadVars_::tm_slots, tv_root_lock, and TVT_MAX.

void TmThreadAppend ( ThreadVars tv,
int  type 
)

Appends this TV to tv_root based on its type.

Parameters
typeholds the type this TV belongs to.

Definition at line 1358 of file tm-threads.c.

References ThreadVars_::next, ThreadVars_::prev, SCMutexLock, SCMutexUnlock, tv_root_lock, and type.

Referenced by TmThreadSpawn().

Here is the caller graph for this function:

void TmThreadCheckThreadState ( void  )

Used to check the thread for certain conditions of failure.

Definition at line 2071 of file tm-threads.c.

References FatalError, ThreadVars_::name, ThreadVars_::next, SC_ERR_FATAL, SCMutexLock, SCMutexUnlock, THV_FAILED, TmThreadsCheckFlag(), tv_root_lock, and TVT_MAX.

Referenced by PostRunDeinit().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadClearThreadsFamily ( int  family)

Definition at line 1850 of file tm-threads.c.

References ThreadVars_::next, SCMutexLock, SCMutexUnlock, tv_root_lock, and TVT_MAX.

Referenced by PostRunDeinit().

Here is the caller graph for this function:

void TmThreadContinue ( ThreadVars tv)

Unpauses a thread.

Parameters
tvPointer to a TV instance that has to be unpaused

Definition at line 2005 of file tm-threads.c.

References THV_PAUSE, and TmThreadsUnsetFlag().

Referenced by TmThreadContinueDetectLoaderThreads(), and TmThreadContinueThreads().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadContinueThreads ( void  )

Unpauses all threads present in tv_root.

Definition at line 2015 of file tm-threads.c.

References ThreadVars_::next, SCMutexLock, SCMutexUnlock, TmThreadContinue(), tv_root_lock, and TVT_MAX.

Referenced by main(), and RunModeUnixSocketGetDefaultMode().

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t TmThreadCountThreadsByTmmFlags ( uint8_t  flags)
ThreadVars* TmThreadCreate ( const char *  ,
const char *  ,
const char *  ,
const char *  ,
const char *  ,
const char *  ,
void *  fn_p)(void *,
int   
)
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.

Parameters
nameName of this TV instance
moduleName of TmModule with COMMAND flag set.
mucondFlag to indicate whether to initialize the condition and the mutex variables for this newly created TV.
Return values
thenewly created TV instance, or NULL on error

Definition at line 1332 of file tm-threads.c.

References ThreadVars_::id, m, MANAGEMENT_CPU_SET, TmModuleGetByName(), TmSlotSetFuncAppend(), TmThreadCreate(), TmThreadSetCPU(), TmThreadsRegisterThread(), TVT_CMD, and ThreadVars_::type.

Referenced by DetectLoaderThreadSpawn().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
nameName of this TV instance
fn_pPointer to function when "slots" is of type "custom"
mucondFlag to indicate whether to initialize the condition and the mutex variables for this newly created TV.
Return values
thenewly created TV instance, or NULL on error

Definition at line 1271 of file tm-threads.c.

References ThreadVars_::id, MANAGEMENT_CPU_SET, TmThreadCreate(), TmThreadSetCPU(), TmThreadsRegisterThread(), TVT_MGMT, and ThreadVars_::type.

Referenced by StatsSpawnThreads().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
nameName of this TV instance
moduleName of TmModule with MANAGEMENT flag set.
mucondFlag to indicate whether to initialize the condition and the mutex variables for this newly created TV.
Return values
thenewly created TV instance, or NULL on error

Definition at line 1299 of file tm-threads.c.

References ThreadVars_::id, m, MANAGEMENT_CPU_SET, TmModuleGetByName(), TmSlotSetFuncAppend(), TmThreadCreate(), TmThreadSetCPU(), TmThreadsRegisterThread(), TVT_MGMT, and ThreadVars_::type.

Referenced by BypassedFlowManagerThreadSpawn(), FlowManagerThreadSpawn(), and FlowRecyclerThreadSpawn().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
nameName of this TV instance
inq_nameIncoming queue name
inqh_nameIncoming queue handler name as set by TmqhSetup()
outq_nameOutgoing queue name
outqh_nameOutgoing queue handler as set by TmqhSetup()
slotsString representation for the slot function to be used
Return values
thenewly created TV instance, or NULL on error

Definition at line 1241 of file tm-threads.c.

References ThreadVars_::id, TmThreadCreate(), TmThreadsRegisterThread(), TVT_PPT, and ThreadVars_::type.

Referenced by RunModeErfFileAutoFp(), RunModeErfFileSingle(), RunModeFilePcapAutoFp(), RunModeFilePcapSingle(), RunModeSetIPSAutoFp(), RunModeSetIPSWorker(), and RunModeSetLiveCaptureAutoFp().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadDisablePacketThreads ( void  )

Disable all threads having the specified TMs.

Definition at line 1671 of file tm-threads.c.

References PacketQueue_::cond_q, FatalError, Tmq_::id, ThreadVars_::inq, ThreadVars_::name, ThreadVars_::next, Tmq_::reader_cnt, SC_ERR_FATAL, SCCondSignal, SCLogDebug, SCMutexLock, SCMutexUnlock, SleepMsec, THV_KILL, THV_RUNNING_DONE, TmThreadsCheckFlag(), TmThreadsSetFlag(), trans_q, tv_root_lock, TVT_PPT, and Tmq_::writer_cnt.

Referenced by PostRunDeinit().

Here is the call graph for this function:

Here is the caller graph for this function:

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 1566 of file tm-threads.c.

References PacketQueue_::cond_q, FatalError, TmModule_::flags, Tmq_::id, ThreadVars_::inq, ThreadVars_::name, ThreadVars_::next, TmModule_::PktAcqBreakLoop, Tmq_::reader_cnt, SC_ATOMIC_GET, SC_ERR_FATAL, SCCondSignal, SCLogDebug, SCMutexLock, SCMutexUnlock, SleepMsec, TmSlot_::slot_next, THV_FLOW_LOOP, THV_KILL_PKTACQ, TM_FLAG_RECEIVE_TM, TmSlot_::tm_id, ThreadVars_::tm_slots, TmModuleGetById(), TmThreadDumpThreads(), TmThreadsCheckFlag(), TmThreadsSetFlag(), trans_q, tv_root_lock, TVT_PPT, and Tmq_::writer_cnt.

Referenced by PostRunDeinit().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadDumpThreads ( void  )
TmSlot* TmThreadGetFirstTmSlotForPartialPattern ( const char *  )

Definition at line 1727 of file tm-threads.c.

References TmModule_::name, ThreadVars_::next, SCMutexLock, SCMutexUnlock, TmSlot_::slot_next, TmSlot_::tm_id, ThreadVars_::tm_slots, TmModuleGetById(), tv_root_lock, and TVT_PPT.

Here is the call graph for this function:

int TmThreadGetNbThreads ( uint8_t  type)
void TmThreadInitMC ( ThreadVars tv)

Sets the thread flags for a thread instance(tv)

Parameters
tvPointer to the thread instance for which the flag has to be set
flagsHolds the thread state this thread instance has to be set to 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.

Parameters
tvPointer to a TV instance

Definition at line 1924 of file tm-threads.c.

References ThreadVars_::ctrl_cond, ThreadVars_::ctrl_mutex, SC_ERR_FATAL, SCCtrlCondDestroy, SCCtrlCondInit, SCCtrlMutexDestroy, SCCtrlMutexInit, SCFree, SCLogError, and SCMalloc.

Referenced by TmThreadCreate().

Here is the caller graph for this function:

void TmThreadKillThreads ( void  )

Definition at line 1789 of file tm-threads.c.

References ThreadVars_::id, ThreadVars_::name, ThreadVars_::printable_name, SCFree, SCLogDebug, TmSlot_::slot_next, StatsThreadCleanup(), ThreadVars_::thread_group_name, ThreadVars_::tm_slots, TmThreadKillThreadsFamily(), TmThreadsUnregisterThread(), and TVT_MAX.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadKillThreadsFamily ( int  family)

Definition at line 1760 of file tm-threads.c.

References BUG_ON, MAX_WAIT_TIME, MIN, MIN_WAIT_TIME, ThreadVars_::next, SCMutexLock, SCMutexUnlock, SleepUsec, tv_root_lock, and TVT_MAX.

Referenced by PostRunDeinit(), and TmThreadKillThreads().

Here is the caller graph for this function:

void TmThreadPause ( ThreadVars tv)

Pauses a thread.

Parameters
tvPointer to a TV instance that has to be paused

Definition at line 2038 of file tm-threads.c.

References THV_PAUSE, and TmThreadsSetFlag().

Referenced by TmThreadPauseThreads().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadPauseThreads ( void  )

Pauses all threads present in tv_root.

Definition at line 2048 of file tm-threads.c.

References ThreadVars_::next, SCMutexLock, SCMutexUnlock, TmThreadPause(), TmThreadsListThreads(), tv_root_lock, and TVT_MAX.

Here is the call graph for this function:

int TmThreadsCheckFlag ( ThreadVars tv,
uint16_t  flag 
)
TmEcode TmThreadSetCPUAffinity ( ThreadVars tv,
uint16_t  cpu 
)

Set the thread options (cpu affinity).

Parameters
tvpointer to the ThreadVars to setup the affinity.
cpucpu on which affinity is set.
Return values
TM_ECODE_OK

Definition at line 1020 of file tm-threads.c.

References ThreadVars_::cpu_affinity, THREAD_SET_AFFINITY, ThreadVars_::thread_setup_flags, and TM_ECODE_OK.

Referenced by RunModeErfFileAutoFp().

Here is the caller graph for this function:

void TmThreadSetFlags ( ThreadVars ,
uint8_t   
)

Referenced by TmThreadSpawn().

Here is the caller graph for this function:

void TmThreadSetGroupName ( ThreadVars tv,
const char *  name 
)

Definition at line 1832 of file tm-threads.c.

References SC_ERR_RUNMODE, SCLogError, SCStrdup, ThreadVars_::thread_group_name, and unlikely.

Referenced by RunModeErfFileAutoFp(), RunModeFilePcapAutoFp(), RunModeSetIPSAutoFp(), and RunModeSetLiveCaptureAutoFp().

Here is the caller graph for this function:

void TmThreadSetPrio ( ThreadVars )

Adjusting nice value for threads.

Definition at line 984 of file tm-threads.c.

References ThreadVars_::name, SC_ERR_THREAD_NICE_PRIO, SCEnter, SCLogDebug, SCLogError, SCReturn, and ThreadVars_::thread_priority.

Referenced by TmThreadSetupOptions().

Here is the caller graph for this function:

TmEcode TmThreadSetThreadPriority ( ThreadVars tv,
int  prio 
)

Set the thread options (thread priority).

Parameters
tvPointer to the ThreadVars to setup the thread priority.
Return values
TM_ECODE_OK.

Definition at line 973 of file tm-threads.c.

References ThreadVars_::thread_priority, THREAD_SET_PRIORITY, ThreadVars_::thread_setup_flags, and TM_ECODE_OK.

Referenced by RunModeErfFileAutoFp().

Here is the caller graph for this function:

TmEcode TmThreadSetupOptions ( ThreadVars tv)

Set the thread options (cpu affinitythread). Priority should be already set by pthread_create.

Parameters
tvpointer to the ThreadVars of the calling thread.

Definition at line 1061 of file tm-threads.c.

References AffinityGetNextCPU(), ThreadVars_::cpu_affinity, ThreadsAffinityType_::cpu_set, EXCLUSIVE_AFFINITY, ThreadsAffinityType_::hiprio_cpu, ThreadsAffinityType_::lowprio_cpu, ThreadsAffinityType_::medprio_cpu, ThreadsAffinityType_::mode_flag, ThreadVars_::name, ThreadsAffinityType_::prio, PRIO_HIGH, PRIO_LOW, PRIO_MEDIUM, SCGetThreadIdLong, SCLogPerf, thread_affinity, ThreadVars_::thread_priority, THREAD_SET_AFFINITY, THREAD_SET_AFFTYPE, THREAD_SET_PRIORITY, ThreadVars_::thread_setup_flags, TM_ECODE_OK, and TmThreadSetPrio().

Referenced by StatsSetUI64(), and TmThreadsSlotVarRun().

Here is the call graph for this function:

Here is the caller graph for this function:

ThreadVars* TmThreadsGetCallingThread ( void  )

Returns the TV for the calling thread.

Return values
tvPointer to the ThreadVars instance for the calling thread; NULL on no match

Definition at line 2176 of file tm-threads.c.

References ThreadVars_::next, SCMutexLock, SCMutexUnlock, ThreadVars_::t, tv_root_lock, and TVT_MAX.

ThreadVars* TmThreadsGetTVContainingSlot ( TmSlot )
int TmThreadsInjectPacketsById ( Packet **  packets,
const int  id 
)
Return values
r1 if packet was accepted, 0 otherwise
Note
if packet was not accepted, it's still the responsibility of the caller.

Definition at line 2438 of file tm-threads.c.

References PacketQueue_::cond_q, Tmq_::id, ThreadVars_::inq, PacketQueue_::mutex_q, PacketEnqueue(), SCCondSignal, SCMutexLock, SCMutexUnlock, ThreadVars_::stream_pq, Threads_::threads, Threads_::threads_size, trans_q, and Thread_::tv.

Referenced by FlowForceReassemblyForFlow().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadsListThreads ( void  )
TmEcode TmThreadSpawn ( ThreadVars tv)
int TmThreadsRegisterThread ( ThreadVars tv,
const int  type 
)
void TmThreadsSetThreadTimestamp ( const int  id,
const struct timeval *  ts 
)

Definition at line 2386 of file tm-threads.c.

References SCMutexLock, SCMutexUnlock, Threads_::threads, Threads_::threads_size, Thread_::ts, and unlikely.

Referenced by TimeSetByThread().

Here is the caller graph for this function:

TmEcode TmThreadsSlotVarRun ( ThreadVars tv,
Packet p,
TmSlot slot 
)

Separate run function so we can call it recursively.

Todo:
Deal with post_pq for slots beyond the first.

Definition at line 115 of file tm-threads.c.

References BUG_ON, EngineDone(), Tmq_::id, TmSlot_::id, ThreadVars_::inq, PacketQueue_::len, len, likely, TmSlot_::Management, PacketQueue_::mutex_q, ThreadVars_::name, Packet_::next, PACKET_PROFILING_TMM_END, PACKET_PROFILING_TMM_START, PacketDequeue(), PacketPoolDestroy(), PacketPoolInit(), PacketPoolInitEmpty(), TmSlot_::PktAcqLoop, PktSrcToString(), SC_ATOMIC_GET, SC_ATOMIC_SET, SC_ERR_FATAL, SC_ERR_THREAD_INIT, SCDropCaps, SCLogDebug, SCLogError, SCLogNotice, SCLogWarning, SCMutexInit, SCMutexLock, SCMutexUnlock, SCSetThreadName, SleepUsec, TmSlot_::slot_initdata, TmSlot_::slot_next, TmSlot_::slot_post_pq, TmSlot_::slot_pre_pq, TmSlot_::SlotThreadDeinit, TmSlot_::SlotThreadExitPrintStats, TmSlot_::SlotThreadInit, StatsSetupPrivate(), StatsSyncCounters, ThreadVars_::stream_pq, suricata_ctl_flags, ThreadVars_::thread_setup_flags, THV_CLOSED, THV_DEINIT, THV_FAILED, THV_FLOW_LOOP, THV_INIT_DONE, THV_KILL, THV_KILL_PKTACQ, THV_PAUSE, THV_PAUSED, THV_RUNNING_DONE, TM_ECODE_DONE, TM_ECODE_FAILED, TM_ECODE_OK, ThreadVars_::tm_func, TmSlot_::tm_id, ThreadVars_::tm_slots, TMM_FLOWWORKER, ThreadVars_::tmqh_in, ThreadVars_::tmqh_out, TmqhOutputPacketpool(), TmqhReleasePacketsToPacketPool(), TmThreadDumpThreads(), TmThreadsCheckFlag(), TmThreadSetupOptions(), TmThreadsSetFlag(), TmThreadsSlotVarRun(), TmThreadsUnsetFlag(), TmThreadTestThreadUnPaused(), TmThreadWaitForFlag(), PacketQueue_::top, trans_q, and unlikely.

Referenced by TmThreadsSlotVarRun().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadsUnregisterThread ( const int  id)

Definition at line 2353 of file tm-threads.c.

References Thread_::in_use, SCFree, SCMutexLock, SCMutexUnlock, Threads_::threads, Threads_::threads_cnt, and Threads_::threads_size.

Referenced by TmThreadKillThreads().

Here is the caller graph for this function:

void TmThreadsUnsetFlag ( ThreadVars ,
uint16_t   
)

Unset a thread flag.

Definition at line 105 of file tm-threads.c.

References SC_ATOMIC_AND.

Referenced by StatsSetUI64(), TmThreadContinue(), and TmThreadsSlotVarRun().

Here is the caller graph for this function:

void TmThreadTestThreadUnPaused ( ThreadVars tv)

Tests if the thread represented in the arg has been unpaused or not.

The function would return if the thread tv has been unpaused or if the kill flag for the thread has been set.

Parameters
tvPointer to the TV instance.

Definition at line 1973 of file tm-threads.c.

References SleepUsec, THV_KILL, THV_PAUSE, and TmThreadsCheckFlag().

Referenced by StatsSetUI64(), and TmThreadsSlotVarRun().

Here is the call graph for this function:

Here is the caller graph for this function:

void TmThreadWaitForFlag ( ThreadVars tv,
uint16_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.

Parameters
tvPointer to the TV instance.

Definition at line 1991 of file tm-threads.c.

References SleepUsec, and TmThreadsCheckFlag().

Referenced by NapatechGetStreamConfig(), StatsSetUI64(), TmThreadSpawn(), and TmThreadsSlotVarRun().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Return values
TM_ECODE_OKall initialized properly
TM_ECODE_FAILEDfailure

Definition at line 2099 of file tm-threads.c.

References ThreadVars_::name, ThreadVars_::next, SC_ATOMIC_GET, SC_ERR_THREAD_INIT, SCLogError, SCLogNotice, SCMutexLock, SCMutexUnlock, SleepUsec, THV_CLOSED, THV_DEAD, THV_FAILED, THV_INIT_DONE, TM_ECODE_FAILED, TM_ECODE_OK, TmThreadsCheckFlag(), tv_root_lock, TVT_MAX, TVT_MGMT, and TVT_PPT.

Referenced by main(), and RunModeUnixSocketGetDefaultMode().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation