Skip to content

Commit

Permalink
Merge pull request OISF#6 from ken-tilera/mutex-init
Browse files Browse the repository at this point in the history
Mutex init
  • Loading branch information
regit committed Aug 26, 2013
2 parents 1e501b6 + ddbcbf6 commit 8c062a8
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/app-layer-ftp.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app-layer-htp.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app-layer-parser.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/detect-luajit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/source-af-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/source-pcap.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/source-pfring.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/stream-tcp.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -105,7 +105,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
Expand Down
4 changes: 2 additions & 2 deletions src/stream.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion src/threads.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tm-threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions src/util-cuda-handlers.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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),
Expand Down
10 changes: 5 additions & 5 deletions src/util-debug-filters.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/util-time.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 8c062a8

Please sign in to comment.