detect/dbv: Assert MT lock held

Add a DBV assert to validate that the master->lock is held.

Suppress missing master->lock warning

Issue: 7819
pull/14077/head
Jeff Lucovsky 1 month ago committed by Victor Julien
parent 46a53aee73
commit 9a7a30f18e

@ -3153,6 +3153,9 @@ static TmEcode DetectEngineThreadCtxInitForMT(ThreadVars *tv, DetectEngineThread
uint32_t max_tenant_id = 0;
DetectEngineCtx *list = master->list;
DEBUG_VALIDATE_BUG_ON(!SCMutexIsLocked(&master->lock));
/* coverity[missing_lock] */
if (master->tenant_selector == TENANT_SELECTOR_UNKNOWN) {
SCLogError("no tenant selector set: "
"set using multi-detect.selector");

@ -116,6 +116,7 @@
#define SCMutexInit(mut, mutattrs) SCMutexInit_dbg(mut, mutattrs)
#define SCMutexLock(mut) SCMutexLock_dbg(mut)
#define SCMutexTrylock(mut) SCMutexTrylock_dbg(mut)
#define SCMutexIsLocked(mut) (SCMutexTrylock(mut) == EBUSY)
#define SCMutexUnlock(mut) SCMutexUnlock_dbg(mut)
#define SCMutexDestroy pthread_mutex_destroy
#define SCMUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER

@ -90,6 +90,7 @@ extern thread_local uint64_t mutex_lock_cnt;
#define SCMutexInit(mut, mutattr ) pthread_mutex_init(mut, mutattr)
#define SCMutexLock(mut) SCMutexLock_profile(mut)
#define SCMutexTrylock(mut) pthread_mutex_trylock(mut)
#define SCMutexIsLocked(mut) (SCMutexTrylock(mut) == EBUSY)
#define SCMutexUnlock(mut) pthread_mutex_unlock(mut)
#define SCMutexDestroy pthread_mutex_destroy
#define SCMUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER

@ -43,6 +43,7 @@ static int ThreadMacrosTest01Mutex(void)
r |= SCMutexInit(&mut, NULL);
r |= SCMutexLock(&mut);
r |= (SCMutexTrylock(&mut) == EBUSY)? 0 : 1;
r |= SCMutexIsLocked(&mut) ? 0 : 1;
r |= SCMutexUnlock(&mut);
r |= SCMutexDestroy(&mut);

@ -118,6 +118,7 @@ enum {
#define SCMutexInit(mut, mutattr ) pthread_mutex_init(mut, mutattr)
#define SCMutexLock(mut) pthread_mutex_lock(mut)
#define SCMutexTrylock(mut) pthread_mutex_trylock(mut)
#define SCMutexIsLocked(mut) (SCMutexTrylock(mut) == EBUSY)
#define SCMutexUnlock(mut) pthread_mutex_unlock(mut)
#define SCMutexDestroy pthread_mutex_destroy
#define SCMUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER

Loading…
Cancel
Save