Create SCMUTEX_INITIALIZER to abstract out PTHREAD_MUTEX_INITIALIZER

This allows replacing pthread mutexes with other types of mutex.
pull/514/merge
Ken Steele 13 years ago committed by Victor Julien
parent 784843b146
commit 5532af4621

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save