]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output: clean file desc at exit. 925/head
authorEric Leblond <eric@regit.org>
Wed, 9 Apr 2014 13:04:45 +0000 (15:04 +0200)
committerEric Leblond <eric@regit.org>
Wed, 9 Apr 2014 13:09:09 +0000 (15:09 +0200)
This is a beginning of implementation for bug #1660:
 https://redmine.openinfosecfoundation.org/issues/1160

This patch adds a cleaning function for each logger of new type
(packet, tx and file). These functions are called in RunModeShutDown().

The state of this patch is that it is crashing suricata when sending
pcap to analyse:
 - At first pcap if tx and file cleaning function are called
 - At second pcap if only packet cleaning function is called

The cause in first case is unknown. In second case this is due to
the necessity of cleaning the list of logger registered to a logging
type.

src/output-file.c
src/output-file.h
src/output-packet.c
src/output-packet.h
src/output-tx.c
src/output-tx.h
src/runmodes.c

index f6283d70a11f53eb0ccf0ef3ac2c14e63971cb3e..c9a71444d339c5252b387dd58be633065ec5ec67 100644 (file)
@@ -277,3 +277,13 @@ void TmModuleFileLoggerRegister (void) {
     tmm_modules[TMM_FILELOGGER].ThreadDeinit = OutputFileLogThreadDeinit;
     tmm_modules[TMM_FILELOGGER].cap_flags = 0;
 }
+
+void OutputFileShutdown(void)
+{
+    OutputFileLogger *logger = list;
+    while (logger) {
+        if (logger->output_ctx != NULL && logger->output_ctx->DeInit != NULL)
+            logger->output_ctx->DeInit(logger->output_ctx);
+        logger = logger->next;
+    }
+}
index 2e2009681b86cfe67d5a2bef838e3c52b724c08f..8b203e267c1d6f804e79182a0b5fb8242d424124 100644 (file)
@@ -41,4 +41,6 @@ int OutputRegisterFileLogger(const char *name, FileLogger LogFunc, OutputCtx *);
 
 void TmModuleFileLoggerRegister (void);
 
+void OutputFileShutdown(void);
+
 #endif /* __OUTPUT_FILE_H__ */
index 6f9ddde55afa9971bf2e6f3d6ac099bc217f34da..d575232d8ae38f5595191801d2bf1f371ca08283 100644 (file)
@@ -217,3 +217,16 @@ void TmModulePacketLoggerRegister (void) {
     tmm_modules[TMM_PACKETLOGGER].ThreadDeinit = OutputPacketLogThreadDeinit;
     tmm_modules[TMM_PACKETLOGGER].cap_flags = 0;
 }
+
+void OutputPacketShutdown(void)
+{
+    OutputPacketLogger *logger = list;
+    while (logger) {
+        if (logger->output_ctx != NULL && logger->output_ctx->DeInit != NULL)
+            logger->output_ctx->DeInit(logger->output_ctx);
+        logger = logger->next;
+    }
+
+    /* FIXME */
+    list = NULL;
+}
index 1173282f68a7ef0f278e51c2bfa65fa67f2b5688..5ae1adf8e4878c28c2ef867a1c9a9dbf45cf6400 100644 (file)
@@ -41,4 +41,6 @@ int OutputRegisterPacketLogger(const char *name, PacketLogger LogFunc,
 
 void TmModulePacketLoggerRegister (void);
 
+void OutputPacketShutdown(void);
+
 #endif /* __OUTPUT_PACKET_H__ */
index f6e5235439f45a794170887aac0ef009f5838c30..3322277d2519642510708858276737842d2b692e 100644 (file)
@@ -284,3 +284,13 @@ void TmModuleTxLoggerRegister (void) {
     tmm_modules[TMM_TXLOGGER].ThreadDeinit = OutputTxLogThreadDeinit;
     tmm_modules[TMM_TXLOGGER].cap_flags = 0;
 }
+
+void OutputTxShutdown(void)
+{
+    OutputTxLogger *logger = list;
+    while (logger) {
+        if (logger->output_ctx != NULL && logger->output_ctx->DeInit != NULL)
+            logger->output_ctx->DeInit(logger->output_ctx);
+        logger = logger->next;
+    }
+}
index 92815499003e3603498acfb79cee3b80bc931d28..7ffb8a6d25e8c0e171a18ce82328f662c52b262b 100644 (file)
@@ -40,4 +40,6 @@ int OutputRegisterTxLogger(const char *name, AppProto alproto, TxLogger LogFunc,
 
 void TmModuleTxLoggerRegister (void);
 
+void OutputTxShutdown(void);
+
 #endif /* __OUTPUT_PACKET_H__ */
index d975414e19e267bca03971d5406f31a424e0cc63..6256819fd6267e49542b3db63ac72f1fc2320ed7 100644 (file)
@@ -408,6 +408,10 @@ void RunModeShutDown(void)
             output->output_ctx->DeInit(output->output_ctx);
         SCFree(output);
     }
+
+    OutputPacketShutdown();
+    OutputTxShutdown();
+    OutputFileShutdown();
 }
 
 static TmModule *pkt_logger_module = NULL;