]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
tls-json: add cleanup function
authorVictor Julien <victor@inliniac.net>
Thu, 10 Apr 2014 07:41:52 +0000 (09:41 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 10 Apr 2014 07:41:52 +0000 (09:41 +0200)
Properly clean up output context when shutting down.

src/output-json-tls.c

index 5b00d8a96f373e5c5b2b341da7894ff76fad4b20..869f8fc38ea10b22c0158dd5d5a06dd64c9d3cd6 100644 (file)
@@ -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;
 }