* rule reloads even if no packets are read by the capture method. */
#define THV_CAPTURE_INJECT_PKT (1<<11)
-/** Thread flags set and read by threads, to control the threads, when they
- * encounter certain conditions like failure */
-#define THV_RESTART_THREAD 0x01 /** restart the thread */
-#define THV_ENGINE_EXIT 0x02 /** shut the engine down gracefully */
-
-/** Maximum no of times a thread can be restarted */
-#define THV_MAX_RESTARTS 50
-
/** \brief Per thread variable structure */
typedef struct ThreadVars_ {
pthread_t t;
SC_ATOMIC_DECLARE(unsigned int, flags);
- /** aof(action on failure) determines what should be done with the thread
- when it encounters certain conditions like failures */
- uint8_t aof;
-
- /** no of times the thread has been restarted on failure */
- uint8_t restarted;
-
/** TmModule::flags for each module part of this thread */
uint8_t tmm_flags;
/* lock to protect tv_root */
SCMutex tv_root_lock = SCMUTEX_INITIALIZER;
-/* Action On Failure(AOF). Determines how the engine should behave when a
- * thread encounters a failure. Defaults to restart the failed thread */
-uint8_t tv_aof = THV_RESTART_THREAD;
-
/**
* \brief Check if a thread flag is set.
*
/* default state for every newly created thread */
TmThreadsSetFlag(tv, THV_PAUSE);
TmThreadsSetFlag(tv, THV_USE);
- /* default aof for every newly created thread */
- tv->aof = THV_RESTART_THREAD;
/* set the incoming queue */
if (inq_name != NULL && strcmp(inq_name, "packetpool") != 0) {
return;
}
#endif
-/**
- * \brief Sets the aof(Action on failure) for a thread instance(tv)
- *
- * \param tv Pointer to the thread instance for which the aof has to be set
- * \param aof Holds the aof this thread instance has to be set to
- */
-void TmThreadSetAOF(ThreadVars *tv, uint8_t aof)
-{
- if (tv != NULL)
- tv->aof = aof;
-
- return;
-}
/**
* \brief Initializes the mutex and condition variables for this TV
}
/**
- * \brief Restarts the thread sent as the argument
- *
- * \param tv Pointer to the thread instance(tv) to be restarted
- */
-static void TmThreadRestartThread(ThreadVars *tv)
-{
- if (tv->restarted >= THV_MAX_RESTARTS) {
- SCLogError(SC_ERR_TM_THREADS_ERROR,"thread restarts exceeded "
- "threshold limit for thread \"%s\"", tv->name);
- exit(EXIT_FAILURE);
- }
-
- TmThreadsUnsetFlag(tv, THV_CLOSED);
- TmThreadsUnsetFlag(tv, THV_FAILED);
-
- if (TmThreadSpawn(tv) != TM_ECODE_OK) {
- SCLogError(SC_ERR_THREAD_SPAWN, "thread \"%s\" failed to spawn", tv->name);
- exit(EXIT_FAILURE);
- }
-
- tv->restarted++;
- SCLogInfo("thread \"%s\" restarted", tv->name);
-
- return;
-}
-
-/**
- * \brief Used to check the thread for certain conditions of failure. If the
- * thread has been specified to restart on failure, the thread is
- * restarted. If the thread has been specified to gracefully shutdown
- * the engine on failure, it does so. The global aof flag, tv_aof
- * overrides the thread aof flag, if it holds a THV_ENGINE_EXIT;
+ * \brief Used to check the thread for certain conditions of failure.
*/
void TmThreadCheckThreadState(void)
{
while (tv) {
if (TmThreadsCheckFlag(tv, THV_FAILED)) {
TmThreadsSetFlag(tv, THV_DEINIT);
- pthread_join(tv->t, NULL);
- if ((tv_aof & THV_ENGINE_EXIT) || (tv->aof & THV_ENGINE_EXIT)) {
- EngineKill();
- goto end;
- } else {
- /* if the engine kill-stop has been received by now, chuck
- * restarting and return to kill the engine */
- if ((suricata_ctl_flags & SURICATA_KILL) ||
- (suricata_ctl_flags & SURICATA_STOP)) {
- goto end;
- }
- TmThreadRestartThread(tv);
- }
+ EngineKill();
+ goto end;
}
tv = tv->next;
}