Make suricata_ctl_flags be volatile

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.
pull/1190/merge
Ken Steele 11 years ago committed by Victor Julien
parent 503cc3de69
commit a781fc5c2e

@ -96,7 +96,6 @@
#endif /* HAVE_AF_PACKET */
extern uint8_t suricata_ctl_flags;
extern int max_pending_packets;
#ifndef HAVE_AF_PACKET

@ -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;

@ -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") */

@ -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;

@ -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;

@ -54,8 +54,6 @@
#endif /* __SC_CUDA_SUPPORT__ */
extern uint8_t suricata_ctl_flags;
#define PCAP_STATE_DOWN 0
#define PCAP_STATE_UP 1

@ -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

@ -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;

@ -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];

Loading…
Cancel
Save