Go to the documentation of this file.
25 #ifndef SURICATA_TM_THREADS_H
26 #define SURICATA_TM_THREADS_H
34 static inline void SleepUsec(uint64_t usec)
42 #define SleepMsec(msec) Sleep((msec))
44 #define SleepUsec(usec) usleep((usec))
45 #define SleepMsec(msec) usleep((msec) * 1000)
48 #define TM_QUEUE_NAME_MAX 16
49 #define TM_THREAD_NAME_MAX 16
88 void *(fn_p)(
void *),
int);
163 static inline bool TmThreadsHandleInjectedPackets(
ThreadVars *
tv)
166 if (pq && pq->
len > 0) {
173 #ifdef DEBUG_VALIDATION
178 TmThreadsSlotProcessPktFail(
tv, extra_p);
201 TmThreadsSlotProcessPktFail(
tv, p);
207 TmThreadsHandleInjectedPackets(
tv);
242 TmThreadsCaptureInjectPacket(
tv, p);
246 if (TmThreadsHandleInjectedPackets(
tv) ==
false) {
249 TmThreadsCaptureInjectPacket(
tv, p);
261 static inline void TmThreadsCaptureBreakLoop(
ThreadVars *
tv)
ThreadVars * tv_root[TVT_MAX]
struct FlowQueue_ * flow_queue
void TmThreadsInitThreadsTimestamp(const SCTime_t ts)
void TmThreadSetPrio(ThreadVars *)
Adjusting nice value for threads.
void TmThreadContinue(ThreadVars *)
Unpauses a thread.
TmEcode TmThreadSetCPU(ThreadVars *, uint8_t)
bool TmThreadsWaitForUnpause(ThreadVars *tv)
Wait for a thread to become unpaused.
void TmThreadsListThreads(void)
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
@ PKT_SRC_CAPTURE_TIMEOUT
TmEcode TmThreadsSlotVarRun(ThreadVars *tv, Packet *p, TmSlot *slot)
Separate run function so we can call it recursively.
void TmThreadsInjectFlowById(Flow *f, const int id)
inject a flow into a threads flow queue
void TmThreadKillThreadsFamily(int family)
struct PacketQueue_ * stream_pq_local
void TmThreadClearThreadsFamily(int family)
TmEcode TmThreadSpawn(ThreadVars *)
Spawns a thread associated with the ThreadVars instance tv.
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
TmEcode TmThreadsProcessDecodePseudoPackets(ThreadVars *tv, PacketQueueNoLock *decode_pq, TmSlot *slot)
simple fifo queue for packets
void TmqhReleasePacketsToPacketPool(PacketQueue *pq)
Release all the packets in the queue back to the packetpool. Mainly used by threads that have failed,...
uint16_t TmThreadsGetWorkerThreadMax(void)
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
void TmThreadsUnregisterThread(const int id)
#define PKT_SET_SRC(p, src_val)
void TmThreadDisablePacketThreads(void)
Disable all packet threads.
void TmThreadsGetMinimalTimestamp(struct timeval *ts)
void TmThreadsSetThreadTimestamp(const int id, const SCTime_t ts)
TmEcode(* PktAcqLoop)(ThreadVars *, void *, void *)
TmEcode(* PktAcqBreakLoop)(ThreadVars *, void *)
struct TmSlot_ * tm_slots
Packet * PacketDequeueNoLock(PacketQueueNoLock *qnl)
TmEcode(* Management)(ThreadVars *, void *)
#define SCMutexUnlock(mut)
#define PKT_PSEUDO_STREAM_END
Per thread variable structure.
void TmThreadDisableReceiveThreads(void)
Disable all threads having the specified TMs.
void TmSlotSetFuncAppend(ThreadVars *, TmModule *, const void *)
Appends a new entry to the slots.
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 sl...
void TmThreadSetGroupName(ThreadVars *tv, const char *name)
void TmThreadsSetFlag(ThreadVars *, uint32_t)
Set a thread flag.
TmEcode TmThreadWaitOnThreadInit(void)
Used to check if all threads have finished their initialization. On finding an un-initialized thread,...
#define THV_CAPTURE_INJECT_PKT
ThreadVars * TmThreadCreate(const char *, const char *, const char *, const char *, const char *, const char *, void *(fn_p)(void *), int)
TmModule * TmModuleGetById(int id)
Returns a TM Module by its id.
int TmThreadGetNbThreads(uint8_t type)
#define TM_FLAG_RECEIVE_TM
int TmThreadsRegisterThread(ThreadVars *tv, const int type)
ThreadVars * TmThreadCreateMgmtThread(const char *name, void *(fn_p)(void *), int)
Creates and returns the TV instance for a Management thread(MGMT). This function supports only custom...
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...
void TmThreadKillThreads(void)
void TmThreadAppend(ThreadVars *, int)
Appends this TV to tv_root based on its type.
void(* tmqh_out)(struct ThreadVars_ *, struct Packet_ *)
struct TmSlot_ * tm_flowworker
void TmThreadInitMC(ThreadVars *)
Initializes the mutex and condition variables for this TV.
TmEcode(* SlotThreadInit)(ThreadVars *, const void *, void **)
void TmThreadWaitForFlag(ThreadVars *, uint32_t)
Waits till the specified flag(s) is(are) set. We don't bother if the kill flag has been set or not on...
const void * slot_initdata
Packet * PacketDequeue(PacketQueue *q)
TmEcode TmThreadSetCPUAffinity(ThreadVars *, uint16_t)
Set the thread options (cpu affinity).
TmEcode(* SlotThreadDeinit)(ThreadVars *, void *)
void(* SlotThreadExitPrintStats)(ThreadVars *, void *)
SC_ATOMIC_DECLARE(void *, slot_data)
PacketQueueNoLock decode_pq
void TmThreadCheckThreadState(void)
Used to check the thread for certain conditions of failure.
struct TmSlot_ * slot_next
int TmThreadsCheckFlag(ThreadVars *, uint32_t)
Check if a thread flag is set.
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
void TmThreadsUnsetFlag(ThreadVars *, uint32_t)
Unset a thread flag.
TmEcode TmThreadSetThreadPriority(ThreadVars *, int)
Set the thread options (thread priority).
TmEcode TmThreadWaitOnThreadRunning(void)
Waits for all threads to be in a running state.
TmEcode(* TmSlotFunc)(ThreadVars *, Packet *, void *)
void TmThreadContinueThreads(void)
Unpauses all threads present in tv_root.
Packet * PacketGetFromQueueOrAlloc(void)
Get a packet. We try to get a packet from the packetpool first, but if that is empty we alloc a packe...
TmEcode TmThreadSetupOptions(ThreadVars *)
Set the thread options (cpu affinitythread). Priority should be already set by pthread_create.
bool TmThreadsTimeSubsysIsReady(void)
uint32_t TmThreadCountThreadsByTmmFlags(uint8_t flags)
returns a count of all the threads that match the flag
ThreadVars * TmThreadCreatePacketHandler(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 custo...