]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Create SCMUTEX_INITIALIZER to abstract out PTHREAD_MUTEX_INITIALIZER
authorKen Steele <ken@tilera.com>
Tue, 6 Aug 2013 18:49:31 +0000 (14:49 -0400)
committerVictor Julien <victor@inliniac.net>
Mon, 2 Sep 2013 13:03:30 +0000 (15:03 +0200)
This allows replacing pthread mutexes with other types of mutex.

14 files changed:
src/app-layer-ftp.c
src/app-layer-htp.c
src/app-layer-parser.c
src/detect-luajit.c
src/source-af-packet.c
src/source-pcap.c
src/source-pfring.c
src/stream-tcp.c
src/stream.c
src/threads.h
src/tm-threads.c
src/util-cuda-handlers.c
src/util-debug-filters.c
src/util-time.c

index f52d8d3e1d94f84a4596b9ef752c73b4b5cf497c..6b633c84304ab681e86a066ed74201b408cd5429 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -228,7 +228,7 @@ static int FTPParseResponse(Flow *f, void *ftp_state, AppLayerParserState *pstat
 }
 
 #ifdef DEBUG
-static SCMutex ftp_state_mem_lock = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex ftp_state_mem_lock = SCMUTEX_INITIALIZER;
 static uint64_t ftp_state_memuse = 0;
 static uint64_t ftp_state_memcnt = 0;
 #endif
index 5156b3d3a5c249d9469f2d1a2d4fc036edd72be7..9f894d0334b6f1a9cf3208f725fd681a21549902 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2011 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -85,7 +85,7 @@ static SCRadixTree *cfgtree;
 static HTPCfgRec cfglist;
 
 #ifdef DEBUG
-static SCMutex htp_state_mem_lock = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex htp_state_mem_lock = SCMUTEX_INITIALIZER;
 static uint64_t htp_state_memuse = 0;
 static uint64_t htp_state_memcnt = 0;
 #endif
index 8a93ca61794e6518f3e6582000831f5be8edc415..1fa42cc73c89f7ebba7126f5780def019d075f29 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -72,7 +72,7 @@ static AppLayerParserTableElement al_parser_table[MAX_PARSERS];
 static uint16_t al_max_parsers = 0; /* incremented for every registered parser */
 
 static Pool *al_result_pool = NULL;
-static SCMutex al_result_pool_mutex = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex al_result_pool_mutex = SCMUTEX_INITIALIZER;
 #ifdef DEBUG
 static uint32_t al_result_pool_elmts = 0;
 #endif /* DEBUG */
