From b2d29a85e90770a155763034e9873bd368b58fe3 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 10 Apr 2014 09:41:52 +0200 Subject: [PATCH] tls-json: add cleanup function Properly clean up output context when shutting down. --- src/output-json-tls.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/output-json-tls.c b/src/output-json-tls.c index 5b00d8a96f..869f8fc38e 100644 --- a/src/output-json-tls.c +++ b/src/output-json-tls.c @@ -212,6 +212,16 @@ static TmEcode JsonTlsLogThreadDeinit(ThreadVars *t, void *data) return TM_ECODE_OK; } +static void OutputTlsLogDeinit(OutputCtx *output_ctx) +{ + OutputTlsLoggerDisable(); + + OutputTlsCtx *tls_ctx = output_ctx->data; + LogFileCtx *logfile_ctx = tls_ctx->file_ctx; + LogFileFreeCtx(logfile_ctx); + SCFree(tls_ctx); + SCFree(output_ctx); +} #define DEFAULT_LOG_FILENAME "tls.json" OutputCtx *OutputTlsLogInit(ConfNode *conf) @@ -259,11 +269,20 @@ OutputCtx *OutputTlsLogInit(ConfNode *conf) } } output_ctx->data = tls_ctx; - output_ctx->DeInit = NULL; + output_ctx->DeInit = OutputTlsLogDeinit; return output_ctx; } +static void OutputTlsLogDeinitSub(OutputCtx *output_ctx) +{ + OutputTlsLoggerDisable(); + + OutputTlsCtx *tls_ctx = output_ctx->data; + SCFree(tls_ctx); + SCFree(output_ctx); +} + OutputCtx *OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) { AlertJsonThread *ajt = parent_ctx->data; @@ -297,7 +316,7 @@ OutputCtx *OutputTlsLogInitSub(ConfNode *conf, OutputCtx *parent_ctx) } } output_ctx->data = tls_ctx; - output_ctx->DeInit = NULL; + output_ctx->DeInit = OutputTlsLogDeinitSub; return output_ctx; }