]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threads: merge unpause test into wait for pause function
authorJason Ish <jason.ish@oisf.net>
Thu, 10 Oct 2024 22:53:12 +0000 (16:53 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 12 Oct 2024 09:03:39 +0000 (11:03 +0200)
TmThreadTestThreadUnPaused was only being used by
TmThreadsWaitForUnpause and is still enough to just become one
function.

src/tm-threads.c
src/tm-threads.h

index ba086498f1af93c8d9968b7449d53d87056af110..09bd040d71cc631a9b21a4515d99c3bfc0b4eda3 100644 (file)
@@ -358,11 +358,21 @@ error:
     return NULL;
 }
 
+/**
+ * Also returns if the kill flag is set.
+ */
 void TmThreadsWaitForUnpause(ThreadVars *tv)
 {
     if (TmThreadsCheckFlag(tv, THV_PAUSE)) {
         TmThreadsSetFlag(tv, THV_PAUSED);
-        TmThreadTestThreadUnPaused(tv);
+
+        while (TmThreadsCheckFlag(tv, THV_PAUSE)) {
+            SleepUsec(100);
+
+            if (TmThreadsCheckFlag(tv, THV_KILL))
+                break;
+        }
+
         TmThreadsUnsetFlag(tv, THV_PAUSED);
     }
 }
@@ -1737,24 +1747,6 @@ static void TmThreadDeinitMC(ThreadVars *tv)
     }
 }
 
-/**
- * \brief 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.
- *
- * \param tv Pointer to the TV instance.
- */
-void TmThreadTestThreadUnPaused(ThreadVars *tv)
-{
-    while (TmThreadsCheckFlag(tv, THV_PAUSE)) {
-        SleepUsec(100);
-
-        if (TmThreadsCheckFlag(tv, THV_KILL))
-            break;
-    }
-}
-
 /**
  * \brief 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.
index 2418fe99ba35175f0b5864cbcc9c0f98af01fbe1..2a46b133c4ccf028bfe2b0c4c2349f44009a8143 100644 (file)
@@ -108,7 +108,6 @@ void TmThreadSetPrio(ThreadVars *);
 int TmThreadGetNbThreads(uint8_t type);
 
 void TmThreadInitMC(ThreadVars *);
-void TmThreadTestThreadUnPaused(ThreadVars *);
 void TmThreadContinue(ThreadVars *);
 void TmThreadContinueThreads(void);
 void TmThreadCheckThreadState(void);
@@ -288,7 +287,11 @@ void TmThreadsGetMinimalTimestamp(struct timeval *ts);
 uint16_t TmThreadsGetWorkerThreadMax(void);
 bool TmThreadsTimeSubsysIsReady(void);
 
-/** \brief Wait for a thread to become unpaused. */
+/** \brief Wait for a thread to become unpaused.
+ *
+ * Check if a thread should wait to be unpaused and wait if so, or
+ * until the thread kill flag is set.
+ */
 void TmThreadsWaitForUnpause(ThreadVars *tv);
 
 #endif /* SURICATA_TM_THREADS_H */