Should fix crashes occuring from unix mode shutdown/cleanup phase.
/* main loop */
while(run) {
- TmThreadTestThreadUnPaused(tv);
+ if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
+ TmThreadsSetFlag(tv, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv);
+ TmThreadsUnsetFlag(tv, THV_PAUSED);
+ }
/* grab a msg, can return NULL on signals */
StreamMsg *smsg = StreamMsgGetFromQueue(stream_q);
TmThreadsSetFlag(tv_local, THV_INIT_DONE);
while (run) {
- TmThreadTestThreadUnPaused(tv_local);
+ if (TmThreadsCheckFlag(tv_local, THV_PAUSE)) {
+ TmThreadsSetFlag(tv_local, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv_local);
+ TmThreadsUnsetFlag(tv_local, THV_PAUSED);
+ }
cond_time.tv_sec = time(NULL) + sc_counter_tts;
cond_time.tv_nsec = 0;
TmThreadsSetFlag(tv_local, THV_INIT_DONE);
while (run) {
- TmThreadTestThreadUnPaused(tv_local);
+ if (TmThreadsCheckFlag(tv_local, THV_PAUSE)) {
+ TmThreadsSetFlag(tv_local, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv_local);
+ TmThreadsUnsetFlag(tv_local, THV_PAUSED);
+ }
cond_time.tv_sec = time(NULL) + SC_PERF_WUT_TTS;
cond_time.tv_nsec = 0;
TmThreadsSetFlag(th_v, THV_INIT_DONE);
while (1)
{
- TmThreadTestThreadUnPaused(th_v);
+ if (TmThreadsCheckFlag(th_v, THV_PAUSE)) {
+ TmThreadsSetFlag(th_v, THV_PAUSED);
+ TmThreadTestThreadUnPaused(th_v);
+ TmThreadsUnsetFlag(th_v, THV_PAUSED);
+ }
if (SC_ATOMIC_GET(flow_flags) & FLOW_EMERGENCY) {
emerg = TRUE;
while (q->len != 0) {
usleep(100);
}
+ TmThreadsSetFlag(tv, THV_PAUSE);
+ if (tv->inq->q_type == 0)
+ SCCondSignal(&trans_q[tv->inq->id].cond_q);
+ else
+ SCCondSignal(&data_queues[tv->inq->id].cond_q);
+ while (!TmThreadsCheckFlag(tv, THV_PAUSED)) {
+ if (tv->inq->q_type == 0)
+ SCCondSignal(&trans_q[tv->inq->id].cond_q);
+ else
+ SCCondSignal(&data_queues[tv->inq->id].cond_q);
+ usleep(100);
+ }
+ TmThreadsUnsetFlag(tv, THV_PAUSE);
}
}
tv = tv->next;
this->running = 0;
TmThreadKillThreadsFamily(TVT_MGMT);
TmThreadClearThreadsFamily(TVT_MGMT);
+ TmThreadDisableThreadsWithTMS(TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM);
FlowForceReassembly();
TmThreadKillThreadsFamily(TVT_PPT);
TmThreadClearThreadsFamily(TVT_PPT);
struct TmSlot_;
/** Thread flags set and read by threads to control the threads */
-#define THV_USE 0x01 /** thread is in use */
-#define THV_INIT_DONE 0x02 /** thread initialization done */
-#define THV_PAUSE 0x04 /** thread has been paused */
-#define THV_KILL 0x08 /** thread has been asked to cleanup and exit */
-#define THV_FAILED 0x10 /** thread has encountered an error and failed */
-#define THV_CLOSED 0x20 /** thread done, should be joinable */
+#define THV_USE 1 /** thread is in use */
+#define THV_INIT_DONE (1 << 1) /** thread initialization done */
+#define THV_PAUSE (1 << 2) /** signal thread to pause itself */
+#define THV_PAUSED (1 << 3) /** the thread is paused atm */
+#define THV_KILL (1 << 4) /** thread has been asked to cleanup and exit */
+#define THV_FAILED (1 << 5) /** thread has encountered an error and failed */
+#define THV_CLOSED (1 << 6) /** thread done, should be joinable */
/* used to indicate the thread is going through de-init. Introduced as more
* of a hack for solving stream-timeout-shutdown. Is set by the main thread. */
-#define THV_DEINIT 0x40
-#define THV_RUNNING_DONE 0x80 /** thread has completed running and is entering
- * the de-init phase */
+#define THV_DEINIT (1 << 7)
+#define THV_RUNNING_DONE (1 << 8) /** thread has completed running and is entering
+ * the de-init phase */
/** Thread flags set and read by threads, to control the threads, when they
* encounter certain conditions like failure */
char *name;
char *thread_group_name;
- SC_ATOMIC_DECLARE(unsigned char, flags);
+ SC_ATOMIC_DECLARE(unsigned short, flags);
/** aof(action on failure) determines what should be done with the thread
when it encounters certain conditions like failures */
* \retval 1 flag is set.
* \retval 0 flag is not set.
*/
-int TmThreadsCheckFlag(ThreadVars *tv, uint8_t flag)
+int TmThreadsCheckFlag(ThreadVars *tv, uint16_t flag)
{
return (SC_ATOMIC_GET(tv->flags) & flag) ? 1 : 0;
}
/**
* \brief Set a thread flag.
*/
-void TmThreadsSetFlag(ThreadVars *tv, uint8_t flag)
+void TmThreadsSetFlag(ThreadVars *tv, uint16_t flag)
{
SC_ATOMIC_OR(tv->flags, flag);
}
/**
* \brief Unset a thread flag.
*/
-void TmThreadsUnsetFlag(ThreadVars *tv, uint8_t flag)
+void TmThreadsUnsetFlag(ThreadVars *tv, uint16_t flag)
{
SC_ATOMIC_AND(tv->flags, ~flag);
}
TmThreadsSetFlag(tv, THV_INIT_DONE);
while (run) {
- TmThreadTestThreadUnPaused(tv);
+ if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
+ TmThreadsSetFlag(tv, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv);
+ TmThreadsUnsetFlag(tv, THV_PAUSED);
+ }
TmSlotFunc SlotFunc = SC_ATOMIC_GET(s->SlotFunc);
r = SlotFunc(tv, NULL, SC_ATOMIC_GET(s->slot_data), &s->slot_pre_pq, &s->slot_post_pq);
TmThreadsSetFlag(tv, THV_INIT_DONE);
while (run) {
- TmThreadTestThreadUnPaused(tv);
+ if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
+ TmThreadsSetFlag(tv, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv);
+ TmThreadsUnsetFlag(tv, THV_PAUSED);
+ }
TmSlotFunc SlotFunc = SC_ATOMIC_GET(s->SlotFunc);
p = tv->tmqh_in(tv);
while (run) {
TmSlotFunc SlotFunc = SC_ATOMIC_GET(s->SlotFunc);
- TmThreadTestThreadUnPaused(tv);
+ if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
+ TmThreadsSetFlag(tv, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv);
+ TmThreadsUnsetFlag(tv, THV_PAUSED);
+ }
r = SlotFunc(tv, NULL, SC_ATOMIC_GET(s->slot_data), /* no outqh, no pq */NULL, NULL);
TmThreadsSetFlag(tv, THV_INIT_DONE);
while (run) {
- TmThreadTestThreadUnPaused(tv);
+ if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
+ TmThreadsSetFlag(tv, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv);
+ TmThreadsUnsetFlag(tv, THV_PAUSED);
+ }
/* input a packet */
p = tv->tmqh_in(tv);
TmThreadsSetFlag(tv, THV_INIT_DONE);
while(run) {
- TmThreadTestThreadUnPaused(tv);
+ if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
+ TmThreadsSetFlag(tv, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv);
+ TmThreadsUnsetFlag(tv, THV_PAUSED);
+ }
r = s->PktAcqLoop(tv, SC_ATOMIC_GET(s->slot_data), s);
s = (TmSlot *)tv->tm_slots;
while (run) {
- TmThreadTestThreadUnPaused(tv);
+ if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
+ TmThreadsSetFlag(tv, THV_PAUSED);
+ TmThreadTestThreadUnPaused(tv);
+ TmThreadsUnsetFlag(tv, THV_PAUSED);
+ }
/* input a packet */
p = tv->tmqh_in(tv);
*
* \param tv Pointer to the TV instance.
*/
-void TmThreadWaitForFlag(ThreadVars *tv, uint8_t flags)
+void TmThreadWaitForFlag(ThreadVars *tv, uint16_t flags)
{
while (!TmThreadsCheckFlag(tv, flags)) {
usleep(100);
void TmThreadActivateDummySlot(void);
void TmThreadDeActivateDummySlot(void);
-int TmThreadsCheckFlag(ThreadVars *, uint8_t);
-void TmThreadsSetFlag(ThreadVars *, uint8_t);
-void TmThreadsUnsetFlag(ThreadVars *, uint8_t);
-void TmThreadWaitForFlag(ThreadVars *, uint8_t);
+int TmThreadsCheckFlag(ThreadVars *, uint16_t);
+void TmThreadsSetFlag(ThreadVars *, uint16_t);
+void TmThreadsUnsetFlag(ThreadVars *, uint16_t);
+void TmThreadWaitForFlag(ThreadVars *, uint16_t);
TmEcode TmThreadsSlotVarRun (ThreadVars *tv, Packet *p, TmSlot *slot);