]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
lib: rename threadvars creation function
authorJason Ish <jason.ish@oisf.net>
Wed, 24 Apr 2024 22:10:15 +0000 (16:10 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 1 Apr 2025 08:17:05 +0000 (10:17 +0200)
Also use a proper return type (ThreadVars *).

Ticket: #7240

examples/lib/custom/main.c
src/runmode-lib.c
src/runmode-lib.h

index c4da9f6146d6b27f06551efc590ed8f7826074a7..150891549013e1567ab417e4b3efd27bdb45b4f9 100644 (file)
@@ -31,7 +31,7 @@ static void *SimpleWorker(void *arg)
     char *pcap_file = (char *)arg;
 
     /* Create worker. */
-    ThreadVars *tv = RunModeCreateWorker();
+    ThreadVars *tv = SCRunModeLibCreateThreadVars();
     if (!tv) {
         pthread_exit(NULL);
     }
index 1441dabe4bcb67f2b34bb3af3c03a5a639fea9cd..97f8d9d78efbac8da41235aaa8ae7084995ad55a 100644 (file)
@@ -59,13 +59,7 @@ const char *RunModeLibGetDefaultMode(void)
     return "live";
 }
 
-/** \brief create a "fake" worker thread in charge of processing the packets.
- *
- *  This method just creates a context representing the worker, which is handled from the library
- *  client. No actual thread (pthread_t) is created.
- *
- * \return Pointer to ThreadVars structure representing the worker thread */
-void *RunModeCreateWorker(void)
+ThreadVars *SCRunModeLibCreateThreadVars(void)
 {
     char tname[TM_THREAD_NAME_MAX];
     TmModule *tm_module = NULL;
index c33cb4e65bf344b39597934d5d20fe5b9a22956a..86a1b812d05e31671669643c5f133d7398dad576 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef SURICATA_RUNMODE_LIB_H
 #define SURICATA_RUNMODE_LIB_H
 
+#include "threadvars.h"
+
 /** \brief register runmodes for suricata as a library */
 void RunModeIdsLibRegister(void);
 
@@ -37,13 +39,15 @@ int RunModeIdsLibOffline(void);
 /** \brief runmode default mode (live) */
 const char *RunModeLibGetDefaultMode(void);
 
-/** \brief create a "fake" worker thread in charge of processing the packets.
+/**
+ * \brief Create ThreadVars for use by a user provided thread.
  *
- *  This method just creates a context representing the worker, which is handled from the library
- *  client. No actual thread (pthread_t) is created.
+ * Unlike other runmodes, this does not spawn a thread, as the threads
+ * are controlled by the application using Suricata as a library.
  *
- * \return Pointer to ThreadVars structure representing the worker thread */
-void *RunModeCreateWorker(void);
+ * \return Pointer to allocated ThreadVars or NULL on failure
+ */
+ThreadVars *SCRunModeLibCreateThreadVars(void);
 
 /** \brief start the "fake" worker.
  *