diff --git a/examples/lib/custom/main.c b/examples/lib/custom/main.c index c4da9f6146..1508915490 100644 --- a/examples/lib/custom/main.c +++ b/examples/lib/custom/main.c @@ -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); } diff --git a/src/runmode-lib.c b/src/runmode-lib.c index 1441dabe4b..97f8d9d78e 100644 --- a/src/runmode-lib.c +++ b/src/runmode-lib.c @@ -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; diff --git a/src/runmode-lib.h b/src/runmode-lib.h index c33cb4e65b..86a1b812d0 100644 --- a/src/runmode-lib.h +++ b/src/runmode-lib.h @@ -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. *