Changing mutex/spinlocks/conditions naming types

remotes/origin/master-1.0.x
Pablo Rincon 17 years ago committed by Victor Julien
parent 406ee2ce70
commit e26833be3f

@ -73,7 +73,7 @@ TmEcode AlertDebuglogIPv4(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq
CreateTimeString(&p->ts, timebuf, sizeof(timebuf));
sc_mutex_lock(&aft->file_ctx->fp_mutex);
SCMutexLock(&aft->file_ctx->fp_mutex);
fprintf(aft->file_ctx->fp, "+================\n");
fprintf(aft->file_ctx->fp, "TIME: %s\n", timebuf);
@ -137,7 +137,7 @@ TmEcode AlertDebuglogIPv4(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq
PrintRawDataFp(aft->file_ctx->fp, p->pkt, p->pktlen);
fflush(aft->file_ctx->fp);
sc_mutex_unlock(&aft->file_ctx->fp_mutex);
SCMutexUnlock(&aft->file_ctx->fp_mutex);
return TM_ECODE_OK;
}
@ -155,7 +155,7 @@ TmEcode AlertDebuglogIPv6(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq
CreateTimeString(&p->ts, timebuf, sizeof(timebuf));
sc_mutex_lock(&aft->file_ctx->fp_mutex);
SCMutexLock(&aft->file_ctx->fp_mutex);
for (i = 0; i < p->alerts.cnt; i++) {
PacketAlert *pa = &p->alerts.alerts[i];
char srcip[46], dstip[46];
@ -167,7 +167,7 @@ TmEcode AlertDebuglogIPv6(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq
timebuf, pa->gid, pa->sid, pa->rev, pa->msg, pa->prio, IPV6_GET_L4PROTO(p), srcip, p->sp, dstip, p->dp);
}
fflush(aft->file_ctx->fp);
sc_mutex_unlock(&aft->file_ctx->fp_mutex);
SCMutexUnlock(&aft->file_ctx->fp_mutex);
return TM_ECODE_OK;
}

@ -91,7 +91,7 @@ TmEcode AlertFastlogIPv4(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
CreateTimeString(&p->ts, timebuf, sizeof(timebuf));
sc_mutex_lock(&aft->file_ctx->fp_mutex);
SCMutexLock(&aft->file_ctx->fp_mutex);
for (i = 0; i < p->alerts.cnt; i++) {
PacketAlert *pa = &p->alerts.alerts[i];
@ -104,7 +104,7 @@ TmEcode AlertFastlogIPv4(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
timebuf, pa->gid, pa->sid, pa->rev, pa->msg, pa->prio, IPV4_GET_IPPROTO(p), srcip, p->sp, dstip, p->dp);
}
fflush(aft->file_ctx->fp);
sc_mutex_unlock(&aft->file_ctx->fp_mutex);
SCMutexUnlock(&aft->file_ctx->fp_mutex);
return TM_ECODE_OK;
}
@ -122,7 +122,7 @@ TmEcode AlertFastlogIPv6(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
CreateTimeString(&p->ts, timebuf, sizeof(timebuf));
sc_mutex_lock(&aft->file_ctx->fp_mutex);
SCMutexLock(&aft->file_ctx->fp_mutex);
for (i = 0; i < p->alerts.cnt; i++) {
PacketAlert *pa = &p->alerts.alerts[i];
@ -136,7 +136,7 @@ TmEcode AlertFastlogIPv6(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
fflush(aft->file_ctx->fp);
}
sc_mutex_unlock(&aft->file_ctx->fp_mutex);
SCMutexUnlock(&aft->file_ctx->fp_mutex);
return TM_ECODE_OK;
}

@ -150,15 +150,15 @@ TmEcode AlertUnifiedAlert (ThreadVars *tv, Packet *p, void *data, PacketQueue *p
}
/** check and enforce the filesize limit, thread safe */
sc_mutex_lock(&aun->file_ctx->fp_mutex);
SCMutexLock(&aun->file_ctx->fp_mutex);
if ((aun->size_current + sizeof(hdr)) > aun->size_limit) {
if (AlertUnifiedAlertRotateFile(tv,aun) < 0)
{
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
return TM_ECODE_FAILED;
}
}
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
/* XXX which one to add to this alert? Lets see how Snort solves this.
* For now just take last alert. */

@ -156,15 +156,15 @@ TmEcode AlertUnifiedLog (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
/* check and enforce the filesize limit */
/** Wait for the mutex. We dont want all the threads rotating the file
* at the same time :) */
sc_mutex_lock(&aun->file_ctx->fp_mutex);
SCMutexLock(&aun->file_ctx->fp_mutex);
if ((aun->size_current + sizeof(hdr) + p->pktlen + ethh_offset) > aun->size_limit) {
if (AlertUnifiedLogRotateFile(tv,aun) < 0)
{
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
return TM_ECODE_FAILED;
}
}
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
/* XXX which one to add to this alert? Lets see how Snort solves this.
* For now just take last alert. */

@ -217,15 +217,15 @@ int Unified2PacketTypeAlert (ThreadVars *t, Packet *p, void *data)
memcpy(write_buffer,&hdr,sizeof(Unified2AlertFileHeader));
sc_mutex_lock(&aun->file_ctx->fp_mutex);
SCMutexLock(&aun->file_ctx->fp_mutex);
if ((aun->size_current + (sizeof(hdr) + sizeof(phdr))) > aun->size_limit) {
if (Unified2AlertRotateFile(t,aun) < 0)
{
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
return -1;
}
}
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
phdr.sensor_id = 0;
phdr.linktype = htonl(p->datalink);
@ -292,15 +292,15 @@ int Unified2IPv6TypeAlert (ThreadVars *t, Packet *p, void *data, PacketQueue *pq
}
/* check and enforce the filesize limit */
sc_mutex_lock(&aun->file_ctx->fp_mutex);
SCMutexLock(&aun->file_ctx->fp_mutex);
if ((aun->size_current +(sizeof(hdr) + sizeof(phdr))) > aun->size_limit) {
if (Unified2AlertRotateFile(t,aun) < 0)
{
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
return -1;
}
}
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
/* XXX which one to add to this alert? Lets see how Snort solves this.
* For now just take last alert. */
@ -403,15 +403,15 @@ int Unified2IPv4TypeAlert (ThreadVars *tv, Packet *p, void *data, PacketQueue *p
}
/* check and enforce the filesize limit */
sc_mutex_lock(&aun->file_ctx->fp_mutex);
SCMutexLock(&aun->file_ctx->fp_mutex);
if ((aun->size_current +(sizeof(hdr) + sizeof(phdr))) > aun->size_limit) {
if (Unified2AlertRotateFile(tv,aun) < 0)
{
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
return -1;
}
}
sc_mutex_unlock(&aun->file_ctx->fp_mutex);
SCMutexUnlock(&aun->file_ctx->fp_mutex);
/* XXX which one to add to this alert? Lets see how Snort solves this.
* For now just take last alert. */

@ -307,12 +307,12 @@ int AppLayerHandleMsg(StreamMsg *smsg, char need_lock)
uint16_t alproto = ALPROTO_UNKNOWN;
int r = 0;
if (need_lock == TRUE) sc_mutex_lock(&smsg->flow->m);
if (need_lock == TRUE) SCMutexLock(&smsg->flow->m);
TcpSession *ssn = smsg->flow->protoctx;
if (ssn != NULL) {
alproto = ssn->alproto;
}
if (need_lock == TRUE) sc_mutex_unlock(&smsg->flow->m);
if (need_lock == TRUE) SCMutexUnlock(&smsg->flow->m);
if (ssn != NULL) {
if (smsg->flags & STREAM_START) {
@ -327,10 +327,10 @@ int AppLayerHandleMsg(StreamMsg *smsg, char need_lock)
smsg->data.data, smsg->data.data_len, smsg->flags);
if (alproto != ALPROTO_UNKNOWN) {
/* store the proto and setup the L7 data array */
if (need_lock == TRUE) sc_mutex_lock(&smsg->flow->m);
if (need_lock == TRUE) SCMutexLock(&smsg->flow->m);
StreamL7DataPtrInit(ssn,StreamL7GetStorageSize());
ssn->alproto = alproto;
if (need_lock == TRUE) sc_mutex_unlock(&smsg->flow->m);
if (need_lock == TRUE) SCMutexUnlock(&smsg->flow->m);
r = AppLayerParse(smsg->flow, alproto, smsg->flags,
smsg->data.data, smsg->data.data_len, need_lock);
@ -354,9 +354,9 @@ int AppLayerHandleMsg(StreamMsg *smsg, char need_lock)
}
}
if (need_lock == TRUE) sc_mutex_lock(&smsg->flow->m);
if (need_lock == TRUE) SCMutexLock(&smsg->flow->m);
smsg->flow->use_cnt--;
if (need_lock == TRUE) sc_mutex_unlock(&smsg->flow->m);
if (need_lock == TRUE) SCMutexUnlock(&smsg->flow->m);
/* return the used message to the queue */
StreamMsgReturnToPool(smsg);

@ -30,7 +30,7 @@
#include "app-layer-htp.h"
#ifdef DEBUG
static sc_mutex_t htp_state_mem_lock = PTHREAD_MUTEX_INITIALIZER;
static SCMutex htp_state_mem_lock = PTHREAD_MUTEX_INITIALIZER;
static uint64_t htp_state_memuse = 0;
static uint64_t htp_state_memcnt = 0;
#endif
@ -50,10 +50,10 @@ static void *HTPStateAlloc(void)
((HtpState *)(s))->connp = htp_connp_create(cfg);
#ifdef DEBUG
sc_mutex_lock(&htp_state_mem_lock);
SCMutexLock(&htp_state_mem_lock);
htp_state_memcnt++;
htp_state_memuse+=sizeof(HtpState);
sc_mutex_unlock(&htp_state_mem_lock);
SCMutexUnlock(&htp_state_mem_lock);
#endif
return s;
}
@ -70,10 +70,10 @@ static void HTPStateFree(void *s)
free(s);
#ifdef DEBUG
sc_mutex_lock(&htp_state_mem_lock);
SCMutexLock(&htp_state_mem_lock);
htp_state_memcnt--;
htp_state_memuse-=sizeof(HtpState);
sc_mutex_unlock(&htp_state_mem_lock);
SCMutexUnlock(&htp_state_mem_lock);
#endif
}

@ -376,7 +376,7 @@ static int HTTPParseResponse(void *http_state, AppLayerParserState *pstate, uint
}
#ifdef DEBUG
static sc_mutex_t http_state_mem_lock = PTHREAD_MUTEX_INITIALIZER;
static SCMutex http_state_mem_lock = PTHREAD_MUTEX_INITIALIZER;
static uint64_t http_state_memuse = 0;
static uint64_t http_state_memcnt = 0;
#endif
@ -389,10 +389,10 @@ static void *HTTPStateAlloc(void) {
memset(s, 0, sizeof(HttpState));
#ifdef DEBUG
sc_mutex_lock(&http_state_mem_lock);
SCMutexLock(&http_state_mem_lock);
http_state_memcnt++;
http_state_memuse+=sizeof(HttpState);
sc_mutex_unlock(&http_state_mem_lock);
SCMutexUnlock(&http_state_mem_lock);
#endif
return s;
}
@ -400,10 +400,10 @@ static void *HTTPStateAlloc(void) {
static void HTTPStateFree(void *s) {
free(s);
#ifdef DEBUG
sc_mutex_lock(&http_state_mem_lock);
SCMutexLock(&http_state_mem_lock);
http_state_memcnt--;
http_state_memuse-=sizeof(HttpState);
sc_mutex_unlock(&http_state_mem_lock);
SCMutexUnlock(&http_state_mem_lock);
#endif
}
@ -422,9 +422,9 @@ void RegisterHTTPParsers(void) {
void HTTPAtExitPrintStats(void) {
#ifdef DEBUG
sc_mutex_lock(&http_state_mem_lock);
SCMutexLock(&http_state_mem_lock);
SCLogDebug("http_state_memcnt %"PRIu64", http_state_memuse %"PRIu64"", http_state_memcnt, http_state_memuse);
sc_mutex_unlock(&http_state_mem_lock);
SCMutexUnlock(&http_state_mem_lock);
#endif
}

@ -681,9 +681,9 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
if (parser_state_store == NULL)
goto error;
if (need_lock == TRUE) sc_mutex_lock(&f->m);
if (need_lock == TRUE) SCMutexLock(&f->m);
ssn->aldata[app_layer_sid] = (void *)parser_state_store;
if (need_lock == TRUE) sc_mutex_unlock(&f->m);
if (need_lock == TRUE) SCMutexUnlock(&f->m);
}
} else {
SCLogDebug("No App Layer Data");
@ -725,18 +725,18 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
/* See if we already have a 'app layer' state */
void *app_layer_state = NULL;
if (need_lock == TRUE) sc_mutex_lock(&f->m);
if (need_lock == TRUE) SCMutexLock(&f->m);
app_layer_state = ssn->aldata[p->storage_id];
if (need_lock == TRUE) sc_mutex_unlock(&f->m);
if (need_lock == TRUE) SCMutexUnlock(&f->m);
if (app_layer_state == NULL) {
app_layer_state = p->StateAlloc();
if (app_layer_state == NULL)
goto error;
if (need_lock == TRUE) sc_mutex_lock(&f->m);
if (need_lock == TRUE) SCMutexLock(&f->m);
ssn->aldata[p->storage_id] = app_layer_state;
if (need_lock == TRUE) sc_mutex_unlock(&f->m);
if (need_lock == TRUE) SCMutexUnlock(&f->m);
}
/* invoke the recursive parser */
@ -748,9 +748,9 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
/* set the packets to no inspection and reassembly for the TLS sessions */
if (parser_state->flags & APP_LAYER_PARSER_NO_INSPECTION) {
if (need_lock == TRUE) sc_mutex_lock(&f->m);
if (need_lock == TRUE) SCMutexLock(&f->m);
FlowSetNoPayloadInspectionFlag(f);
if (need_lock == TRUE) sc_mutex_unlock(&f->m);
if (need_lock == TRUE) SCMutexUnlock(&f->m);
/* Set the no reassembly flag for both the stream in this TcpSession */
if (parser_state->flags & APP_LAYER_PARSER_NO_REASSEMBLY) {

@ -92,7 +92,7 @@ static void SCPerfInitOPCtx(void)
sc_perf_op_ctx->club_tm = 1;
/* init the lock used by SCPerfClubTMInst */
if (sc_mutex_init(&sc_perf_op_ctx->pctmi_lock, NULL) != 0) {
if (SCMutexInit(&sc_perf_op_ctx->pctmi_lock, NULL) != 0) {
SCLogError(SC_INITIALIZATION_ERROR, "error initializing pctmi mutex");
exit(EXIT_FAILURE);
}
@ -156,9 +156,9 @@ static void *SCPerfMgmtThread(void *arg)
cond_time.tv_sec = time(NULL) + SC_PERF_MGMTT_TTS;
cond_time.tv_nsec = 0;
sc_mutex_lock(tv_local->m);
sc_cond_timedwait(tv_local->cond, tv_local->m, &cond_time);
sc_mutex_unlock(tv_local->m);
SCMutexLock(tv_local->m);
SCCondTimedwait(tv_local->cond, tv_local->m, &cond_time);
SCMutexUnlock(tv_local->m);
SCPerfOutputCounters();
@ -200,9 +200,9 @@ static void *SCPerfWakeupThread(void *arg)
cond_time.tv_sec = time(NULL) + SC_PERF_WUT_TTS;
cond_time.tv_nsec = 0;
sc_mutex_lock(tv_local->m);
sc_cond_timedwait(tv_local->cond, tv_local->m, &cond_time);
sc_mutex_unlock(tv_local->m);
SCMutexLock(tv_local->m);
SCCondTimedwait(tv_local->cond, tv_local->m, &cond_time);
SCMutexUnlock(tv_local->m);
tv = tv_root[TVT_PPT];
while (tv != NULL) {
@ -217,7 +217,7 @@ static void *SCPerfWakeupThread(void *arg)
* not, it should be okay */
tv->sc_perf_pctx.perf_flag = 1;
sc_cond_signal(&q->cond_q);
SCCondSignal(&q->cond_q);
tv = tv->next;
}
@ -701,7 +701,7 @@ static int SCPerfOutputCounterFileIface()
tv = tv_root[i];
while (tv != NULL) {
sc_mutex_lock(&tv->sc_perf_pctx.m);
SCMutexLock(&tv->sc_perf_pctx.m);
pc = tv->sc_perf_pctx.head;
while (pc != NULL) {
@ -728,7 +728,7 @@ static int SCPerfOutputCounterFileIface()
pc = pc->next;
}
sc_mutex_unlock(&tv->sc_perf_pctx.m);
SCMutexUnlock(&tv->sc_perf_pctx.m);
tv = tv->next;
}
fflush(sc_perf_op_ctx->fp);
@ -748,7 +748,7 @@ static int SCPerfOutputCounterFileIface()
for (i = 0; i < pctmi->size; i++) {
pc_heads[i] = pctmi->head[i]->head;
sc_mutex_lock(&pctmi->head[i]->m);
SCMutexLock(&pctmi->head[i]->m);
while(strcmp(pctmi->tm_name, pc_heads[i]->name->tm_name))
pc_heads[i] = pc_heads[i]->next;
@ -799,7 +799,7 @@ static int SCPerfOutputCounterFileIface()
}
for (i = 0; i < pctmi->size; i++)
sc_mutex_unlock(&pctmi->head[i]->m);
SCMutexUnlock(&pctmi->head[i]->m);
pctmi = pctmi->next;
@ -1088,7 +1088,7 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
return 0;
}
sc_mutex_lock(&sc_perf_op_ctx->pctmi_lock);
SCMutexLock(&sc_perf_op_ctx->pctmi_lock);
pctmi = sc_perf_op_ctx->pctmi;
prev = pctmi;
@ -1120,7 +1120,7 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
else
prev->next = temp;
sc_mutex_unlock(&sc_perf_op_ctx->pctmi_lock);
SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
return 1;
}
@ -1129,7 +1129,7 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
if (hpctx[i] != pctx)
continue;
sc_mutex_unlock(&sc_perf_op_ctx->pctmi_lock);
SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
return 1;
}
@ -1148,7 +1148,7 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
}
pctmi->size++;
sc_mutex_unlock(&sc_perf_op_ctx->pctmi_lock);
SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
return 1;
}
@ -1504,7 +1504,7 @@ int SCPerfUpdateCounterArray(SCPerfCounterArray *pca, SCPerfContext *pctx,
pcae = pca->head;
sc_mutex_lock(&pctx->m);
SCMutexLock(&pctx->m);
pc = pctx->head;
for (i = 1; i <= pca->size; i++) {
@ -1523,7 +1523,7 @@ int SCPerfUpdateCounterArray(SCPerfCounterArray *pca, SCPerfContext *pctx,
}
}
sc_mutex_unlock(&pctx->m);
SCMutexUnlock(&pctx->m);
pctx->perf_flag = 0;

@ -119,7 +119,7 @@ typedef struct SCPerfContext_ {
uint16_t curr_id;
/* mutex to prevent simultaneous access during update_counter/output_stat */
sc_mutex_t m;
SCMutex m;
} SCPerfContext;
/**
@ -187,7 +187,7 @@ typedef struct SCPerfOPIfaceContext_ {
uint32_t club_tm;
SCPerfClubTMInst *pctmi;
sc_mutex_t pctmi_lock;
SCMutex pctmi_lock;
} SCPerfOPIfaceContext;

@ -201,7 +201,7 @@ typedef struct Packet_
uint8_t rtv_cnt;
/* tunnel packet ref count */
uint8_t tpr_cnt;
sc_mutex_t mutex_rtv_cnt;
SCMutex mutex_rtv_cnt;
/* tunnel stuff */
uint8_t tunnel_proto;
/* tunnel XXX convert to bitfield*/
@ -297,8 +297,8 @@ typedef struct PacketQueue_ {
Packet *top;
Packet *bot;
uint16_t len;
sc_mutex_t mutex_q;
sc_cond_t cond_q;
SCMutex mutex_q;
SCCondT cond_q;
#ifdef DBG_PERF
uint16_t dbg_maxlen;
#endif /* DBG_PERF */
@ -382,22 +382,22 @@ typedef struct DecodeThreadVars_
#define TUNNEL_INCR_PKT_RTV(p) \
{ \
sc_mutex_lock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
SCMutexLock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
((p)->root ? (p)->root->rtv_cnt++ : (p)->rtv_cnt++); \
sc_mutex_unlock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
SCMutexUnlock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
}
#define TUNNEL_INCR_PKT_TPR(p) \
{ \
sc_mutex_lock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
SCMutexLock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
((p)->root ? (p)->root->tpr_cnt++ : (p)->tpr_cnt++); \
sc_mutex_unlock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
SCMutexUnlock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
}
#define TUNNEL_DECR_PKT_TPR(p) \
{ \
sc_mutex_lock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
SCMutexLock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
((p)->root ? (p)->root->tpr_cnt-- : (p)->tpr_cnt--); \
sc_mutex_unlock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
SCMutexUnlock((p)->root ? &(p)->root->mutex_rtv_cnt : &(p)->mutex_rtv_cnt); \
}
#define TUNNEL_DECR_PKT_TPR_NOLOCK(p) \
{ \

@ -75,13 +75,13 @@ typedef struct _DefragContext {
uint64_t ip6_frags; /**< Number of IPv6 fragments seen. */
HashListTable *frag_table; /**< Hash (list) table of fragment trackers. */
sc_mutex_t frag_table_lock;
SCMutex frag_table_lock;
Pool *tracker_pool; /**< Pool of trackers. */
sc_mutex_t tracker_pool_lock;
SCMutex tracker_pool_lock;
Pool *frag_pool; /**< Pool of fragments. */
sc_mutex_t frag_pool_lock;
SCMutex frag_pool_lock;
time_t timeout; /**< Default timeout. */
@ -133,7 +133,7 @@ typedef struct _DefragTracker {
uint8_t seen_last; /**< Has this tracker seen the last fragment? */
sc_mutex_t lock; /**< Mutex for locking list operations on
SCMutex lock; /**< Mutex for locking list operations on
* this tracker. */
TAILQ_HEAD(frag_tailq, _frag) frags; /**< Head of list of fragments. */
@ -285,7 +285,7 @@ DefragTrackerFreeFrags(DefragTracker *tracker)
Frag *frag;
/* Lock the frag pool as we'll be return items to it. */
sc_mutex_lock(&tracker->dc->frag_pool_lock);
SCMutexLock(&tracker->dc->frag_pool_lock);
while ((frag = TAILQ_FIRST(&tracker->frags)) != NULL) {
TAILQ_REMOVE(&tracker->frags, frag, next);
@ -295,7 +295,7 @@ DefragTrackerFreeFrags(DefragTracker *tracker)
PoolReturn(frag->dc->frag_pool, frag);
}
sc_mutex_unlock(&tracker->dc->frag_pool_lock);
SCMutexUnlock(&tracker->dc->frag_pool_lock);
}
/**
@ -305,7 +305,7 @@ static void
DefragTrackerReset(DefragTracker *tracker)
{
DefragContext *saved_dc = tracker->dc;
sc_mutex_t saved_lock = tracker->lock;
SCMutex saved_lock = tracker->lock;
DefragTrackerFreeFrags(tracker);
memset(tracker, 0, sizeof(*tracker));
@ -332,7 +332,7 @@ DefragTrackerNew(void *arg)
tracker = calloc(1, sizeof(*tracker));
if (tracker == NULL)
return NULL;
if (sc_mutex_init(&tracker->lock, NULL) != 0)
if (SCMutexInit(&tracker->lock, NULL) != 0)
return NULL;
tracker->dc = dc;
TAILQ_INIT(&tracker->frags);
@ -349,7 +349,7 @@ DefragTrackerFree(void *arg)
{
DefragTracker *tracker = arg;
sc_mutex_destroy(&tracker->lock);
SCMutexDestroy(&tracker->lock);
DefragTrackerFreeFrags(tracker);
free(tracker);
}
@ -377,7 +377,7 @@ DefragContextNew(void)
"Defrag: Failed to initialize hash table.");
exit(EXIT_FAILURE);
}
if (sc_mutex_init(&dc->frag_table_lock, NULL) != 0) {
if (SCMutexInit(&dc->frag_table_lock, NULL) != 0) {
SCLogError(SC_ERR_MEM_ALLOC,
"Defrag: Failed to initialize hash table mutex.");
exit(EXIT_FAILURE);
@ -395,7 +395,7 @@ DefragContextNew(void)
"Defrag: Failed to initialize tracker pool.");
exit(EXIT_FAILURE);
}
if (sc_mutex_init(&dc->tracker_pool_lock, NULL) != 0) {
if (SCMutexInit(&dc->tracker_pool_lock, NULL) != 0) {
SCLogError(SC_ERR_MEM_ALLOC,
"Defrag: Failed to initialize tracker pool mutex.");
exit(EXIT_FAILURE);
@ -411,7 +411,7 @@ DefragContextNew(void)
"Defrag: Failed to initialize fragment pool.");
exit(EXIT_FAILURE);
}
if (sc_mutex_init(&dc->frag_pool_lock, NULL) != 0) {
if (SCMutexInit(&dc->frag_pool_lock, NULL) != 0) {
SCLogError(SC_ERR_MEM_ALLOC,
"Defrag: Failed to initialize frag pool mutex.");
exit(EXIT_FAILURE);
@ -479,7 +479,7 @@ Defrag4InsertFrag(DefragContext *dc, DefragTracker *tracker, Packet *p)
* instead of after. */
/* Lock this tracker as we'll be doing list operations on it. */
sc_mutex_lock(&tracker->lock);
SCMutexLock(&tracker->lock);
/* Update timeout. */
tracker->timeout = p->ts;
@ -618,16 +618,16 @@ insert:
}
/* Allocate frag and insert. */
sc_mutex_lock(&dc->frag_pool_lock);
SCMutexLock(&dc->frag_pool_lock);
new = PoolGet(dc->frag_pool);
sc_mutex_unlock(&dc->frag_pool_lock);
SCMutexUnlock(&dc->frag_pool_lock);
if (new == NULL)
goto done;
new->pkt = malloc(len);
if (new->pkt == NULL) {
sc_mutex_lock(&dc->frag_pool_lock);
SCMutexLock(&dc->frag_pool_lock);
PoolReturn(dc->frag_pool, new);
sc_mutex_unlock(&dc->frag_pool_lock);
SCMutexUnlock(&dc->frag_pool_lock);
goto done;
}
BUG_ON(ltrim > len);
@ -651,13 +651,13 @@ insert:
if (remove) {
TAILQ_REMOVE(&tracker->frags, prev, next);
DefragFragReset(prev);
sc_mutex_lock(&dc->frag_pool_lock);
SCMutexLock(&dc->frag_pool_lock);
PoolReturn(dc->frag_pool, prev);
sc_mutex_unlock(&dc->frag_pool_lock);
SCMutexUnlock(&dc->frag_pool_lock);
}
done:
sc_mutex_unlock(&tracker->lock);
SCMutexUnlock(&tracker->lock);
}
/**
@ -676,7 +676,7 @@ Defrag4Reassemble(ThreadVars *tv, DefragContext *dc, DefragTracker *tracker,
int len = 0;
/* Lock the tracker. */
sc_mutex_lock(&tracker->lock);
SCMutexLock(&tracker->lock);
/* Should not be here unless we have seen the last fragment. */
if (!tracker->seen_last)
@ -719,13 +719,13 @@ Defrag4Reassemble(ThreadVars *tv, DefragContext *dc, DefragTracker *tracker,
if (rp == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate packet for fragmentation re-assembly, dumping fragments.");
sc_mutex_lock(&dc->frag_table_lock);
SCMutexLock(&dc->frag_table_lock);
HashListTableRemove(dc->frag_table, tracker, sizeof(tracker));
sc_mutex_unlock(&dc->frag_table_lock);
SCMutexUnlock(&dc->frag_table_lock);
DefragTrackerReset(tracker);
sc_mutex_lock(&dc->tracker_pool_lock);
SCMutexLock(&dc->tracker_pool_lock);
PoolReturn(dc->tracker_pool, tracker);
sc_mutex_unlock(&dc->tracker_pool_lock);
SCMutexUnlock(&dc->tracker_pool_lock);
goto done;
}
@ -786,12 +786,12 @@ Defrag4Reassemble(ThreadVars *tv, DefragContext *dc, DefragTracker *tracker,
/* Remove the frag tracker. */
HashListTableRemove(dc->frag_table, tracker, sizeof(tracker));
DefragTrackerReset(tracker);
sc_mutex_lock(&dc->tracker_pool_lock);
SCMutexLock(&dc->tracker_pool_lock);
PoolReturn(dc->tracker_pool, tracker);
sc_mutex_unlock(&dc->tracker_pool_lock);
SCMutexUnlock(&dc->tracker_pool_lock);
done:
sc_mutex_unlock(&tracker->lock);
SCMutexUnlock(&tracker->lock);
return rp;
}
@ -864,18 +864,18 @@ Defrag4(ThreadVars *tv, DefragContext *dc, Packet *p)
lookup.id = IPV4_GET_IPID(p);
lookup.src_addr = p->src;
lookup.dst_addr = p->dst;
sc_mutex_lock(&dc->frag_table_lock);
SCMutexLock(&dc->frag_table_lock);
tracker = HashListTableLookup(dc->frag_table, &lookup, sizeof(lookup));
sc_mutex_unlock(&dc->frag_table_lock);
SCMutexUnlock(&dc->frag_table_lock);
if (tracker == NULL) {
sc_mutex_lock(&dc->tracker_pool_lock);
SCMutexLock(&dc->tracker_pool_lock);
tracker = PoolGet(dc->tracker_pool);
if (tracker == NULL) {
/* Timeout trackers and try again. */
DefragTimeoutTracker(dc, p);
tracker = PoolGet(dc->tracker_pool);
}
sc_mutex_unlock(&dc->tracker_pool_lock);
SCMutexUnlock(&dc->tracker_pool_lock);
if (tracker == NULL) {
/* Report memory error - actually a pool allocation error. */
SCLogError(SC_ERR_MEM_ALLOC, "Defrag: Failed to allocate tracker.");
@ -890,15 +890,15 @@ Defrag4(ThreadVars *tv, DefragContext *dc, Packet *p)
/* XXX Do policy lookup. */
tracker->policy = dc->default_policy;
sc_mutex_lock(&dc->frag_table_lock);
SCMutexLock(&dc->frag_table_lock);
if (HashListTableAdd(dc->frag_table, tracker, sizeof(*tracker)) != 0) {
/* Failed to add new tracker. */
sc_mutex_unlock(&dc->frag_table_lock);
SCMutexUnlock(&dc->frag_table_lock);
SCLogError(SC_ERR_MEM_ALLOC,
"Defrag: Failed to add new tracker to hash table.");
return NULL;
}
sc_mutex_unlock(&dc->frag_table_lock);
SCMutexUnlock(&dc->frag_table_lock);
}
if (!more_frags) {

@ -63,7 +63,7 @@ int DetectFlowvarMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p
DetectFlowvarData *fd = (DetectFlowvarData *)m->ctx;
/* we need a lock */
sc_mutex_lock(&p->flow->m);
SCMutexLock(&p->flow->m);
FlowVar *fv = FlowVarGet(p->flow, fd->idx);
if (fv != NULL) {
@ -71,7 +71,7 @@ int DetectFlowvarMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p
if (ptr != NULL)
ret = 1;
}
sc_mutex_unlock(&p->flow->m);
SCMutexUnlock(&p->flow->m);
return ret;
}

@ -98,7 +98,7 @@ int DetectTlsVersionMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *
}
int ret = 0;
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
SCLogDebug("looking for tls_data->ver 0x%02X (flags 0x%02X)", tls_data->ver, flags);
if (flags & STREAM_TOCLIENT) {
@ -110,7 +110,7 @@ int DetectTlsVersionMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *
if (tls_data->ver == tls_state->client_version)
ret = 1;
}
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
SCReturnInt(ret);
}

@ -130,9 +130,9 @@ Packet *SetupPktWait (void)
Packet *p = NULL;
int r = 0;
do {
r = sc_mutex_lock(&packet_q.mutex_q);
r = SCMutexLock(&packet_q.mutex_q);
p = PacketDequeue(&packet_q);
sc_mutex_unlock(&packet_q.mutex_q);
SCMutexUnlock(&packet_q.mutex_q);
if (p == NULL) {
//TmqDebugList();
@ -153,9 +153,9 @@ Packet *SetupPkt (void)
Packet *p = NULL;
int r = 0;
r = sc_mutex_lock(&packet_q.mutex_q);
r = SCMutexLock(&packet_q.mutex_q);
p = PacketDequeue(&packet_q);
r = sc_mutex_unlock(&packet_q.mutex_q);
r = SCMutexUnlock(&packet_q.mutex_q);
if (p == NULL) {
TmqDebugList();
@ -168,7 +168,7 @@ Packet *SetupPkt (void)
memset(p, 0, sizeof(Packet));
r = sc_mutex_init(&p->mutex_rtv_cnt, NULL);
r = SCMutexInit(&p->mutex_rtv_cnt, NULL);
SCLogDebug("allocated a new packet...");
}
@ -187,8 +187,8 @@ void GlobalInits()
int blah;
int r = 0;
for(blah=0;blah<256;blah++) {
r |= sc_mutex_init(&trans_q[blah].mutex_q, NULL);
r |= sc_cond_init(&trans_q[blah].cond_q, NULL);
r |= SCMutexInit(&trans_q[blah].mutex_q, NULL);
r |= SCCondInit(&trans_q[blah].cond_q, NULL);
}
if (r != 0) {
@ -196,13 +196,13 @@ void GlobalInits()
exit(EXIT_FAILURE);
}
sc_mutex_init(&mutex_pending, NULL);
sc_cond_init(&cond_pending, NULL);
SCMutexInit(&mutex_pending, NULL);
SCCondInit(&cond_pending, NULL);
/* initialize packet queues Here! */
memset(&packet_q,0,sizeof(packet_q));
sc_mutex_init(&packet_q.mutex_q, NULL);
sc_cond_init(&packet_q.cond_q, NULL);
SCMutexInit(&packet_q.mutex_q, NULL);
SCCondInit(&packet_q.cond_q, NULL);
}
@ -216,9 +216,9 @@ Packet *TunnelPktSetup(ThreadVars *t, DecodeThreadVars *dtv, Packet *parent, uin
int r = 0;
#if 0
do {
r = sc_mutex_lock(&packet_q.mutex_q);
r = SCMutexLock(&packet_q.mutex_q);
p = PacketDequeue(&packet_q);
sc_mutex_unlock(&packet_q.mutex_q);
SCMutexUnlock(&packet_q.mutex_q);
if (p == NULL) {
//TmqDebugList();
@ -229,13 +229,13 @@ Packet *TunnelPktSetup(ThreadVars *t, DecodeThreadVars *dtv, Packet *parent, uin
}
} while (p == NULL);
#endif
r = sc_mutex_lock(&mutex_pending);
r = SCMutexLock(&mutex_pending);
pending++;
#ifdef DBG_PERF
if (pending > dbg_maxpending)
dbg_maxpending = pending;
#endif /* DBG_PERF */
sc_mutex_unlock(&mutex_pending);
SCMutexUnlock(&mutex_pending);
/* set the root ptr to the lowest layer */
if (parent->root != NULL)
@ -543,7 +543,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
memset(p, 0, sizeof(Packet));
sc_mutex_init(&p->mutex_rtv_cnt, NULL);
SCMutexInit(&p->mutex_rtv_cnt, NULL);
PacketEnqueue(&packet_q,p);
}
@ -633,10 +633,10 @@ int main(int argc, char **argv)
if (sigflags & EIDPS_SIGTERM || sigflags & EIDPS_KILL)
break;
sc_mutex_lock(&mutex_pending);
SCMutexLock(&mutex_pending);
if (pending == 0)
done = 1;
sc_mutex_unlock(&mutex_pending);
SCMutexUnlock(&mutex_pending);
if (done == 0) {
usleep(100);

@ -28,8 +28,8 @@ uint32_t pending;
#ifdef DBG_PERF
uint32_t dbg_maxpending;
#endif /* DBG_PERF */
sc_mutex_t mutex_pending;
sc_cond_t cond_pending;
SCMutex mutex_pending;
SCCondT cond_pending;
/* preallocated packet structures here
* XXX move to the packetpool queue handler code

@ -48,12 +48,12 @@ static void FlowBitAdd(Flow *f, uint16_t idx) {
//printf("FlowBitAdd: adding flowbit with idx %" PRIu32 "\n", idx);
#ifdef FLOWBITS_STATS
sc_mutex_lock(&flowbits_mutex);
SCMutexLock(&flowbits_mutex);
flowbits_added++;
flowbits_memuse += sizeof(FlowBit);
if (flowbits_memuse > flowbits_memuse_max)
flowbits_memuse_max = flowbits_memuse;
sc_mutex_unlock(&flowbits_mutex);
SCMutexUnlock(&flowbits_mutex);
#endif /* FLOWBITS_STATS */
}
}
@ -67,7 +67,7 @@ static void FlowBitRemove(Flow *f, uint16_t idx) {
//printf("FlowBitRemove: remove flowbit with idx %" PRIu32 "\n", idx);
#ifdef FLOWBITS_STATS
sc_mutex_lock(&flowbits_mutex);
SCMutexLock(&flowbits_mutex);
flowbits_removed++;
if (flowbits_memuse >= sizeof(FlowBit))
flowbits_memuse -= sizeof(FlowBit);
@ -75,34 +75,34 @@ static void FlowBitRemove(Flow *f, uint16_t idx) {
printf("ERROR: flowbits memory usage going below 0!\n");
flowbits_memuse = 0;
}
sc_mutex_unlock(&flowbits_mutex);
SCMutexUnlock(&flowbits_mutex);
#endif /* FLOWBITS_STATS */
}
void FlowBitSet(Flow *f, uint16_t idx) {
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
FlowBit *fb = FlowBitGet(f, idx);
if (fb == NULL) {
FlowBitAdd(f, idx);
}
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
void FlowBitUnset(Flow *f, uint16_t idx) {
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
FlowBit *fb = FlowBitGet(f, idx);
if (fb != NULL) {
FlowBitRemove(f, idx);
}
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
void FlowBitToggle(Flow *f, uint16_t idx) {
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
FlowBit *fb = FlowBitGet(f, idx);
if (fb != NULL) {
@ -111,32 +111,32 @@ void FlowBitToggle(Flow *f, uint16_t idx) {
FlowBitAdd(f, idx);
}
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
int FlowBitIsset(Flow *f, uint16_t idx) {
int r = 0;
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
FlowBit *fb = FlowBitGet(f, idx);
if (fb != NULL) {
r = 1;
}
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
return r;
}
int FlowBitIsnotset(Flow *f, uint16_t idx) {
int r = 0;
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
FlowBit *fb = FlowBitGet(f, idx);
if (fb == NULL) {
r = 1;
}
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
return r;
}
@ -147,7 +147,7 @@ void FlowBitFree(FlowBit *fb) {
free(fb);
#ifdef FLOWBITS_STATS
sc_mutex_lock(&flowbits_mutex);
SCMutexLock(&flowbits_mutex);
flowbits_removed++;
if (flowbits_memuse >= sizeof(FlowBit))
flowbits_memuse -= sizeof(FlowBit);
@ -155,7 +155,7 @@ void FlowBitFree(FlowBit *fb) {
printf("ERROR: flowbits memory usage going below 0!\n");
flowbits_memuse = 0;
}
sc_mutex_unlock(&flowbits_mutex);
SCMutexUnlock(&flowbits_mutex);
#endif /* FLOWBITS_STATS */
}

@ -77,7 +77,7 @@ Flow *FlowGetFlowFromHash (Packet *p)
uint32_t key = FlowGetKey(p);
/* get our hash bucket and lock it */
FlowBucket *fb = &flow_hash[key];
sc_mutex_lock(&fb->m);
SCMutexLock(&fb->m);
SCLogDebug("FlowGetFlowFromHash: fb %p fb->f %p", fb, fb->f);
@ -90,7 +90,7 @@ Flow *FlowGetFlowFromHash (Packet *p)
f = fb->f = FlowAlloc();
if (f == NULL) {
sc_mutex_unlock(&fb->m);
SCMutexUnlock(&fb->m);
return NULL;
}
}
@ -99,25 +99,25 @@ Flow *FlowGetFlowFromHash (Packet *p)
f->hprev = NULL;
/* got one, now lock, initialize and return */
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
FlowInit(f,p);
FlowRequeue(f, NULL, &flow_new_q[f->protomap]);
f->flags |= FLOW_NEW_LIST;
f->fb = fb;
sc_mutex_unlock(&fb->m);
SCMutexUnlock(&fb->m);
return f;
}
/* ok, we have a flow in the bucket. Let's find out if it is our flow */
f = fb->f;
/* lock the 'root' flow */
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
/* see if this is the flow we are looking for */
if (CMP_FLOW(f, p) == 0) {
Flow *pf = NULL; /* previous flow */
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
while (f) {
pf = f; /* pf is not locked at this point */
@ -131,7 +131,7 @@ Flow *FlowGetFlowFromHash (Packet *p)
f = fb->f = FlowAlloc();
if (f == NULL) {
sc_mutex_unlock(&fb->m);
SCMutexUnlock(&fb->m);
return NULL;
}
}
@ -140,18 +140,18 @@ Flow *FlowGetFlowFromHash (Packet *p)
f->hprev = pf;
/* lock, initialize and return */
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
FlowInit(f,p);
FlowRequeue(f, NULL, &flow_new_q[f->protomap]);
f->flags |= FLOW_NEW_LIST;
f->fb = fb;
sc_mutex_unlock(&fb->m);
SCMutexUnlock(&fb->m);
return f;
}
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
if (CMP_FLOW(f, p) != 0) {
/* we found our flow, lets put it on top of the
@ -165,18 +165,18 @@ Flow *FlowGetFlowFromHash (Packet *p)
fb->f = f;
/* found our flow */
sc_mutex_unlock(&fb->m);
SCMutexUnlock(&fb->m);
return f;
}
/* not found, try the next... */
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
}
/* The 'root' flow was our flow, return it.
* It's already locked. */
sc_mutex_unlock(&fb->m);
SCMutexUnlock(&fb->m);
return f;
}

@ -9,7 +9,7 @@
* to the list, the entire bucket is locked. */
typedef struct FlowBucket_ {
Flow *f;
sc_mutex_t m;
SCMutex m;
} FlowBucket;
/* prototypes */

@ -85,7 +85,7 @@ FlowConfig flow_config;
uint8_t flow_flags;
uint32_t flow_memuse;
sc_mutex_t flow_memuse_mutex;
SCMutex flow_memuse_mutex;
#define FLOWBITS_STATS
#ifdef FLOWBITS_STATS
@ -93,7 +93,7 @@ uint32_t flowbits_memuse;
uint32_t flowbits_memuse_max;
uint32_t flowbits_added;
uint32_t flowbits_removed;
sc_mutex_t flowbits_mutex;
SCMutex flowbits_mutex;
#endif /* FLOWBITS_STATS */
#endif /* __FLOW_PRIVATE_H__ */

@ -23,8 +23,8 @@ FlowQueue *FlowQueueNew() {
FlowQueue *FlowQueueInit (FlowQueue *q) {
if (q != NULL) {
memset(q, 0, sizeof(FlowQueue));
sc_mutex_init(&q->mutex_q, NULL);
sc_cond_init(&q->cond_q, NULL);
SCMutexInit(&q->mutex_q, NULL);
SCCondInit(&q->cond_q, NULL);
}
return q;
}
@ -48,11 +48,11 @@ void FlowEnqueue (FlowQueue *q, Flow *f) {
}
Flow *FlowDequeue (FlowQueue *q) {
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
Flow *f = q->bot;
if (f == NULL) {
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return NULL;
}
@ -71,7 +71,7 @@ Flow *FlowDequeue (FlowQueue *q) {
f->lnext = NULL;
f->lprev = NULL;
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return f;
}
@ -79,7 +79,7 @@ void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq)
{
if (srcq != NULL)
{
sc_mutex_lock(&srcq->mutex_q);
SCMutexLock(&srcq->mutex_q);
/* remove from old queue */
if (srcq->top == f)
@ -97,11 +97,11 @@ void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq)
f->lprev = NULL;
/* don't unlock if src and dst are the same */
if (srcq != dstq) sc_mutex_unlock(&srcq->mutex_q);
if (srcq != dstq) SCMutexUnlock(&srcq->mutex_q);
}
/* now put it in dst */
if (srcq != dstq) sc_mutex_lock(&dstq->mutex_q);
if (srcq != dstq) SCMutexLock(&dstq->mutex_q);
/* add to new queue (append) */
f->lprev = dstq->bot;
@ -118,6 +118,6 @@ void FlowRequeue(Flow *f, FlowQueue *srcq, FlowQueue *dstq)
dstq->dbg_maxlen = dstq->len;
#endif /* DBG_PERF */
sc_mutex_unlock(&dstq->mutex_q);
SCMutexUnlock(&dstq->mutex_q);
}

@ -12,8 +12,8 @@ typedef struct FlowQueue_
Flow *top;
Flow *bot;
uint32_t len;
sc_mutex_t mutex_q;
sc_cond_t cond_q;
SCMutex mutex_q;
SCCondT cond_q;
#ifdef DBG_PERF
uint32_t dbg_maxlen;
#endif /* DBG_PERF */

@ -15,20 +15,20 @@ Flow *FlowAlloc(void)
{
Flow *f;
sc_mutex_lock(&flow_memuse_mutex);
SCMutexLock(&flow_memuse_mutex);
if (flow_memuse + sizeof(Flow) > flow_config.memcap) {
sc_mutex_unlock(&flow_memuse_mutex);
SCMutexUnlock(&flow_memuse_mutex);
return NULL;
}
f = malloc(sizeof(Flow));
if (f == NULL) {
sc_mutex_unlock(&flow_memuse_mutex);
SCMutexUnlock(&flow_memuse_mutex);
return NULL;
}
flow_memuse += sizeof(Flow);
sc_mutex_unlock(&flow_memuse_mutex);
SCMutexUnlock(&flow_memuse_mutex);
sc_mutex_init(&f->m, NULL);
SCMutexInit(&f->m, NULL);
f->lnext = NULL;
f->lprev = NULL;
f->hnext = NULL;
@ -42,9 +42,9 @@ Flow *FlowAlloc(void)
/** free the memory of a flow */
void FlowFree(Flow *f)
{
sc_mutex_lock(&flow_memuse_mutex);
SCMutexLock(&flow_memuse_mutex);
flow_memuse -= sizeof(Flow);
sc_mutex_unlock(&flow_memuse_mutex);
SCMutexUnlock(&flow_memuse_mutex);
free(f);
}

@ -39,7 +39,7 @@ FlowVar *FlowVarGet(Flow *f, uint8_t idx) {
void FlowVarAdd(Flow *f, uint8_t idx, uint8_t *value, uint16_t size) {
//printf("Adding flow var \"%s\" with value(%" PRId32 ") \"%s\"\n", name, size, value);
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
FlowVar *fv = FlowVarGet(f, idx);
if (fv == NULL) {
@ -59,7 +59,7 @@ void FlowVarAdd(Flow *f, uint8_t idx, uint8_t *value, uint16_t size) {
}
out:
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
void FlowVarFree(FlowVar *fv) {

@ -104,7 +104,7 @@ void FlowUpdateQueue(Flow *f)
*/
static int FlowPrune (FlowQueue *q, struct timeval *ts)
{
int mr = sc_mutex_trylock(&q->mutex_q);
int mr = SCMutexTrylock(&q->mutex_q);
if (mr != 0) {
SCLogDebug("Trylock failed!\n");
if (mr == EBUSY)
@ -116,21 +116,21 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
Flow *f = q->top;
if (f == NULL) {
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
SCLogDebug("top was null!\n");
return 0;
}
if (sc_mutex_trylock(&f->m) != 0) {
if (SCMutexTrylock(&f->m) != 0) {
SCLogDebug("cant lock 1!\n");
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return 0;
}
/* unlock list */
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
if (sc_mutex_trylock(&f->fb->m) != 0) {
sc_mutex_unlock(&f->m);
if (SCMutexTrylock(&f->fb->m) != 0) {
SCMutexUnlock(&f->m);
SCLogDebug("cant lock 2!\n");
return 0;
}
@ -184,8 +184,8 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
/* do the timeout check */
if ((f->lastts.tv_sec + timeout) >= ts->tv_sec) {
sc_mutex_unlock(&f->fb->m);
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->fb->m);
SCMutexUnlock(&f->m);
SCLogDebug("timeout check failed!\n");
return 0;
}
@ -194,8 +194,8 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
* we are currently processing in one of the threads */
if (f->use_cnt > 0) {
SCLogDebug("timed out but use_cnt > 0: %"PRIu16", %p, proto %"PRIu8"", f->use_cnt, f, f->proto);
sc_mutex_unlock(&f->fb->m);
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->fb->m);
SCMutexUnlock(&f->m);
SCLogDebug("it is in one of the threads!\n");
return 0;
}
@ -211,7 +211,7 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
f->hnext = NULL;
f->hprev = NULL;
sc_mutex_unlock(&f->fb->m);
SCMutexUnlock(&f->fb->m);
f->fb = NULL;
FlowClearMemory (f, f->protomap);
@ -219,7 +219,7 @@ static int FlowPrune (FlowQueue *q, struct timeval *ts)
/* move to spare list */
FlowRequeue(f, q, &flow_spare_q);
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
return 1;
}
@ -247,11 +247,11 @@ static uint32_t FlowPruneFlows(FlowQueue *q, struct timeval *ts)
static int FlowUpdateSpareFlows(void) {
uint32_t toalloc = 0, tofree = 0, len;
sc_mutex_lock(&flow_spare_q.mutex_q);
SCMutexLock(&flow_spare_q.mutex_q);
len = flow_spare_q.len;
sc_mutex_unlock(&flow_spare_q.mutex_q);
SCMutexUnlock(&flow_spare_q.mutex_q);
if (len < flow_config.prealloc) {
toalloc = flow_config.prealloc - len;
@ -262,9 +262,9 @@ static int FlowUpdateSpareFlows(void) {
if (f == NULL)
return 0;
sc_mutex_lock(&flow_spare_q.mutex_q);
SCMutexLock(&flow_spare_q.mutex_q);
FlowEnqueue(&flow_spare_q,f);
sc_mutex_unlock(&flow_spare_q.mutex_q);
SCMutexUnlock(&flow_spare_q.mutex_q);
}
} else if (len > flow_config.prealloc) {
tofree = len - flow_config.prealloc;
@ -288,9 +288,9 @@ static int FlowUpdateSpareFlows(void) {
* \param direction direction to set the flag in
*/
void FlowSetIPOnlyFlag(Flow *f, char direction) {
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
direction ? (f->flags |= FLOW_TOSERVER_IPONLY_SET) : (f->flags |= FLOW_TOCLIENT_IPONLY_SET);
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
/** \brief decrease the use cnt of a flow
@ -301,10 +301,10 @@ void FlowDecrUsecnt(ThreadVars *tv, Packet *p) {
if (p == NULL || p->flow == NULL)
return;
sc_mutex_lock(&p->flow->m);
SCMutexLock(&p->flow->m);
if (p->flow->use_cnt > 0)
p->flow->use_cnt--;
sc_mutex_unlock(&p->flow->m);
SCMutexUnlock(&p->flow->m);
}
/** \brief Entry point for packet flow handling
@ -362,7 +362,7 @@ void FlowHandlePacket (ThreadVars *tv, Packet *p)
/* set the flow in the packet */
p->flow = f;
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
/** \brief initialize the configuration
@ -382,7 +382,7 @@ void FlowInitConfig (char quiet)
FlowQueueInit(&flow_est_q[ifq]);
FlowQueueInit(&flow_close_q[ifq]);
}
sc_mutex_init(&flow_memuse_mutex, NULL);
SCMutexInit(&flow_memuse_mutex, NULL);
/* set defaults */
flow_config.hash_rand = rand(); /* XXX seed rand */
@ -405,7 +405,7 @@ void FlowInitConfig (char quiet)
memset(flow_hash, 0, flow_config.hash_size * sizeof(FlowBucket));
for (i = 0; i < flow_config.hash_size; i++)
sc_mutex_init(&flow_hash[i].m, NULL);
SCMutexInit(&flow_hash[i].m, NULL);
flow_config.memuse += (flow_config.hash_size * sizeof(FlowBucket));
if (quiet == FALSE)
@ -511,7 +511,7 @@ void FlowShutdown(void) {
free(flow_hash);
flow_memuse -= flow_config.hash_size * sizeof(FlowBucket);
sc_mutex_destroy(&flow_memuse_mutex);
SCMutexDestroy(&flow_memuse_mutex);
}
/** \brief Thread that manages the various queue's and removes timed out flows.
@ -771,9 +771,9 @@ int FlowSetProtoEmergencyTimeout(uint8_t proto, uint32_t emerg_new_timeout, uint
* \param f Flow to set the flag in
*/
void FlowLockSetNoPacketInspectionFlag(Flow *f) {
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
f->flags |= FLOW_NOPACKET_INSPECTION;
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
/** \brief Set the No Packet Inspection Flag without locking the flow.
@ -789,9 +789,9 @@ void FlowSetNoPacketInspectionFlag(Flow *f) {
* \param f Flow to set the flag in
*/
void FlowLockSetNoPayloadInspectionFlag(Flow *f) {
sc_mutex_lock(&f->m);
SCMutexLock(&f->m);
f->flags |= FLOW_NOPAYLOAD_INSPECTION;
sc_mutex_unlock(&f->m);
SCMutexUnlock(&f->m);
}
/** \brief Set the No payload inspection Flag without locking the flow.
@ -899,7 +899,7 @@ static int FlowTestPrune(Flow *f, struct timeval *ts) {
FlowQueue *q = FlowQueueNew();
int r = sc_mutex_init(&q->mutex_q, NULL);
int r = SCMutexInit(&q->mutex_q, NULL);
if (r != 0) {
SCLogDebug("Error initializing mutex!");
@ -945,12 +945,12 @@ static int FlowTest03 (void) {
memset(&f, 0, sizeof(Flow));
memset(&ts, 0, sizeof(ts));
memset(&fb, 0, sizeof(FlowBucket));
sc_mutex_init(&f.m, NULL);
SCMutexInit(&f.m, NULL);
TimeGet(&ts);
f.lastts.tv_sec = ts.tv_sec - 5000;
f.protoctx = &ssn;
sc_mutex_init(&fb.m, NULL);
SCMutexInit(&fb.m, NULL);
f.fb = &fb;
f.proto = IPPROTO_TCP;
@ -985,8 +985,8 @@ static int FlowTest04 (void) {
memset(&seg, 0, sizeof(TcpSegment));
memset(&client, 0, sizeof(TcpSegment));
sc_mutex_init(&f.m, NULL);
sc_mutex_init(&fb.m, NULL);
SCMutexInit(&f.m, NULL);
SCMutexInit(&fb.m, NULL);
TimeGet(&ts);
seg.payload = payload;
@ -1028,8 +1028,8 @@ static int FlowTest05 (void) {
memset(&ts, 0, sizeof(ts));
memset(&fb, 0, sizeof(FlowBucket));
sc_mutex_init(&f.m, NULL);
sc_mutex_init(&fb.m, NULL);
SCMutexInit(&f.m, NULL);
SCMutexInit(&fb.m, NULL);
TimeGet(&ts);
ssn.state = TCP_SYN_SENT;
@ -1069,8 +1069,8 @@ static int FlowTest06 (void) {
memset(&seg, 0, sizeof(TcpSegment));
memset(&client, 0, sizeof(TcpSegment));
sc_mutex_init(&fb.m, NULL);
sc_mutex_init(&f.m, NULL);
SCMutexInit(&fb.m, NULL);
SCMutexInit(&f.m, NULL);
TimeGet(&ts);
seg.payload = payload;

@ -77,7 +77,7 @@ typedef struct Flow_
/** how many pkts and stream msgs are using the flow *right now* */
uint16_t use_cnt;
sc_mutex_t m;
SCMutex m;
/* list flow ptrs
* NOTE!!! These are NOT protected by the

@ -6,7 +6,7 @@
#include "util-bloomfilter-counting.h"
typedef struct HostTable_ {
sc_mutex_t m;
SCMutex m;
/* storage & lookup */
HashTable *hash;
@ -16,7 +16,7 @@ typedef struct HostTable_ {
} HostTable;
typedef struct Host_ {
sc_mutex_t m;
SCMutex m;
Address addr;
uint8_t os;

@ -93,7 +93,7 @@ TmEcode LogHttplogIPv4(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
inet_ntop(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip));
inet_ntop(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip));
sc_mutex_lock(&aft->file_ctx->fp_mutex);
SCMutexLock(&aft->file_ctx->fp_mutex);
for (i = 0; i < p->http_uri.cnt; i++) {
/* time */
fprintf(aft->file_ctx->fp, "%s ", timebuf);
@ -111,7 +111,7 @@ TmEcode LogHttplogIPv4(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
fprintf(aft->file_ctx->fp, " [**] %s:%" PRIu32 " -> %s:%" PRIu32 "\n", srcip, p->sp, dstip, p->dp);
}
fflush(aft->file_ctx->fp);
sc_mutex_unlock(&aft->file_ctx->fp_mutex);
SCMutexUnlock(&aft->file_ctx->fp_mutex);
aft->uri_cnt += p->http_uri.cnt;
return TM_ECODE_OK;
@ -136,7 +136,7 @@ TmEcode LogHttplogIPv6(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
inet_ntop(AF_INET6, (const void *)GET_IPV6_SRC_ADDR(p), srcip, sizeof(srcip));
inet_ntop(AF_INET6, (const void *)GET_IPV6_DST_ADDR(p), dstip, sizeof(dstip));
sc_mutex_lock(&aft->file_ctx->fp_mutex);
SCMutexLock(&aft->file_ctx->fp_mutex);
for (i = 0; i < p->http_uri.cnt; i++) {
/* time */
fprintf(aft->file_ctx->fp, "%s ", timebuf);
@ -154,7 +154,7 @@ TmEcode LogHttplogIPv6(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
fprintf(aft->file_ctx->fp, " [**] %s:%" PRIu32 " -> %s:%" PRIu32 "\n", srcip, p->sp, dstip, p->dp);
}
fflush(aft->file_ctx->fp);
sc_mutex_unlock(&aft->file_ctx->fp_mutex);
SCMutexUnlock(&aft->file_ctx->fp_mutex);
aft->uri_cnt += p->http_uri.cnt;
return TM_ECODE_OK;

@ -36,7 +36,7 @@ Packet *PacketDequeue (PacketQueue *q) {
/* If we are going to get the last packet, set len to 0
* before doing anything else (to make the threads to follow
* the sc_cond_wait as soon as possible) */
* the SCondWait as soon as possible) */
q->len--;
/* pull the bottom packet from the queue */

@ -12,8 +12,8 @@ typedef struct PacketQueue_ {
Packet *top;
Packet *bot;
uint16_t len;
sc_mutex_t mutex_q;
sc_cond_t cond_q;
SCMutex mutex_q;
SCCondT cond_q;
#ifdef DBG_PERF
uint16_t dbg_maxlen;
#endif /* DBG_PERF */

@ -68,7 +68,7 @@ static NFQGlobalVars nfq_g;
static NFQThreadVars nfq_t[NFQ_MAX_QUEUE];
static uint16_t receive_queue_num = 0;
static uint16_t verdict_queue_num = 0;
static sc_mutex_t nfq_init_lock;
static SCMutex nfq_init_lock;
TmEcode ReceiveNFQ(ThreadVars *, Packet *, void *, PacketQueue *);
TmEcode ReceiveNFQThreadInit(ThreadVars *, void *, void **);
@ -86,7 +86,7 @@ void TmModuleReceiveNFQRegister (void) {
/* XXX create a general NFQ setup function */
memset(&nfq_g, 0, sizeof(nfq_g));
memset(&nfq_t, 0, sizeof(nfq_t));
sc_mutex_init(&nfq_init_lock, NULL);
SCMutexInit(&nfq_init_lock, NULL);
tmm_modules[TMM_RECEIVENFQ].name = "ReceiveNFQ";
tmm_modules[TMM_RECEIVENFQ].ThreadInit = ReceiveNFQThreadInit;
@ -264,7 +264,7 @@ TmEcode NFQInitThread(NFQThreadVars *nfq_t, uint16_t queue_num, uint32_t queue_m
}
TmEcode ReceiveNFQThreadInit(ThreadVars *tv, void *initdata, void **data) {
sc_mutex_lock(&nfq_init_lock);
SCMutexLock(&nfq_init_lock);
printf("ReceiveNFQThreadInit: starting... will bind to queuenum %" PRIu32 "\n", receive_queue_num);
sigset_t sigs;
@ -281,18 +281,18 @@ TmEcode ReceiveNFQThreadInit(ThreadVars *tv, void *initdata, void **data) {
if (r < 0) {
printf("NFQInitThread failed\n");
//return -1;
sc_mutex_unlock(&nfq_init_lock);
SCMutexUnlock(&nfq_init_lock);
exit(EXIT_FAILURE);
}
*data = (void *)ntv;
receive_queue_num++;
sc_mutex_unlock(&nfq_init_lock);
SCMutexUnlock(&nfq_init_lock);
return TM_ECODE_OK;
}
TmEcode VerdictNFQThreadInit(ThreadVars *tv, void *initdata, void **data) {
sc_mutex_lock(&nfq_init_lock);
SCMutexLock(&nfq_init_lock);
printf("VerdictNFQThreadInit: starting... will bind to queuenum %" PRIu32 "\n", verdict_queue_num);
/* no initialization, ReceiveNFQ takes care of that */
@ -301,7 +301,7 @@ TmEcode VerdictNFQThreadInit(ThreadVars *tv, void *initdata, void **data) {
*data = (void *)ntv;
verdict_queue_num++;
sc_mutex_unlock(&nfq_init_lock);
SCMutexUnlock(&nfq_init_lock);
return TM_ECODE_OK;
}
@ -338,9 +338,9 @@ void NFQRecvPkt(NFQThreadVars *t) {
//printf("NFQRecvPkt: t %p, rv = %" PRId32 "\n", t, rv);
sc_mutex_lock(&t->mutex_qh);
SCMutexLock(&t->mutex_qh);
ret = nfq_handle_packet(t->h, buf, rv);
sc_mutex_unlock(&t->mutex_qh);
SCMutexUnlock(&t->mutex_qh);
if (ret != 0)
printf("NFQRecvPkt: nfq_handle_packet error %" PRId32 "\n", ret);
@ -357,11 +357,11 @@ TmEcode ReceiveNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq) {
/* check if we have too many packets in the system
* so we will wait for some to free up */
sc_mutex_lock(&mutex_pending);
SCMutexLock(&mutex_pending);
if (pending > MAX_PENDING) {
sc_cond_wait(&cond_pending, &mutex_pending);
SCondWait(&cond_pending, &mutex_pending);
}
sc_mutex_unlock(&mutex_pending);
SCMutexUnlock(&mutex_pending);
return TM_ECODE_OK;
}
@ -405,9 +405,9 @@ void NFQSetVerdict(NFQThreadVars *t, Packet *p) {
if (verdict == NF_DROP) t->dropped++;
#endif /* COUNTERS */
sc_mutex_lock(&t->mutex_qh);
SCMutexLock(&t->mutex_qh);
ret = nfq_set_verdict(t->qh, p->nfq_v.id, verdict, 0, NULL);
sc_mutex_unlock(&t->mutex_qh);
SCMutexUnlock(&t->mutex_qh);
if (ret < 0)
printf("NFQSetVerdict: nfq_set_verdict of %p failed %" PRId32 "\n", p, ret);
@ -422,15 +422,15 @@ TmEcode VerdictNFQ(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq) {
char verdict = 1;
//printf("VerdictNFQ: tunnel pkt: %p %s\n", p, p->root ? "upper layer" : "root");
sc_mutex_t *m = p->root ? &p->root->mutex_rtv_cnt : &p->mutex_rtv_cnt;
sc_mutex_lock(m);
SCMutex *m = p->root ? &p->root->mutex_rtv_cnt : &p->mutex_rtv_cnt;
SCMutexLock(m);
/* if there are more tunnel packets than ready to verdict packets,
* we won't verdict this one */
if (TUNNEL_PKT_TPR(p) > TUNNEL_PKT_RTV(p)) {
//printf("VerdictNFQ: not ready to verdict yet: TUNNEL_PKT_TPR(p) > TUNNEL_PKT_RTV(p) = %" PRId32 " > %" PRId32 "\n", TUNNEL_PKT_TPR(p), TUNNEL_PKT_RTV(p));
verdict = 0;
}
sc_mutex_unlock(m);
SCMutexUnlock(m);
/* don't verdict if we are not ready */
if (verdict == 1) {

@ -30,7 +30,7 @@ typedef struct NFQThreadVars_
struct nfnl_handle *nh;
/* 2 threads deal with the queue handle, so add a mutex */
struct nfq_q_handle *qh;
sc_mutex_t mutex_qh;
SCMutex mutex_qh;
/* this one should be not changing after init */
uint16_t queue_num;
int fd;

@ -74,11 +74,11 @@ void PcapFileCallback(char *user, struct pcap_pkthdr *h, u_char *pkt) {
PcapFileThreadVars *ptv = (PcapFileThreadVars *)user;
//ThreadVars *tv = ptv->tv;
sc_mutex_lock(&mutex_pending);
SCMutexLock(&mutex_pending);
if (pending > MAX_PENDING) {
sc_cond_wait(&cond_pending, &mutex_pending);
SCondWait(&cond_pending, &mutex_pending);
}
sc_mutex_unlock(&mutex_pending);
SCMutexUnlock(&mutex_pending);
Packet *p = ptv->in_p;

@ -86,11 +86,11 @@ void PcapCallback(char *user, struct pcap_pkthdr *h, u_char *pkt) {
PcapThreadVars *ptv = (PcapThreadVars *)user;
ThreadVars *tv = ptv->tv;
sc_mutex_lock(&mutex_pending);
SCMutexLock(&mutex_pending);
if (pending > MAX_PENDING) {
sc_cond_wait(&cond_pending, &mutex_pending);
SCondWait(&cond_pending, &mutex_pending);
}
sc_mutex_unlock(&mutex_pending);
SCMutexUnlock(&mutex_pending);
Packet *p = tv->tmqh_in(tv);
p->ts.tv_sec = h->ts.tv_sec;

@ -37,7 +37,7 @@
//#define DEBUG
#ifdef DEBUG
static sc_mutex_t segment_pool_memuse_mutex;
static SCMutex segment_pool_memuse_mutex;
static uint64_t segment_pool_memuse = 0;
static uint64_t segment_pool_memcnt = 0;
#endif
@ -70,10 +70,10 @@ void *TcpSegmentPoolAlloc(void *payload_len) {
}
#ifdef DEBUG
sc_mutex_lock(&segment_pool_memuse_mutex);
SCMutexLock(&segment_pool_memuse_mutex);
segment_pool_memuse += seg->payload_len;
segment_pool_memcnt ++;
sc_mutex_unlock(&segment_pool_memuse_mutex);
SCMutexUnlock(&segment_pool_memuse_mutex);
#endif
return seg;
}
@ -97,9 +97,9 @@ void TcpSegmentPoolFree(void *ptr) {
static uint16_t segment_pool_pktsizes[segment_pool_num] = {4, 16, 112, 248, 512, 768, 1448, 0xffff};
static uint16_t segment_pool_poolsizes[segment_pool_num] = {2048, 3072, 3072, 3072, 3072, 4096, 8192, 512};
static Pool *segment_pool[segment_pool_num];
static sc_mutex_t segment_pool_mutex[segment_pool_num];
static SCMutex segment_pool_mutex[segment_pool_num];
#ifdef DEBUG
static sc_mutex_t segment_pool_cnt_mutex;
static SCMutex segment_pool_cnt_mutex;
static uint64_t segment_pool_cnt = 0;
#endif
/* index to the right pool for all packet sizes. */
@ -108,12 +108,12 @@ static uint16_t segment_pool_idx[65536]; /* O(1) lookups of the pool */
int StreamTcpReassembleInit(char quiet) {
StreamMsgQueuesInit();
#ifdef DEBUG
sc_mutex_init(&segment_pool_memuse_mutex, NULL);
SCMutexInit(&segment_pool_memuse_mutex, NULL);
#endif
uint16_t u16 = 0;
for (u16 = 0; u16 < segment_pool_num; u16++) {
segment_pool[u16] = PoolInit(segment_pool_poolsizes[u16], segment_pool_poolsizes[u16] / 8, TcpSegmentPoolAlloc, (void *) & segment_pool_pktsizes[u16], TcpSegmentPoolFree);
sc_mutex_init(&segment_pool_mutex[u16], NULL);
SCMutexInit(&segment_pool_mutex[u16], NULL);
}
uint16_t idx = 0;
@ -131,7 +131,7 @@ int StreamTcpReassembleInit(char quiet) {
idx++;
}
#ifdef DEBUG
sc_mutex_init(&segment_pool_cnt_mutex, NULL);
SCMutexInit(&segment_pool_cnt_mutex, NULL);
#endif
return 0;
}
@ -145,7 +145,7 @@ void StreamTcpReassembleFree(char quiet) {
}
PoolFree(segment_pool[u16]);
sc_mutex_destroy(&segment_pool_mutex[u16]);
SCMutexDestroy(&segment_pool_mutex[u16]);
}
#ifdef DEBUG
@ -1352,21 +1352,21 @@ void StreamTcpSegmentDataCopy(TcpSegment *dst_seg, TcpSegment *src_seg) {
TcpSegment* StreamTcpGetSegment(uint16_t len) {
uint16_t idx = segment_pool_idx[len];
SCLogDebug("%" PRIu32 " for payload_len %" PRIu32 "", idx, len);
sc_mutex_lock(&segment_pool_mutex[idx]);
SCMutexLock(&segment_pool_mutex[idx]);
TcpSegment *seg = (TcpSegment *) PoolGet(segment_pool[idx]);
SCLogDebug("segment_pool[%u]->empty_list_size %u, segment_pool[%u]->alloc_list_size %u, alloc %u",
idx, segment_pool[idx]->empty_list_size, idx, segment_pool[idx]->alloc_list_size, segment_pool[idx]->allocated);
//PoolPrintSaturation(segment_pool[idx]);
sc_mutex_unlock(&segment_pool_mutex[idx]);
SCMutexUnlock(&segment_pool_mutex[idx]);
SCLogDebug("StreamTcpGetSegment: seg we return is %p", seg);
if (seg == NULL) {
SCLogDebug("segment_pool[%u]->empty_list_size %u, alloc %u", idx, segment_pool[idx]->empty_list_size, segment_pool[idx]->allocated);
} else {
#ifdef DEBUG
sc_mutex_lock(&segment_pool_cnt_mutex);
SCMutexLock(&segment_pool_cnt_mutex);
segment_pool_cnt++;
sc_mutex_unlock(&segment_pool_cnt_mutex);
SCMutexUnlock(&segment_pool_cnt_mutex);
#endif
}
return seg;
@ -1383,15 +1383,15 @@ void StreamTcpSegmentReturntoPool(TcpSegment *seg) {
seg->prev = NULL;
uint16_t idx = segment_pool_idx[seg->pool_size];
sc_mutex_lock(&segment_pool_mutex[idx]);
SCMutexLock(&segment_pool_mutex[idx]);
PoolReturn(segment_pool[idx], (void *) seg);
SCLogDebug("segment_pool[%"PRIu16"]->empty_list_size %"PRIu32"", idx,segment_pool[idx]->empty_list_size);
sc_mutex_unlock(&segment_pool_mutex[idx]);
SCMutexUnlock(&segment_pool_mutex[idx]);
#ifdef DEBUG
sc_mutex_lock(&segment_pool_cnt_mutex);
SCMutexLock(&segment_pool_cnt_mutex);
segment_pool_cnt--;
sc_mutex_unlock(&segment_pool_cnt_mutex);
SCMutexUnlock(&segment_pool_cnt_mutex);
#endif
}

@ -68,11 +68,11 @@ static int ValidTimestamp(TcpSession * , Packet *);
#define STREAMTCP_EMERG_CLOSED_TIMEOUT 20
static Pool *ssn_pool = NULL;
static sc_mutex_t ssn_pool_mutex;
static SCMutex ssn_pool_mutex;
#ifdef DEBUG
static uint64_t ssn_pool_cnt;
static sc_mutex_t ssn_pool_cnt_mutex;
static SCMutex ssn_pool_cnt_mutex;
#endif
void TmModuleStreamTcpRegister (void) {
@ -116,14 +116,14 @@ void StreamTcpSessionClear(void *ssnptr) {
AppLayerParserCleanupState(ssn);
memset(ssn, 0, sizeof(TcpSession));
sc_mutex_lock(&ssn_pool_mutex);
SCMutexLock(&ssn_pool_mutex);
PoolReturn(ssn_pool, ssn);
sc_mutex_unlock(&ssn_pool_mutex);
SCMutexUnlock(&ssn_pool_mutex);
#ifdef DEBUG
sc_mutex_lock(&ssn_pool_cnt_mutex);
SCMutexLock(&ssn_pool_cnt_mutex);
ssn_pool_cnt--;
sc_mutex_unlock(&ssn_pool_cnt_mutex);
SCMutexUnlock(&ssn_pool_cnt_mutex);
#endif
}
@ -143,16 +143,16 @@ static void StreamTcpSessionPktFree (Packet *p) {
AppLayerParserCleanupState(ssn);
memset(ssn, 0, sizeof(TcpSession));
sc_mutex_lock(&ssn_pool_mutex);
SCMutexLock(&ssn_pool_mutex);
PoolReturn(ssn_pool, p->flow->protoctx);
sc_mutex_unlock(&ssn_pool_mutex);
SCMutexUnlock(&ssn_pool_mutex);
p->flow->protoctx = NULL;
#ifdef DEBUG
sc_mutex_lock(&ssn_pool_cnt_mutex);
SCMutexLock(&ssn_pool_cnt_mutex);
ssn_pool_cnt--;
sc_mutex_unlock(&ssn_pool_cnt_mutex);
SCMutexUnlock(&ssn_pool_cnt_mutex);
#endif
}
@ -210,7 +210,7 @@ void StreamTcpInitConfig(char quiet) {
exit(1);
}
sc_mutex_init(&ssn_pool_mutex, NULL);
SCMutexInit(&ssn_pool_mutex, NULL);
StreamTcpReassembleInit(quiet);
@ -235,7 +235,7 @@ void StreamTcpFreeConfig(char quiet) {
#ifdef DEBUG
SCLogDebug("ssn_pool_cnt %"PRIu64"", ssn_pool_cnt);
#endif
sc_mutex_destroy(&ssn_pool_mutex);
SCMutexDestroy(&ssn_pool_mutex);
}
/** \brief The function is used to to fetch a TCP session from the
@ -249,9 +249,9 @@ TcpSession *StreamTcpNewSession (Packet *p) {
TcpSession *ssn = (TcpSession *)p->flow->protoctx;
if (ssn == NULL) {
sc_mutex_lock(&ssn_pool_mutex);
SCMutexLock(&ssn_pool_mutex);
p->flow->protoctx = PoolGet(ssn_pool);
sc_mutex_unlock(&ssn_pool_mutex);
SCMutexUnlock(&ssn_pool_mutex);
ssn = (TcpSession *)p->flow->protoctx;
if (ssn == NULL)
@ -261,9 +261,9 @@ TcpSession *StreamTcpNewSession (Packet *p) {
ssn->aldata = NULL;
#ifdef DEBUG
sc_mutex_lock(&ssn_pool_cnt_mutex);
SCMutexLock(&ssn_pool_cnt_mutex);
ssn_pool_cnt++;
sc_mutex_unlock(&ssn_pool_cnt_mutex);
SCMutexUnlock(&ssn_pool_cnt_mutex);
#endif
}
@ -1955,9 +1955,9 @@ TmEcode StreamTcp (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq)
if (p->flow == NULL)
return TM_ECODE_OK;
sc_mutex_lock(&p->flow->m);
SCMutexLock(&p->flow->m);
ret = StreamTcpPacket(tv, p, stt);
sc_mutex_unlock(&p->flow->m);
SCMutexUnlock(&p->flow->m);
//if (ret)
// return TM_ECODE_FAILED;

@ -7,7 +7,7 @@
#include "util-pool.h"
#include "util-debug.h"
static sc_mutex_t stream_pool_memuse_mutex;
static SCMutex stream_pool_memuse_mutex;
static uint64_t stream_pool_memuse = 0;
static uint64_t stream_pool_memcnt = 0;
@ -20,7 +20,7 @@ static uint16_t toclient_min_init_chunk_len = 0;
static uint16_t toclient_min_chunk_len = 0;
static Pool *stream_msg_pool = NULL;
static sc_mutex_t stream_msg_pool_mutex = PTHREAD_MUTEX_INITIALIZER;
static SCMutex stream_msg_pool_mutex = PTHREAD_MUTEX_INITIALIZER;
void *StreamMsgAlloc(void *null) {
StreamMsg *s = malloc(sizeof(StreamMsg));
@ -29,10 +29,10 @@ void *StreamMsgAlloc(void *null) {
memset(s, 0, sizeof(StreamMsg));
sc_mutex_lock(&stream_pool_memuse_mutex);
SCMutexLock(&stream_pool_memuse_mutex);
stream_pool_memuse += sizeof(StreamMsg);
stream_pool_memcnt ++;
sc_mutex_unlock(&stream_pool_memuse_mutex);
SCMutexUnlock(&stream_pool_memuse_mutex);
return s;
}
@ -92,38 +92,38 @@ static StreamMsg *StreamMsgDequeue (StreamMsgQueue *q) {
/* Used by stream reassembler to get msgs */
StreamMsg *StreamMsgGetFromPool(void)
{
sc_mutex_lock(&stream_msg_pool_mutex);
SCMutexLock(&stream_msg_pool_mutex);
StreamMsg *s = (StreamMsg *)PoolGet(stream_msg_pool);
sc_mutex_unlock(&stream_msg_pool_mutex);
SCMutexUnlock(&stream_msg_pool_mutex);
return s;
}
/* Used by l7inspection to return msgs to pool */
void StreamMsgReturnToPool(StreamMsg *s) {
sc_mutex_lock(&stream_msg_pool_mutex);
SCMutexLock(&stream_msg_pool_mutex);
PoolReturn(stream_msg_pool, (void *)s);
sc_mutex_unlock(&stream_msg_pool_mutex);
SCMutexUnlock(&stream_msg_pool_mutex);
}
/* Used by l7inspection to get msgs with data */
StreamMsg *StreamMsgGetFromQueue(StreamMsgQueue *q)
{
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
if (q->len == 0) {
struct timespec cond_time;
cond_time.tv_sec = time(NULL) + 5;
cond_time.tv_nsec = 0;
/* if we have no stream msgs in queue, wait... for 5 seconds */
sc_cond_timedwait(&q->cond_q, &q->mutex_q, &cond_time);
SCCondTimedwait(&q->cond_q, &q->mutex_q, &cond_time);
}
if (q->len > 0) {
StreamMsg *s = StreamMsgDequeue(q);
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return s;
} else {
/* return NULL if we have no stream msg. Should only happen on signals. */
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return NULL;
}
}
@ -131,15 +131,15 @@ StreamMsg *StreamMsgGetFromQueue(StreamMsgQueue *q)
/* Used by stream reassembler to fill the queue for l7inspect reading */
void StreamMsgPutInQueue(StreamMsgQueue *q, StreamMsg *s)
{
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
StreamMsgEnqueue(q, s);
SCLogDebug("q->len %" PRIu32 "", q->len);
sc_cond_signal(&q->cond_q);
sc_mutex_unlock(&q->mutex_q);
SCCondSignal(&q->cond_q);
SCMutexUnlock(&q->mutex_q);
}
void StreamMsgQueuesInit(void) {
sc_mutex_init(&stream_pool_memuse_mutex, NULL);
SCMutexInit(&stream_pool_memuse_mutex, NULL);
//memset(&stream_q, 0, sizeof(stream_q));
stream_msg_pool = PoolInit(5000,250,StreamMsgAlloc,NULL,StreamMsgFree);
@ -149,7 +149,7 @@ void StreamMsgQueuesInit(void) {
void StreamMsgQueuesDeinit(char quiet) {
PoolFree(stream_msg_pool);
sc_mutex_destroy(&stream_pool_memuse_mutex);
SCMutexDestroy(&stream_pool_memuse_mutex);
if (quiet == FALSE)
SCLogDebug("stream_pool_memuse %"PRIu64", stream_pool_memcnt %"PRIu64"", stream_pool_memuse, stream_pool_memcnt);
@ -164,8 +164,8 @@ StreamMsgQueue *StreamMsgQueueGetNew(void) {
}
memset(smq, 0x00, sizeof(StreamMsgQueue));
sc_mutex_init(&smq->mutex_q, NULL);
sc_cond_init(&smq->cond_q, NULL);
SCMutexInit(&smq->mutex_q, NULL);
SCCondInit(&smq->cond_q, NULL);
return smq;
}
@ -184,7 +184,7 @@ StreamMsgQueue *StreamMsgQueueGetByPort(uint16_t port) {
/* XXX hack */
void StreamMsgSignalQueueHack(void) {
//sc_cond_signal(&stream_q.cond_q);
//SCCondSignal(&stream_q.cond_q);
}
void StreamMsgQueueSetMinInitChunkLen(uint8_t dir, uint16_t len) {

@ -40,8 +40,8 @@ typedef struct StreamMsgQueue_ {
StreamMsg *top;
StreamMsg *bot;
uint16_t len;
sc_mutex_t mutex_q;
sc_cond_t cond_q;
SCMutex mutex_q;
SCCondT cond_q;
#ifdef DBG_PERF
uint16_t dbg_maxlen;
#endif /* DBG_PERF */

@ -18,13 +18,13 @@
* \brief Test Mutex macros
*/
int ThreadMacrosTest01Mutex(void) {
sc_mutex_t mut;
SCMutex mut;
int r = 0;
r |= sc_mutex_init(&mut, NULL);
r |= sc_mutex_lock(&mut);
r |= (sc_mutex_trylock(&mut) == EBUSY)? 0 : 1;
r |= sc_mutex_unlock(&mut);
r |= sc_mutex_destroy(&mut);
r |= SCMutexInit(&mut, NULL);
r |= SCMutexLock(&mut);
r |= (SCMutexTrylock(&mut) == EBUSY)? 0 : 1;
r |= SCMutexUnlock(&mut);
r |= SCMutexDestroy(&mut);
return (r == 0)? 1 : 0;
}
@ -33,13 +33,13 @@ int ThreadMacrosTest01Mutex(void) {
* \brief Test Spin Macros
*/
int ThreadMacrosTest02Spinlocks(void) {
sc_spin_t mut;
SCSpinlock mut;
int r = 0;
r |= sc_spin_init(&mut, 0);
r |= sc_spin_lock(&mut);
r |= (sc_spin_trylock(&mut) == EBUSY)? 0 : 1;
r |= sc_spin_unlock(&mut);
r |= sc_spin_destroy(&mut);
r |= SCSpinInit(&mut, 0);
r |= SCSpinLock(&mut);
r |= (SCSpinTrylock(&mut) == EBUSY)? 0 : 1;
r |= SCSpinUnlock(&mut);
r |= SCSpinDestroy(&mut);
return (r == 0)? 1 : 0;
}

@ -20,9 +20,9 @@
//#define DBG_THREADS
/** Suricata Mutex */
#define sc_mutex_t pthread_mutex_t
#define sc_mutexattr_t pthread_mutexattr_t
#define sc_mutex_destroy pthread_mutex_destroy
#define SCMutex pthread_mutex_t
#define SCMutexAttr pthread_mutexattr_t
#define SCMutexDestroy pthread_mutex_destroy
/** Mutex Functions */
#ifdef DBG_THREADS
@ -31,7 +31,7 @@
* It is for Mac OS X users;
* If you see a mutex, spinlock or condiion not initialized, report it please!
*/
#define sc_mutex_lock_dbg(mut) ({ \
#define SCMutexLock_dbg(mut) ({ \
printf("%16s(%s:%d): (thread:%"PRIuMAX") locking mutex %p\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), mut); \
int retl = pthread_mutex_lock(mut); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") locked mutex %p ret %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), mut, retl); \
@ -52,7 +52,7 @@
retl; \
})
#define sc_mutex_trylock_dbg(mut) ({ \
#define SCMutexTrylock_dbg(mut) ({ \
printf("%16s(%s:%d): (thread:%"PRIuMAX") trylocking mutex %p\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), mut); \
int rett = pthread_mutex_trylock(mut); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") trylocked mutex %p ret %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), mut, rett); \
@ -69,7 +69,7 @@
rett; \
})
#define sc_mutex_init_dbg(mut, mutattr) ({ \
#define SCMutexInit_dbg(mut, mutattr) ({ \
int ret; \
ret = pthread_mutex_init(mut, mutattr); \
if (ret != 0) { \
@ -91,7 +91,7 @@
ret; \
})
#define sc_mutex_unlock_dbg(mut) ({ \
#define SCMutexUnlock_dbg(mut) ({ \
printf("%16s(%s:%d): (thread:%"PRIuMAX") unlocking mutex %p\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), mut); \
int retu = pthread_mutex_unlock(mut); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") unlocked mutex %p ret %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), mut, retu); \
@ -108,55 +108,55 @@
retu; \
})
#define sc_mutex_init(mut, mutattrs) sc_mutex_init_dbg(mut, mutattrs)
#define sc_mutex_lock(mut) sc_mutex_lock_dbg(mut)
#define sc_mutex_trylock(mut) sc_mutex_trylock_dbg(mut)
#define sc_mutex_unlock(mut) sc_mutex_unlock_dbg(mut)
#define SCMutexInit(mut, mutattrs) SCMutexInit_dbg(mut, mutattrs)
#define SCMutexLock(mut) SCMutexLock_dbg(mut)
#define SCMutexTrylock(mut) SCMutexTrylock_dbg(mut)
#define SCMutexUnlock(mut) SCMutexUnlock_dbg(mut)
#else
#define sc_mutex_init(mut, mutattr ) pthread_mutex_init(mut, mutattr)
#define sc_mutex_lock(mut) pthread_mutex_lock(mut)
#define sc_mutex_trylock(mut) pthread_mutex_trylock(mut)
#define sc_mutex_unlock(mut) pthread_mutex_unlock(mut)
#define SCMutexInit(mut, mutattr ) pthread_mutex_init(mut, mutattr)
#define SCMutexLock(mut) pthread_mutex_lock(mut)
#define SCMutexTrylock(mut) pthread_mutex_trylock(mut)
#define SCMutexUnlock(mut) pthread_mutex_unlock(mut)
#endif
/** Conditions/Signals */
/* Here we don't need to do nothing atm */
#define sc_cond_t pthread_cond_t
#define sc_cond_init pthread_cond_init
#define sc_cond_signal pthread_cond_signal
#define sc_cond_timedwait pthread_cond_timedwait
#define SCCondT pthread_cond_t
#define SCCondInit pthread_cond_init
#define SCCondSignal pthread_cond_signal
#define SCCondTimedwait pthread_cond_timedwait
#ifdef DBG_THREAD
#define sc_cond_wait_dbg(cond, mut) ({ \
#define SCondWait_dbg(cond, mut) ({ \
int ret = pthread_cond_wait(cond, mut); \
switch (ret) { \
case EINVAL: \
printf("The value specified by attr is invalid (or a sc_cond_t not initialized!)\n"); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") failed sc_cond_wait %p ret %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), mut, retu); \
printf("The value specified by attr is invalid (or a SCCondT not initialized!)\n"); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") failed SCondWait %p ret %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), mut, retu); \
break; \
} \
ret; \
})
#define sc_cond_wait sc_cond_wait_dbg
#define SCondWait SCondWait_dbg
#else
#define sc_cond_wait(cond, mut) pthread_cond_wait(cond, mut)
#define SCondWait(cond, mut) pthread_cond_wait(cond, mut)
#endif
/** Spinlocks */
#define sc_spin_t pthread_spinlock_t
#define SCSpinlock pthread_spinlock_t
/** If posix spin not supported, use mutex */
#if ((_POSIX_SPIN_LOCKS - 200112L) < 0L)
#define pthread_spinlock_t pthread_mutex_t
#define pthread_spin_init(target,arg) sc_mutex_init(target, NULL)
#define pthread_spin_lock(spin) sc_mutex_lock(spin)
#define pthread_spin_trylock(spin) sc_mutex_trylock(spin)
#define pthread_spin_unlock(spin) sc_mutex_unlock(spin)
#define pthread_spin_destroy(spin) sc_mutex_destroy(spin)
#define pthread_spin_init(target,arg) SCMutexInit(target, NULL)
#define pthread_spin_lock(spin) SCMutexLock(spin)
#define pthread_spin_trylock(spin) SCMutexTrylock(spin)
#define pthread_spin_unlock(spin) SCMutexUnlock(spin)
#define pthread_spin_destroy(spin) SCMutexDestroy(spin)
#endif /* End Spin not supported */
#ifdef DBG_THREADS
#define sc_spin_lock_dbg(spin) ({ \
#define SCSpinLock_dbg(spin) ({ \
printf("%16s(%s:%d): (thread:%"PRIuMAX") locking spin %p\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin); \
int ret = pthread_spin_lock(spin); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") unlocked spin %p ret %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin, ret); \
@ -171,7 +171,7 @@
ret; \
})
#define sc_spin_trylock_dbg(spin) ({ \
#define SCSpinTrylock_dbg(spin) ({ \
printf("%16s(%s:%d): (thread:%"PRIuMAX") trylocking spin %p\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin); \
int ret = pthread_spin_trylock(spin); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") trylocked spin %p ret %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin, ret); \
@ -189,7 +189,7 @@
ret; \
})
#define sc_spin_unlock_dbg(spin) ({ \
#define SCSpinUnlock_dbg(spin) ({ \
printf("%16s(%s:%d): (thread:%"PRIuMAX") unlocking spin %p\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin); \
int ret = pthread_spin_unlock(spin); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") unlockedspin %p ret %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin, ret); \
@ -204,7 +204,7 @@
ret; \
})
#define sc_spin_init_dbg(spin, spin_attr) ({ \
#define SCSpinInit_dbg(spin, spin_attr) ({ \
int ret = pthread_spin_init(spin, spin_attr); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") spinlock %p initialization returned %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin, ret); \
switch (ret) { \
@ -224,7 +224,7 @@
ret; \
})
#define sc_spin_destroy_dbg(spin) ({ \
#define SCSpinDestroy_dbg(spin) ({ \
printf("%16s(%s:%d): (thread:%"PRIuMAX") condition %p waiting\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin); \
int ret = pthread_spin_destroy(spin); \
printf("%16s(%s:%d): (thread:%"PRIuMAX") condition %p passed %" PRId32 "\n", __FUNCTION__, __FILE__, __LINE__, (uintmax_t)pthread_self(), spin, ret); \
@ -245,17 +245,17 @@
ret; \
})
#define sc_spin_lock sc_spin_lock_dbg
#define sc_spin_trylock sc_spin_trylock_dbg
#define sc_spin_unlock sc_spin_unlock_dbg
#define sc_spin_init sc_spin_init_dbg
#define sc_spin_destroy sc_spin_destroy_dbg
#define SCSpinLock SCSpinLock_dbg
#define SCSpinTrylock SCSpinTrylock_dbg
#define SCSpinUnlock SCSpinUnlock_dbg
#define SCSpinInit SCSpinInit_dbg
#define SCSpinDestroy SCSpinDestroy_dbg
#else /* if no dbg threads defined... */
#define sc_spin_lock(spin) pthread_spin_lock(spin)
#define sc_spin_trylock(spin) pthread_spin_trylock(spin)
#define sc_spin_unlock(spin) pthread_spin_unlock(spin)
#define sc_spin_init(spin, spin_attr) pthread_spin_init(spin, spin_attr)
#define sc_spin_destroy(spin) pthread_spin_destroy(spin)
#define SCSpinLock(spin) pthread_spin_lock(spin)
#define SCSpinTrylock(spin) pthread_spin_trylock(spin)
#define SCSpinUnlock(spin) pthread_spin_unlock(spin)
#define SCSpinInit(spin, spin_attr) pthread_spin_init(spin, spin_attr)
#define SCSpinDestroy(spin) pthread_spin_destroy(spin)
#endif /* DBG_THREADS */

@ -30,7 +30,7 @@ typedef struct ThreadVars_ {
char *name;
uint8_t flags;
sc_spin_t flags_spinlock;
SCSpinlock flags_spinlock;
/** aof(action on failure) determines what should be done with the thread
when it encounters certain conditions like failures */
@ -62,8 +62,8 @@ typedef struct ThreadVars_ {
SCPerfContext sc_perf_pctx;
SCPerfCounterArray *sc_perf_pca;
sc_mutex_t *m;
sc_cond_t *cond;
SCMutex *m;
SCCondT *cond;
struct ThreadVars_ *next;
struct ThreadVars_ *prev;

@ -55,8 +55,8 @@ LogFileCtx *LogFileNewCtx()
}
memset(lf_ctx, 0, sizeof(LogFileCtx));
/** Ensure that it is unlocked */
sc_mutex_init(&lf_ctx->fp_mutex,NULL);
sc_mutex_unlock(&lf_ctx->fp_mutex);
SCMutexInit(&lf_ctx->fp_mutex,NULL);
SCMutexUnlock(&lf_ctx->fp_mutex);
return lf_ctx;
}
@ -73,9 +73,9 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
{
if (lf_ctx->fp != NULL)
{
sc_mutex_lock(&lf_ctx->fp_mutex);
SCMutexLock(&lf_ctx->fp_mutex);
fclose(lf_ctx->fp);
sc_mutex_unlock(&lf_ctx->fp_mutex);
SCMutexUnlock(&lf_ctx->fp_mutex);
}
if (lf_ctx->config_file != NULL);
free(lf_ctx->config_file);

@ -56,7 +56,7 @@ typedef struct LogFileCtx_ {
FILE *fp;
/** It will be locked if the log/alert
* record cannot be written to the file in one call */
sc_mutex_t fp_mutex;
SCMutex fp_mutex;
/** To know where did we read this config */
char *config_file;

@ -50,9 +50,9 @@ void TmqDebugList(void) {
uint16_t i = 0;
for (i = 0; i < tmq_id; i++) {
/* get a lock accessing the len */
sc_mutex_lock(&trans_q[tmqs[i].id].mutex_q);
SCMutexLock(&trans_q[tmqs[i].id].mutex_q);
printf("TmqDebugList: id %" PRIu32 ", name \'%s\', len %" PRIu32 "\n", tmqs[i].id, tmqs[i].name, trans_q[tmqs[i].id].len);
sc_mutex_unlock(&trans_q[tmqs[i].id].mutex_q);
SCMutexUnlock(&trans_q[tmqs[i].id].mutex_q);
}
}
@ -71,7 +71,7 @@ void TmValidateQueueState(void)
char err = FALSE;
for (i = 0; i < tmq_id; i++) {
sc_mutex_lock(&trans_q[tmqs[i].id].mutex_q);
SCMutexLock(&trans_q[tmqs[i].id].mutex_q);
if (tmqs[i].reader_cnt == 0) {
printf("Error: Queue \"%s\" doesn't have a reader\n", tmqs[i].name);
err = TRUE;
@ -79,7 +79,7 @@ void TmValidateQueueState(void)
printf("Error: Queue \"%s\" doesn't have a writer\n", tmqs[i].name);
err = TRUE;
}
sc_mutex_unlock(&trans_q[tmqs[i].id].mutex_q);
SCMutexUnlock(&trans_q[tmqs[i].id].mutex_q);
if (err == TRUE)
goto error;

@ -37,7 +37,7 @@ static int SetCPUAffinity(int cpu);
ThreadVars *tv_root[TVT_MAX] = { NULL };
/* lock to protect tv_root */
sc_mutex_t tv_root_lock = PTHREAD_MUTEX_INITIALIZER;
SCMutex tv_root_lock = PTHREAD_MUTEX_INITIALIZER;
/* Action On Failure(AOF). Determines how the engine should behave when a
thread encounters a failure. Defaults to restart the failed thread */
@ -75,34 +75,34 @@ typedef struct TmVarSlot_ {
*/
inline int TmThreadsCheckFlag(ThreadVars *tv, uint8_t flag) {
int r;
if (sc_spin_lock(&tv->flags_spinlock) != 0) {
if (SCSpinLock(&tv->flags_spinlock) != 0) {
SCLogError(SC_SPINLOCK_ERROR,"spin lock errno=%d",errno);
return 0;
}
r = (tv->flags & flag);
sc_spin_unlock(&tv->flags_spinlock);
SCSpinUnlock(&tv->flags_spinlock);
return r;
}
inline void TmThreadsSetFlag(ThreadVars *tv, uint8_t flag) {
if (sc_spin_lock(&tv->flags_spinlock) != 0) {
if (SCSpinLock(&tv->flags_spinlock) != 0) {
SCLogError(SC_SPINLOCK_ERROR,"spin lock errno=%d",errno);
return;
}
tv->flags |= flag;
sc_spin_unlock(&tv->flags_spinlock);
SCSpinUnlock(&tv->flags_spinlock);
}
inline void TmThreadsUnsetFlag(ThreadVars *tv, uint8_t flag) {
if (sc_spin_lock(&tv->flags_spinlock) != 0) {
if (SCSpinLock(&tv->flags_spinlock) != 0) {
SCLogError(SC_SPINLOCK_ERROR,"spin lock errno=%d",errno);
return;
}
tv->flags &= ~flag;
sc_spin_unlock(&tv->flags_spinlock);
SCSpinUnlock(&tv->flags_spinlock);
}
/* 1 slot functions */
@ -636,8 +636,8 @@ ThreadVars *TmThreadCreate(char *name, char *inq_name, char *inqh_name,
if (tv == NULL) goto error;
memset(tv, 0, sizeof(ThreadVars));
sc_spin_init(&tv->flags_spinlock, PTHREAD_PROCESS_PRIVATE);
sc_mutex_init(&tv->sc_perf_pctx.m, NULL);
SCSpinInit(&tv->flags_spinlock, PTHREAD_PROCESS_PRIVATE);
SCMutexInit(&tv->sc_perf_pctx.m, NULL);
tv->name = name;
/* default state for every newly created thread */
@ -769,7 +769,7 @@ ThreadVars *TmThreadCreateMgmtThread(char *name, void *(fn_p)(void *),
*/
void TmThreadAppend(ThreadVars *tv, int type)
{
sc_mutex_lock(&tv_root_lock);
SCMutexLock(&tv_root_lock);
if (tv_root[type] == NULL) {
tv_root[type] = tv;
@ -777,7 +777,7 @@ void TmThreadAppend(ThreadVars *tv, int type)
tv->prev = NULL;
//printf("TmThreadAppend: thread \'%s\' is the first thread in the list.\n", tv->name);
sc_mutex_unlock(&tv_root_lock);
SCMutexUnlock(&tv_root_lock);
return;
}
@ -794,7 +794,7 @@ void TmThreadAppend(ThreadVars *tv, int type)
t = t->next;
}
sc_mutex_unlock(&tv_root_lock);
SCMutexUnlock(&tv_root_lock);
//printf("TmThreadAppend: thread \'%s\' is added to the list.\n", tv->name);
}
@ -819,12 +819,12 @@ void TmThreadKillThreads(void) {
//printf("TmThreadKillThreads: (t->inq->reader_cnt + t->inq->writer_cnt) %" PRIu32 "\n", (t->inq->reader_cnt + t->inq->writer_cnt));
/* make sure our packet pending counter doesn't block */
sc_cond_signal(&cond_pending);
SCCondSignal(&cond_pending);
/* signal the queue for the number of users */
for (i = 0; i < (tv->inq->reader_cnt + tv->inq->writer_cnt); i++)
sc_cond_signal(&trans_q[tv->inq->id].cond_q);
SCCondSignal(&trans_q[tv->inq->id].cond_q);
/* to be sure, signal more */
int cnt = 0;
@ -837,7 +837,7 @@ void TmThreadKillThreads(void) {
cnt++;
for (i = 0; i < (tv->inq->reader_cnt + tv->inq->writer_cnt); i++)
sc_cond_signal(&trans_q[tv->inq->id].cond_q);
SCCondSignal(&trans_q[tv->inq->id].cond_q);
usleep(100);
}
@ -935,22 +935,22 @@ void TmThreadSetAOF(ThreadVars *tv, uint8_t aof)
*/
void TmThreadInitMC(ThreadVars *tv)
{
if ( (tv->m = malloc(sizeof(sc_mutex_t))) == NULL) {
if ( (tv->m = malloc(sizeof(SCMutex))) == NULL) {
printf("Error allocating memory\n");
exit(0);
}
if (sc_mutex_init(tv->m, NULL) != 0) {
if (SCMutexInit(tv->m, NULL) != 0) {
printf("Error initializing the tv->m mutex\n");
exit(0);
}
if ( (tv->cond = malloc(sizeof(sc_cond_t))) == NULL) {
if ( (tv->cond = malloc(sizeof(SCCondT))) == NULL) {
printf("Error allocating memory\n");
exit(0);
}
if (sc_cond_init(tv->cond, NULL) != 0) {
if (SCCondInit(tv->cond, NULL) != 0) {
printf("Error initializing the tv->cond condition variable\n");
exit(0);
}
@ -1154,20 +1154,20 @@ ThreadVars *TmThreadsGetCallingThread(void)
ThreadVars *tv = NULL;
int i = 0;
sc_mutex_lock(&tv_root_lock);
SCMutexLock(&tv_root_lock);
for (i = 0; i < TVT_MAX; i++) {
tv = tv_root[i];
while (tv) {
if (pthread_equal(self, tv->t)) {
sc_mutex_unlock(&tv_root_lock);
SCMutexUnlock(&tv_root_lock);
return tv;
}
tv = tv->next;
}
}
sc_mutex_unlock(&tv_root_lock);
SCMutexUnlock(&tv_root_lock);
return NULL;
}

@ -12,7 +12,7 @@ enum {
extern ThreadVars *tv_root[TVT_MAX];
extern sc_mutex_t tv_root_lock;
extern SCMutex tv_root_lock;
void Tm1SlotSetFunc(ThreadVars *, TmModule *, void *);

@ -49,10 +49,10 @@ Packet *TmqhInputFlow(ThreadVars *tv)
{
PacketQueue *q = &trans_q[tv->inq->id];
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
if (q->len == 0) {
/* if we have no packets in queue, wait... */
sc_cond_wait(&q->cond_q, &q->mutex_q);
SCondWait(&q->cond_q, &q->mutex_q);
}
if (tv->sc_perf_pctx.perf_flag == 1)
@ -60,11 +60,11 @@ Packet *TmqhInputFlow(ThreadVars *tv)
if (q->len > 0) {
Packet *p = PacketDequeue(q);
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return p;
} else {
/* return NULL if we have no pkt. Should only happen on signals. */
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return NULL;
}
}
@ -177,10 +177,10 @@ void TmqhOutputFlow(ThreadVars *tv, Packet *p)
}
PacketQueue *q = &trans_q[qid];
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
PacketEnqueue(q, p);
sc_cond_signal(&q->cond_q);
sc_mutex_unlock(&q->mutex_q);
SCCondSignal(&q->cond_q);
SCMutexUnlock(&q->mutex_q);
}
#ifdef UNITTESTS

@ -22,10 +22,10 @@ void TmqhOutputVerdictNfq(ThreadVars *t, Packet *p)
#if 0
PacketQueue *q = &trans_q[p->verdict_q_id];
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
PacketEnqueue(q, p);
sc_cond_signal(&q->cond_q);
sc_mutex_unlock(&q->mutex_q);
SCCondSignal(&q->cond_q);
SCMutexUnlock(&q->mutex_q);
#endif
}

@ -26,14 +26,14 @@ Packet *TmqhInputPacketpool(ThreadVars *t)
/* XXX */
Packet *p = SetupPkt();
sc_mutex_lock(&mutex_pending);
SCMutexLock(&mutex_pending);
pending++;
//printf("PcapFileCallback: pending %" PRIu32 "\n", pending);
#ifdef DBG_PERF
if (pending > dbg_maxpending)
dbg_maxpending = pending;
#endif /* DBG_PERF */
sc_mutex_unlock(&mutex_pending);
SCMutexUnlock(&mutex_pending);
/*
* Disabled because it can enter a 'wait' state, while
@ -41,11 +41,11 @@ Packet *TmqhInputPacketpool(ThreadVars *t)
* to free packets, the exact condition we are waiting
* for. VJ 09-01-16
*
sc_mutex_lock(&mutex_pending);
SCMutexLock(&mutex_pending);
if (pending > MAX_PENDING) {
sc_cond_wait(&cond_pending, &mutex_pending);
SCondWait(&cond_pending, &mutex_pending);
}
sc_mutex_unlock(&mutex_pending);
SCMutexUnlock(&mutex_pending);
*/
return p;
}
@ -62,8 +62,8 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
//printf("TmqhOutputPacketpool: tunnel packet: %p %s\n", p,p->root ? "upper layer":"root");
/* get a lock */
sc_mutex_t *m = p->root ? &p->root->mutex_rtv_cnt : &p->mutex_rtv_cnt;
sc_mutex_lock(m);
SCMutex *m = p->root ? &p->root->mutex_rtv_cnt : &p->mutex_rtv_cnt;
SCMutexLock(m);
if (IS_TUNNEL_ROOT_PKT(p)) {
//printf("TmqhOutputPacketpool: IS_TUNNEL_ROOT_PKT\n");
@ -80,7 +80,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
* by the tunnel packets, and we will enqueue it
* when we handle them */
p->tunnel_verdicted = 1;
sc_mutex_unlock(m);
SCMutexUnlock(m);
return;
}
} else {
@ -103,7 +103,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
/* fall through */
}
}
sc_mutex_unlock(m);
SCMutexUnlock(m);
//printf("TmqhOutputPacketpool: tunnel stuff done, move on\n");
}
@ -112,18 +112,18 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
if (proot && p->root != NULL) {
CLEAR_PACKET(p->root);
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
PacketEnqueue(q, p->root);
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
}
CLEAR_PACKET(p);
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
PacketEnqueue(q, p);
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
sc_mutex_lock(&mutex_pending);
SCMutexLock(&mutex_pending);
//printf("TmqhOutputPacketpool: pending %" PRIu32 "\n", pending);
if (pending > 0) {
pending--;
@ -138,8 +138,8 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
printf("TmqhOutputPacketpool: warning, trying to subtract from 0 pending counter.\n");
}
if (pending <= MAX_PENDING)
sc_cond_signal(&cond_pending);
sc_mutex_unlock(&mutex_pending);
SCCondSignal(&cond_pending);
SCMutexUnlock(&mutex_pending);
}
/**
@ -157,12 +157,12 @@ void TmqhReleasePacketsToPacketPool(PacketQueue *pq)
if (pq == NULL)
return;
sc_mutex_lock(&pq->mutex_q);
SCMutexLock(&pq->mutex_q);
while ( (p = PacketDequeue(pq)) != NULL)
TmqhOutputPacketpool(NULL, p);
sc_mutex_unlock(&pq->mutex_q);
SCMutexUnlock(&pq->mutex_q);
return;
}

@ -20,10 +20,10 @@ Packet *TmqhInputSimple(ThreadVars *t)
{
PacketQueue *q = &trans_q[t->inq->id];
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
if (q->len == 0) {
/* if we have no packets in queue, wait... */
sc_cond_wait(&q->cond_q, &q->mutex_q);
SCondWait(&q->cond_q, &q->mutex_q);
}
if (t->sc_perf_pctx.perf_flag == 1)
@ -31,11 +31,11 @@ Packet *TmqhInputSimple(ThreadVars *t)
if (q->len > 0) {
Packet *p = PacketDequeue(q);
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return p;
} else {
/* return NULL if we have no pkt. Should only happen on signals. */
sc_mutex_unlock(&q->mutex_q);
SCMutexUnlock(&q->mutex_q);
return NULL;
}
}
@ -44,9 +44,9 @@ void TmqhOutputSimple(ThreadVars *t, Packet *p)
{
PacketQueue *q = &trans_q[t->outq->id];
sc_mutex_lock(&q->mutex_q);
SCMutexLock(&q->mutex_q);
PacketEnqueue(q, p);
sc_cond_signal(&q->cond_q);
sc_mutex_unlock(&q->mutex_q);
SCCondSignal(&q->cond_q);
SCMutexUnlock(&q->mutex_q);
}

@ -33,7 +33,7 @@ static SCLogFGFilterFile *sc_log_fg_filters[SC_LOG_FILTER_MAX] = { NULL, NULL };
/**
* \brief Mutex for accessing the fine-grained fiters sc_log_fg_filters
*/
static sc_mutex_t sc_log_fg_filters_m[SC_LOG_FILTER_MAX] = { PTHREAD_MUTEX_INITIALIZER,
static SCMutex sc_log_fg_filters_m[SC_LOG_FILTER_MAX] = { PTHREAD_MUTEX_INITIALIZER,
PTHREAD_MUTEX_INITIALIZER };
/**
@ -44,7 +44,7 @@ static SCLogFDFilter *sc_log_fd_filters = NULL;
/**
* \brief Mutex for accessing the function-dependent filters sc_log_fd_filters
*/
static sc_mutex_t sc_log_fd_filters_m = PTHREAD_MUTEX_INITIALIZER;
static SCMutex sc_log_fd_filters_m = PTHREAD_MUTEX_INITIALIZER;
/**
* \brief Holds the thread_list required by function-dependent filters
@ -54,7 +54,7 @@ static SCLogFDFilterThreadList *sc_log_fd_filters_tl = NULL;
/**
* \brief Mutex for accessing the FD thread_list sc_log_fd_filters_tl
*/
static sc_mutex_t sc_log_fd_filters_tl_m = PTHREAD_MUTEX_INITIALIZER;
static SCMutex sc_log_fd_filters_tl_m = PTHREAD_MUTEX_INITIALIZER;
/**
@ -246,9 +246,9 @@ static inline int SCLogAddFGFilter(const char *file, const char *function,
return -1;
}
sc_mutex_t *m = &sc_log_fg_filters_m[listtype];
SCMutex *m = &sc_log_fg_filters_m[listtype];
sc_mutex_lock(m);
SCMutexLock(m);
fgf_file = sc_log_fg_filters[listtype];
@ -315,7 +315,7 @@ static inline int SCLogAddFGFilter(const char *file, const char *function,
}
done:
sc_mutex_unlock(&sc_log_fg_filters_m[listtype]);
SCMutexUnlock(&sc_log_fg_filters_m[listtype]);
sc_log_fg_filters_present = 1;
return 0;
@ -351,12 +351,12 @@ static int SCLogMatchFGFilter(const char *file, const char *function, int line,
return -1;
}
sc_mutex_lock(&sc_log_fg_filters_m[listtype]);
SCMutexLock(&sc_log_fg_filters_m[listtype]);
fgf_file = sc_log_fg_filters[listtype];
if (fgf_file == NULL) {
sc_mutex_unlock(&sc_log_fg_filters_m[listtype]);
SCMutexUnlock(&sc_log_fg_filters_m[listtype]);
return 1;
}
@ -400,7 +400,7 @@ static int SCLogMatchFGFilter(const char *file, const char *function, int line,
}
if (match == 1) {
sc_mutex_unlock(&sc_log_fg_filters_m[listtype]);
SCMutexUnlock(&sc_log_fg_filters_m[listtype]);
if (listtype == SC_LOG_FILTER_WL)
return 1;
else
@ -410,7 +410,7 @@ static int SCLogMatchFGFilter(const char *file, const char *function, int line,
fgf_file = fgf_file->next;
}
sc_mutex_unlock(&sc_log_fg_filters_m[listtype]);
SCMutexUnlock(&sc_log_fg_filters_m[listtype]);
if (listtype == SC_LOG_FILTER_WL)
return 0;
@ -507,7 +507,7 @@ void SCLogReleaseFGFilters(void)
int i = 0;
for (i = 0; i < SC_LOG_FILTER_MAX; i++) {
sc_mutex_lock(&sc_log_fg_filters_m[i]);
SCMutexLock(&sc_log_fg_filters_m[i]);
fgf_file = sc_log_fg_filters[i];
while (fgf_file != NULL) {
@ -536,7 +536,7 @@ void SCLogReleaseFGFilters(void)
free(temp);
}
sc_mutex_unlock(&sc_log_fg_filters_m[i]);
SCMutexUnlock(&sc_log_fg_filters_m[i]);
sc_log_fg_filters[i] = NULL;
}
@ -568,7 +568,7 @@ int SCLogPrintFGFilters()
#endif
for (i = 0; i < SC_LOG_FILTER_MAX; i++) {
sc_mutex_lock(&sc_log_fg_filters_m[i]);
SCMutexLock(&sc_log_fg_filters_m[i]);
fgf_file = sc_log_fg_filters[i];
while (fgf_file != NULL) {
@ -594,7 +594,7 @@ int SCLogPrintFGFilters()
fgf_file = fgf_file->next;
}
sc_mutex_unlock(&sc_log_fg_filters_m[i]);
SCMutexUnlock(&sc_log_fg_filters_m[i]);
}
return count;
@ -648,10 +648,10 @@ int SCLogMatchFDFilter(const char *function)
return 0;
}
sc_mutex_lock(&sc_log_fd_filters_tl_m);
SCMutexLock(&sc_log_fd_filters_tl_m);
if (sc_log_fd_filters_tl == NULL) {
sc_mutex_unlock(&sc_log_fd_filters_tl_m);
SCMutexUnlock(&sc_log_fd_filters_tl_m);
if (sc_log_fd_filters != NULL)
return 0;
return 1;
@ -661,17 +661,17 @@ int SCLogMatchFDFilter(const char *function)
while (thread_list != NULL) {
if (self == thread_list->t) {
if (thread_list->entered > 0) {
sc_mutex_unlock(&sc_log_fd_filters_tl_m);
SCMutexUnlock(&sc_log_fd_filters_tl_m);
return 1;
}
sc_mutex_unlock(&sc_log_fd_filters_tl_m);
SCMutexUnlock(&sc_log_fd_filters_tl_m);
return 0;
}
thread_list = thread_list->next;
}
sc_mutex_unlock(&sc_log_fd_filters_tl_m);
SCMutexUnlock(&sc_log_fd_filters_tl_m);
return 0;
}
@ -701,7 +701,7 @@ int SCLogCheckFDFilterEntry(const char *function)
return 0;
}
sc_mutex_lock(&sc_log_fd_filters_m);
SCMutexLock(&sc_log_fd_filters_m);
curr = sc_log_fd_filters;
@ -713,13 +713,13 @@ int SCLogCheckFDFilterEntry(const char *function)
}
if (curr == NULL) {
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
return 1;
}
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
sc_mutex_lock(&sc_log_fd_filters_tl_m);
SCMutexLock(&sc_log_fd_filters_tl_m);
thread_list = sc_log_fd_filters_tl;
thread_list_temp = thread_list;
@ -734,7 +734,7 @@ int SCLogCheckFDFilterEntry(const char *function)
if (thread_list != NULL) {
thread_list->entered++;
sc_mutex_unlock(&sc_log_fd_filters_tl_m);
SCMutexUnlock(&sc_log_fd_filters_tl_m);
return 1;
}
@ -752,7 +752,7 @@ int SCLogCheckFDFilterEntry(const char *function)
else
thread_list_prev->next = thread_list_temp;
sc_mutex_unlock(&sc_log_fd_filters_tl_m);
SCMutexUnlock(&sc_log_fd_filters_tl_m);
return 1;
}
@ -779,7 +779,7 @@ void SCLogCheckFDFilterExit(const char *function)
return;
}
sc_mutex_lock(&sc_log_fd_filters_m);
SCMutexLock(&sc_log_fd_filters_m);
curr = sc_log_fd_filters;
@ -791,13 +791,13 @@ void SCLogCheckFDFilterExit(const char *function)
}
if (curr == NULL) {
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
return;
}
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
sc_mutex_lock(&sc_log_fd_filters_tl_m);
SCMutexLock(&sc_log_fd_filters_tl_m);
thread_list = sc_log_fd_filters_tl;
while (thread_list != NULL) {
@ -807,7 +807,7 @@ void SCLogCheckFDFilterExit(const char *function)
thread_list = thread_list->next;
}
sc_mutex_unlock(&sc_log_fd_filters_tl_m);
SCMutexUnlock(&sc_log_fd_filters_tl_m);
thread_list->entered--;
@ -839,7 +839,7 @@ int SCLogAddFDFilter(const char *function)
return -1;
}
sc_mutex_lock(&sc_log_fd_filters_m);
SCMutexLock(&sc_log_fd_filters_m);
curr = sc_log_fd_filters;
while (curr != NULL) {
@ -847,7 +847,7 @@ int SCLogAddFDFilter(const char *function)
if (strcmp(function, curr->func) == 0) {
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
return 0;
}
@ -873,7 +873,7 @@ int SCLogAddFDFilter(const char *function)
prev->next = temp;
}
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
sc_log_fd_filters_present = 1;
return 0;
@ -887,7 +887,7 @@ void SCLogReleaseFDFilters(void)
SCLogFDFilter *fdf = NULL;
SCLogFDFilter *temp = NULL;
sc_mutex_lock(&sc_log_fd_filters_m);
SCMutexLock(&sc_log_fd_filters_m);
fdf = sc_log_fd_filters;
while (fdf != NULL) {
@ -898,7 +898,7 @@ void SCLogReleaseFDFilters(void)
sc_log_fd_filters = NULL;
sc_mutex_unlock( &sc_log_fd_filters_m );
SCMutexUnlock( &sc_log_fd_filters_m );
return;
}
@ -927,10 +927,10 @@ int SCLogRemoveFDFilter(const char *function)
return -1;
}
sc_mutex_lock(&sc_log_fd_filters_m);
SCMutexLock(&sc_log_fd_filters_m);
if (sc_log_fd_filters == NULL) {
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
return 0;
}
@ -946,7 +946,7 @@ int SCLogRemoveFDFilter(const char *function)
if (curr == NULL) {
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
return 0;
}
@ -958,7 +958,7 @@ int SCLogRemoveFDFilter(const char *function)
SCLogReleaseFDFilter(curr);
sc_mutex_unlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
if (sc_log_fd_filters == NULL)
sc_log_fd_filters_present = 0;
@ -987,7 +987,7 @@ int SCLogPrintFDFilters(void)
printf("FD filters:\n");
#endif
r = sc_mutex_lock(&sc_log_fd_filters_m);
r = SCMutexLock(&sc_log_fd_filters_m);
fdf = sc_log_fd_filters;
while (fdf != NULL) {
@ -998,7 +998,7 @@ int SCLogPrintFDFilters(void)
count++;
}
r = sc_mutex_unlock(&sc_log_fd_filters_m);
r = SCMutexUnlock(&sc_log_fd_filters_m);
return count;
}

@ -6,7 +6,7 @@
#include "util-debug.h"
static struct timeval current_time = { 0, 0 };
static sc_mutex_t current_time_mutex = PTHREAD_MUTEX_INITIALIZER;
static SCMutex current_time_mutex = PTHREAD_MUTEX_INITIALIZER;
static char live = TRUE;
void TimeModeSetLive(void)
@ -29,14 +29,14 @@ void TimeSet(struct timeval *tv)
if (tv == NULL)
return;
sc_mutex_lock(&current_time_mutex);
SCMutexLock(&current_time_mutex);
current_time.tv_sec = tv->tv_sec;
current_time.tv_usec = tv->tv_usec;
SCLogDebug("time set to %" PRIuMAX " sec, %" PRIuMAX " usec",
(uintmax_t)current_time.tv_sec, (uintmax_t)current_time.tv_usec);
sc_mutex_unlock(&current_time_mutex);
SCMutexUnlock(&current_time_mutex);
}
/** \brief set the time to "gettimeofday" meant for testing */
@ -57,10 +57,10 @@ void TimeGet(struct timeval *tv)
if (live == TRUE) {
gettimeofday(tv, NULL);
} else {
sc_mutex_lock(&current_time_mutex);
SCMutexLock(&current_time_mutex);
tv->tv_sec = current_time.tv_sec;
tv->tv_usec = current_time.tv_usec;
sc_mutex_unlock(&current_time_mutex);
SCMutexUnlock(&current_time_mutex);
}
SCLogDebug("time we got is %" PRIuMAX " sec, %" PRIuMAX " usec",

Loading…
Cancel
Save