Add Init and DeInit calls to the thread module API.

remotes/origin/master-1.2.x
Victor Julien 14 years ago
parent 7fb78a0ff6
commit effe01ae7b

@ -1412,6 +1412,8 @@ int main(int argc, char **argv)
} }
#endif /* UNITTESTS */ #endif /* UNITTESTS */
TmModuleRunInit();
if (daemon == 1) { if (daemon == 1) {
Daemonize(); Daemonize();
if (pid_filename == NULL) { if (pid_filename == NULL) {
@ -1758,6 +1760,8 @@ int main(int argc, char **argv)
TmqhPacketpoolDestroy(); TmqhPacketpoolDestroy();
MagicDeinit(); MagicDeinit();
TmModuleRunDeInit();
#ifdef PROFILING #ifdef PROFILING
if (profiling_rules_enabled) if (profiling_rules_enabled)
SCProfilingDump(); SCProfilingDump();

@ -153,6 +153,40 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
SCReturnInt(1); SCReturnInt(1);
} }
void TmModuleRunInit(void) {
TmModule *t;
uint16_t i;
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL)
continue;
if (t->Init == NULL)
continue;
t->Init();
}
}
void TmModuleRunDeInit(void) {
TmModule *t;
uint16_t i;
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL)
continue;
if (t->DeInit == NULL)
continue;
t->DeInit();
}
}
/** \brief register all unittests for the tm modules */ /** \brief register all unittests for the tm modules */
void TmModuleRegisterTests(void) { void TmModuleRegisterTests(void) {
#ifdef UNITTESTS #ifdef UNITTESTS

@ -43,6 +43,10 @@ typedef struct TmModule_ {
TmEcode (*PktAcqLoop)(ThreadVars *, void *, void *); TmEcode (*PktAcqLoop)(ThreadVars *, void *, void *);
/** global Init/DeInit */
TmEcode (*Init)(void);
TmEcode (*DeInit)(void);
void (*RegisterTests)(void); void (*RegisterTests)(void);
uint8_t cap_flags; /**< Flags to indicate the capability requierment of uint8_t cap_flags; /**< Flags to indicate the capability requierment of
@ -105,5 +109,8 @@ void TmModuleDebugList(void);
void TmModuleRegisterTests(void); void TmModuleRegisterTests(void);
const char * TmModuleTmmIdToString(TmmId id); const char * TmModuleTmmIdToString(TmmId id);
void TmModuleRunInit(void);
void TmModuleRunDeInit(void);
#endif /* __TM_MODULES_H__ */ #endif /* __TM_MODULES_H__ */

Loading…
Cancel
Save