]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Make suricata_ctl_flags be volatile
authorKen Steele <ken@tilera.com>
Wed, 29 Oct 2014 19:43:42 +0000 (15:43 -0400)
committerVictor Julien <victor@inliniac.net>
Thu, 30 Oct 2014 12:32:24 +0000 (13:32 +0100)
The global variable suricata_ctl_flags needs to volatile, otherwise the
compiler might not cause the variable to be read every time because it
doesn't know other threads might write the variable.

This was causing Suricata to not exit under some conditions.

src/source-af-packet.c
src/source-erf-dag.c
src/source-mpipe.c
src/source-napatech.c
src/source-pcap-file.c
src/source-pcap.c
src/source-pfring.c
src/suricata.c
src/suricata.h

index f5858ac522483374fbf6952c468f2225b497ac74..1d67f0a51e48aca4f9dc3f589017355061f52b88 100644 (file)
@@ -96,7 +96,6 @@
 
 #endif /* HAVE_AF_PACKET */
 
-extern uint8_t suricata_ctl_flags;
 extern int max_pending_packets;
 
 #ifndef HAVE_AF_PACKET
index dbbd0774288e5e376b036cdd80b8505298866c57..a68910c35505eaf31f60b6732c8342ce949242a6 100644 (file)
@@ -91,7 +91,6 @@ NoErfDagSupportExit(ThreadVars *tv, void *initdata, void **data)
 #define BYTES_PER_LOOP (4 * 1024 * 1024) /* 4 MB */
 
 extern int max_pending_packets;
-extern uint8_t suricata_ctl_flags;
 
 typedef struct ErfDagThreadVars_ {
     ThreadVars *tv;
index a7278463676f7ecb0e67b3520ccf442bfa5f34f4..5bac179ab32683a9f8bd274117fe77894976aa6b 100644 (file)
@@ -76,8 +76,6 @@
 
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 
-extern uint8_t suricata_ctl_flags;
-
 /** storage for mpipe device names */
 typedef struct MpipeDevice_ {
     char *dev;  /**< the device (e.g. "xgbe1") */
index 18abd3aa6d09d719fa6810730feb6310f02bea3d..6c577fecc2a1f960d64d08d67699668b978639bf 100644 (file)
@@ -79,7 +79,6 @@ TmEcode NoNapatechSupportExit(ThreadVars *tv, void *initdata, void **data)
 #include <nt.h>
 
 extern int max_pending_packets;
-extern uint8_t suricata_ctl_flags;
 
 typedef struct NapatechThreadVars_ {
     ThreadVars *tv;
index d4232bcebb6cd629e9fc665a70a4a711016b7c56..3202b0d8d4c7e002300804d2b5c9512ed09127a8 100644 (file)
@@ -57,7 +57,6 @@
 
 #endif /* __SC_CUDA_SUPPORT__ */
 
-extern uint8_t suricata_ctl_flags;
 extern int max_pending_packets;
 
 //static int pcap_max_read_packets = 0;
index 0bc76b9ce78a50b7f4aa8ee295ab0813ce593982..bf51ff91ea88b9aeb60d01bc5601209b914b95d3 100644 (file)
@@ -54,8 +54,6 @@
 
 #endif /* __SC_CUDA_SUPPORT__ */
 
-extern uint8_t suricata_ctl_flags;
-
 #define PCAP_STATE_DOWN 0
 #define PCAP_STATE_UP 1
 
index 753afe7f3b15dad16e000479a6d593861bc42395..fb4aed73a7c1d6702075befd38c2fb23c24742c7 100644 (file)
@@ -71,7 +71,6 @@ TmEcode DecodePfring(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue
 TmEcode DecodePfringThreadDeinit(ThreadVars *tv, void *data);
 
 extern int max_pending_packets;
-extern uint8_t suricata_ctl_flags;
 
 #ifndef HAVE_PFRING
 
index 9549827939560b4501e07c45ccf7efc677ce2c25..5d756eb6d4c6dcc1587d7957e34a2f53f3cc9c7a 100644 (file)
@@ -202,7 +202,7 @@ SC_ATOMIC_DECLARE(unsigned int, engine_stage);
 #define DEFAULT_MAX_PENDING_PACKETS 1024
 
 /** suricata engine control flags */
-uint8_t suricata_ctl_flags = 0;
+volatile uint8_t suricata_ctl_flags = 0;
 
 /** Run mode selected */
 int run_mode = RUNMODE_UNKNOWN;
index de0fb02f1122a5b27345332ee329045324e809c8..573be0bb0aa9fc0790fa86b894aa6abc231a2af1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2014 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -162,7 +162,7 @@ typedef struct SCInstance_ {
 /* memset to zeros, and mutex init! */
 void GlobalInits();
 
-extern uint8_t suricata_ctl_flags;
+extern volatile uint8_t suricata_ctl_flags;
 
 /* uppercase to lowercase conversion lookup table */
 uint8_t g_u8_lowercasetable[256];