From ad15ac829761f0f1b429fd3f3c8f43dae18eaee9 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Fri, 27 May 2016 01:33:10 -0600 Subject: [PATCH] logging: convert json alert output to non-thread module --- src/output-json-alert.c | 21 +++++---------------- src/output-json-drop.c | 2 +- src/output-json-ssh.c | 4 ++-- src/output.c | 7 ++++++- src/output.h | 4 +++- src/tm-modules.c | 1 - src/tm-threads-common.h | 1 - 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/output-json-alert.c b/src/output-json-alert.c index 56567ce206..79c8ea0e29 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -741,30 +741,19 @@ error: void TmModuleJsonAlertLogRegister (void) { - tmm_modules[TMM_JSONALERTLOG].name = MODULE_NAME; - tmm_modules[TMM_JSONALERTLOG].ThreadInit = JsonAlertLogThreadInit; - tmm_modules[TMM_JSONALERTLOG].ThreadDeinit = JsonAlertLogThreadDeinit; - tmm_modules[TMM_JSONALERTLOG].cap_flags = 0; - tmm_modules[TMM_JSONALERTLOG].flags = TM_FLAG_LOGAPI_TM; - OutputRegisterPacketModule(MODULE_NAME, "alert-json-log", - JsonAlertLogInitCtx, JsonAlertLogger, JsonAlertLogCondition, NULL, NULL, NULL); + JsonAlertLogInitCtx, JsonAlertLogger, JsonAlertLogCondition, + JsonAlertLogThreadInit, JsonAlertLogThreadDeinit, NULL); OutputRegisterPacketSubModule("eve-log", MODULE_NAME, "eve-log.alert", - JsonAlertLogInitCtxSub, JsonAlertLogger, JsonAlertLogCondition); + JsonAlertLogInitCtxSub, JsonAlertLogger, JsonAlertLogCondition, + JsonAlertLogThreadInit, JsonAlertLogThreadDeinit, NULL); } #else -static TmEcode OutputJsonThreadInit(ThreadVars *t, void *initdata, void **data) -{ - SCLogInfo("Can't init JSON output - JSON support was disabled during build."); - return TM_ECODE_FAILED; -} - void TmModuleJsonAlertLogRegister (void) { - tmm_modules[TMM_JSONALERTLOG].name = MODULE_NAME; - tmm_modules[TMM_JSONALERTLOG].ThreadInit = OutputJsonThreadInit; + SCLogInfo("Can't register JSON output - JSON support was disabled during build."); } #endif diff --git a/src/output-json-drop.c b/src/output-json-drop.c index fee5845f72..8a9a0610c6 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -438,7 +438,7 @@ void TmModuleJsonDropLogRegister (void) OutputRegisterPacketModule(MODULE_NAME, "drop-json-log", JsonDropLogInitCtx, JsonDropLogger, JsonDropLogCondition, NULL, NULL, NULL); OutputRegisterPacketSubModule("eve-log", MODULE_NAME, "eve-log.drop", - JsonDropLogInitCtxSub, JsonDropLogger, JsonDropLogCondition); + JsonDropLogInitCtxSub, JsonDropLogger, JsonDropLogCondition, NULL, NULL, NULL); } #else diff --git a/src/output-json-ssh.c b/src/output-json-ssh.c index ff626666c2..d99c6e8880 100644 --- a/src/output-json-ssh.c +++ b/src/output-json-ssh.c @@ -328,8 +328,8 @@ void TmModuleJsonSshLogRegister (void) JsonSshLogger, JsonSshCondition, NULL, NULL, NULL); /* also register as child of eve-log */ - OutputRegisterPacketSubModule("eve-log", "JsonSshLog", "eve-log.ssh", OutputSshLogInitSub, - JsonSshLogger, JsonSshCondition); + OutputRegisterPacketSubModule("eve-log", "JsonSshLog", "eve-log.ssh", + OutputSshLogInitSub, JsonSshLogger, JsonSshCondition, NULL, NULL, NULL); } #else diff --git a/src/output.c b/src/output.c index 4ffa6b0813..f981fbdeb3 100644 --- a/src/output.c +++ b/src/output.c @@ -127,7 +127,9 @@ error: void OutputRegisterPacketSubModule(const char *parent_name, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *parent_ctx), - PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc) + PacketLogger PacketLogFunc, PacketLogCondition PacketConditionFunc, + ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, + ThreadExitPrintStatsFunc ThreadExitPrintStats) { if (unlikely(PacketLogFunc == NULL || PacketConditionFunc == NULL)) { goto error; @@ -144,6 +146,9 @@ OutputRegisterPacketSubModule(const char *parent_name, const char *name, module->InitSubFunc = InitFunc; module->PacketLogFunc = PacketLogFunc; module->PacketConditionFunc = PacketConditionFunc; + module->ThreadInit = ThreadInit; + module->ThreadDeinit = ThreadDeinit; + module->ThreadExitPrintStats = ThreadExitPrintStats; TAILQ_INSERT_TAIL(&output_modules, module, entries); SCLogDebug("Packet logger \"%s\" registered.", name); diff --git a/src/output.h b/src/output.h index cfa01ae9a0..d7311c13de 100644 --- a/src/output.h +++ b/src/output.h @@ -77,7 +77,9 @@ void OutputRegisterPacketModule(const char *name, const char *conf_name, ThreadInitFunc, ThreadDeinitFunc, ThreadExitPrintStatsFunc); void OutputRegisterPacketSubModule(const char *parent_name, const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *), - PacketLogger LogFunc, PacketLogCondition ConditionFunc); + PacketLogger LogFunc, PacketLogCondition ConditionFunc, + ThreadInitFunc ThreadInit, ThreadDeinitFunc ThreadDeinit, + ThreadExitPrintStatsFunc ThreadExitPrintStats); void OutputRegisterTxModule(const char *name, const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *), AppProto alproto, diff --git a/src/tm-modules.c b/src/tm-modules.c index 834a46a2c2..5099a74b82 100644 --- a/src/tm-modules.c +++ b/src/tm-modules.c @@ -242,7 +242,6 @@ const char * TmModuleTmmIdToString(TmmId id) CASE_CODE (TMM_FILELOGGER); CASE_CODE (TMM_FILEDATALOGGER); CASE_CODE (TMM_STREAMINGLOGGER); - CASE_CODE (TMM_JSONALERTLOG); CASE_CODE (TMM_JSONDROPLOG); CASE_CODE (TMM_JSONFILELOG); CASE_CODE (TMM_JSONFLOWLOG); diff --git a/src/tm-threads-common.h b/src/tm-threads-common.h index 370c5a1cff..7e76782692 100644 --- a/src/tm-threads-common.h +++ b/src/tm-threads-common.h @@ -75,7 +75,6 @@ typedef enum { TMM_FILELOGGER, TMM_FILEDATALOGGER, TMM_STREAMINGLOGGER, - TMM_JSONALERTLOG, TMM_JSONDROPLOG, TMM_JSONSMTPLOG, TMM_JSONSSHLOG, -- 2.47.2