index 2b453c52b67e16ea1e922f826c68414d6c3b4c1c..ddeadd558daa663ad6fc4f3c80ed0ac1eac83b8a 100644 (file)
@@ -119,7 +119,7 @@ void DetectLuajitRegister(void) {
  *  Alternatively, the "detect-engine.luajit-states" var can be set.
  */
 static Pool *luajit_states = NULL;
-static pthread_mutex_t luajit_states_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t luajit_states_lock = SCMUTEX_INITIALIZER;
 
 #define DATATYPE_PACKET                     (1<<0)
 #define DATATYPE_PAYLOAD                    (1<<1)
index 23a8adc91e26fbdcc55d33664ba96efc7d56c901..2aefcf6cda981d78f59d97ef6b5811c114d816df 100644 (file)
@@ -157,7 +157,7 @@ TmEcode NoAFPSupportExit(ThreadVars *tv, void *initdata, void **data)
 #endif
 
 /** protect pfring_set_bpf_filter, as it is not thread safe */
-static SCMutex afpacket_bpf_set_filter_lock = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex afpacket_bpf_set_filter_lock = SCMUTEX_INITIALIZER;
 
 enum {
     AFP_READ_OK,
index 041370921681fd318ed9cc0716cbd7b4d87b3453..d3aa1acdad42754415f8e7cabf06df1a24421758 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -115,7 +115,7 @@ TmEcode DecodePcap(ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *)
 
 /** protect pcap_compile and pcap_setfilter, as they are not thread safe:
  *  http://seclists.org/tcpdump/2009/q1/62 */
-static SCMutex pcap_bpf_compile_lock = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex pcap_bpf_compile_lock = SCMUTEX_INITIALIZER;
 
 /**
  * \brief Registration Function for RecievePcap.
index 68abec6feda5105c50d785bcadf7c978be8d8972..88d615b9827c36769c0b9db5ec6d1dd23ffb0ea6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -115,7 +115,7 @@ TmEcode NoPfringSupportExit(ThreadVars *tv, void *initdata, void **data)
 #else /* implied we do have PF_RING support */
 
 /** protect pfring_set_bpf_filter, as it is not thread safe */
-static SCMutex pfring_bpf_set_filter_lock = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex pfring_bpf_set_filter_lock = SCMUTEX_INITIALIZER;
 
 /* XXX replace with user configurable options */
 #define LIBPFRING_PROMISC     1
index 033bef0338d70e54c71f2f0365192d7c5318d06b..a4b5cb14bb33a65a2cbfec66d517371e28baf206 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2011 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -106,7 +106,7 @@ static int StreamTcpValidateRst(TcpSession * , Packet *);
 static inline int StreamTcpValidateAck(TcpSession *ssn, TcpStream *, Packet *);
 
 static PoolThread *ssn_pool = NULL;
-static SCMutex ssn_pool_mutex = PTHREAD_MUTEX_INITIALIZER; /**< init only, protect initializing and growing pool */
+static SCMutex ssn_pool_mutex = SCMUTEX_INITIALIZER; /**< init only, protect initializing and growing pool */
 #ifdef DEBUG
 static uint64_t ssn_pool_cnt = 0; /** counts ssns, protected by ssn_pool_mutex */
 #endif
index aec247e760563f386284060199f7a6cb66844394..4c9354ae1ce85a8996603385d2f1cba839243e03 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -43,7 +43,7 @@ static uint16_t toserver_min_chunk_len = 2560;
 static uint16_t toclient_min_chunk_len = 2560;
 
 static Pool *stream_msg_pool = NULL;
-static SCMutex stream_msg_pool_mutex = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex stream_msg_pool_mutex = SCMUTEX_INITIALIZER;
 
 int StreamMsgInit(void *data, void *initdata)
 {
index ad48687c40f382039e8a89f2b4c525fc3b907b01..b07457dd87157555891745744dee8d990ec0e394 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -104,6 +104,7 @@ enum {
 #define SCMutex pthread_mutex_t
 #define SCMutexAttr pthread_mutexattr_t
 #define SCMutexDestroy pthread_mutex_destroy
+#define SCMUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
 /** Suricata RWLocks */
 #define SCRWLock pthread_rwlock_t
index 254d4f9eaad200fcb185ed99ee13a5a44672a37c..79efa6d39838234eb326f3e0d81160dcb81d7a14 100644 (file)
@@ -77,7 +77,7 @@ static int SetCPUAffinity(uint16_t cpu);
 ThreadVars *tv_root[TVT_MAX] = { NULL };
 
 /* lock to protect tv_root */
-SCMutex tv_root_lock = PTHREAD_MUTEX_INITIALIZER;
+SCMutex tv_root_lock = SCMUTEX_INITIALIZER;
 
 /* Action On Failure(AOF).  Determines how the engine should behave when a
  * thread encounters a failure.  Defaults to restart the failed thread */
index 2206e1be0411dd0e9d213b3f8396cca71eacc282..79532e5f1e2c183d900615c7f5816e96da533ed7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2012 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -48,7 +48,7 @@ typedef struct CudaHandlerConfProfile_ {
 
 static CudaHandlerConfProfile *conf_profiles = NULL;
 /* protects above var */
-static SCMutex mutex = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex mutex = SCMUTEX_INITIALIZER;
 
 void CudaHandlerAddCudaProfileFromConf(const char *name,
                                        void *(*Callback)(ConfNode *node),
index 6a8b9233dedb466c90eb3d6aa67c996264d6334d..6c06b0af2de3673baed0f3b4a41195d12b9e005b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -43,8 +43,8 @@ SCLogFGFilterFile *sc_log_fg_filters[SC_LOG_FILTER_MAX] = { NULL, NULL };
 /**
  * \brief Mutex for accessing the fine-grained fiters sc_log_fg_filters
  */
-static SCMutex sc_log_fg_filters_m[SC_LOG_FILTER_MAX] = { PTHREAD_MUTEX_INITIALIZER,
-                                                                  PTHREAD_MUTEX_INITIALIZER };
+static SCMutex sc_log_fg_filters_m[SC_LOG_FILTER_MAX] = { SCMUTEX_INITIALIZER,
+                                                          SCMUTEX_INITIALIZER };
 
 /**
  * \brief Holds the function-dependent filters
@@ -54,7 +54,7 @@ static SCLogFDFilter *sc_log_fd_filters = NULL;
 /**
  * \brief Mutex for accessing the function-dependent filters sc_log_fd_filters
  */
-static SCMutex sc_log_fd_filters_m = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex sc_log_fd_filters_m = SCMUTEX_INITIALIZER;
 
 /**
  * \brief Holds the thread_list required by function-dependent filters
@@ -64,7 +64,7 @@ static SCLogFDFilterThreadList *sc_log_fd_filters_tl = NULL;
 /**
  * \brief Mutex for accessing the FD thread_list sc_log_fd_filters_tl
  */
-static SCMutex sc_log_fd_filters_tl_m = PTHREAD_MUTEX_INITIALIZER;
+static SCMutex sc_log_fd_filters_tl_m = SCMUTEX_INITIALIZER;
 
 /**
  * \brief Helper function used internally to add a FG filter
index a7a3b4c178a3828287bbe1298c62cb94fe4e1297..a744607d78cf02b0104f902ae4ed110909dacc13 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
@@ -29,7 +29,7 @@
 #include "util-debug.h"
 
 static struct timeval current_time = { 0, 0 };
-//static SCMutex current_time_mutex = PTHREAD_MUTEX_INITIALIZER;
+//static SCMutex current_time_mutex = SCMUTEX_INITIALIZER;
 static SCSpinlock current_time_spinlock;
 static char live = TRUE;