Go to the documentation of this file.
41 static void WorkerFlushLogs(
void)
48 if (no_of_detect_tvs == 0) {
53 void *fw_threads[no_of_detect_tvs];
55 memset(fw_threads, 0x00, (no_of_detect_tvs *
sizeof(
void *)));
56 memset(detect_tvs, 0x00, (no_of_detect_tvs *
sizeof(
ThreadVars *)));
89 BUG_ON(i != no_of_detect_tvs);
93 SCLogDebug(
"Creating flush pseudo packets for %d threads", no_of_detect_tvs);
96 uint32_t threads_done = 0;
98 for (i = 0; i < no_of_detect_tvs; i++) {
100 threads_done = no_of_detect_tvs;
105 SCLogDebug(
"thread slot %d has ack'd flush request", i);
107 }
else if (detect_tvs[i]) {
108 SCLogDebug(
"thread slot %d not yet ack'd flush request", i);
109 TmThreadsCaptureBreakLoop(detect_tvs[i]);
112 if (threads_done < no_of_detect_tvs) {
122 static int OutputFlushInterval(
void)
124 intmax_t output_flush_interval = 0;
125 if (
ConfGetInt(
"heartbeat.output-flush-interval", &output_flush_interval) == 0) {
126 output_flush_interval = 0;
128 if (output_flush_interval < 0 || output_flush_interval > 60) {
129 SCLogConfig(
"flush_interval must be 0 or less than 60; using 0");
130 output_flush_interval = 0;
133 return (
int)output_flush_interval;
136 static void *LogFlusherWakeupThread(
void *arg)
138 int output_flush_interval = OutputFlushInterval();
140 BUG_ON(output_flush_interval == 0);
142 SCLogConfig(
"Using output-flush-interval of %d seconds", output_flush_interval);
148 const int log_flush_sleep_time = 500;
149 const int flush_wait_count = (1000 * output_flush_interval) / log_flush_sleep_time;
164 uint64_t worker_flush_count = 0;
167 usleep(log_flush_sleep_time * 1000);
169 if (++wait_count == flush_wait_count) {
170 worker_flush_count++;
183 SCLogInfo(
"%s: initiated %" PRIu64
" flushes", tv_local->
name, worker_flush_count);
189 if (0 == OutputFlushInterval()) {
190 SCLogConfig(
"log flusher thread not used with heartbeat.output-flush-interval of 0");
197 FatalError(
"Unable to create and start log flush thread");
int ConfGetInt(const char *name, intmax_t *val)
Retrieve a configuration value as an integer.
TmEcode TmThreadSpawn(ThreadVars *tv)
Spawns a thread associated with the ThreadVars instance tv.
TmEcode TmThreadSetupOptions(ThreadVars *tv)
Set the thread options (cpu affinitythread). Priority should be already set by pthread_create.
void TmThreadsSetFlag(ThreadVars *tv, uint32_t flag)
Set a thread flag.
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...
#define TM_FLAG_DETECT_TM
#define SCSetThreadName(n)
uint32_t TmThreadCountThreadsByTmmFlags(uint8_t flags)
returns a count of all the threads that match the flag
ThreadVars * tv_root[TVT_MAX]
struct TmSlot_ * tm_slots
#define SCMutexUnlock(mut)
Per thread variable structure.
struct ThreadVars_ * next
bool FlowWorkerGetFlushAck(void *flow_worker)
TmModule * TmModuleGetById(int id)
Returns a TM Module by its id.
uint8_t thread_setup_flags
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...
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
void LogFlushThreads(void)
void * FlowWorkerGetThreadData(void *flow_worker)
const char * thread_name_heartbeat
bool TmThreadsWaitForUnpause(ThreadVars *tv)
Wait for a thread to become unpaused.
void FlowWorkerSetFlushAck(void *flow_worker)
struct SCLogConfig_ SCLogConfig
Holds the config state used by the logging api.
void InjectPacketsForFlush(ThreadVars **detect_tvs, int no_of_detect_tvs)
struct TmSlot_ * slot_next
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
int TmThreadsCheckFlag(ThreadVars *tv, uint32_t flag)
Check if a thread flag is set.
volatile uint8_t suricata_ctl_flags