diff --git a/engine/Engine.cpp b/engine/Engine.cpp index 4271c678..20fd1e9f 100644 --- a/engine/Engine.cpp +++ b/engine/Engine.cpp @@ -424,9 +424,13 @@ bool EngineStatusHandler::received(Message &msg) msg.retValue() << ",threads=" << Thread::count(); msg.retValue() << ",workers=" << EnginePrivate::count; msg.retValue() << ",mutexes=" << Mutex::count(); - msg.retValue() << ",locks=" << Mutex::locks(); + int locks = Mutex::locks(); + if (locks >= 0) + msg.retValue() << ",locks=" << locks; msg.retValue() << ",semaphores=" << Semaphore::count(); - msg.retValue() << ",waiting=" << Semaphore::locks(); + locks = Semaphore::locks(); + if (locks >= 0) + msg.retValue() << ",waiting=" << locks; msg.retValue() << ",acceptcalls=" << lookup(Engine::accept(),Engine::getCallAcceptStates()); if (msg.getBoolValue("details",true)) { NamedIterator iter(Engine::runParams()); diff --git a/engine/Mutex.cpp b/engine/Mutex.cpp index 076593ce..0f11ff9b 100644 --- a/engine/Mutex.cpp +++ b/engine/Mutex.cpp @@ -611,7 +611,7 @@ int Mutex::count() int Mutex::locks() { - return MutexPrivate::s_locks; + return s_safety ? MutexPrivate::s_locks : -1; } bool Mutex::efficientTimedLock() @@ -710,7 +710,7 @@ int Semaphore::count() int Semaphore::locks() { - return SemaphorePrivate::s_locks; + return s_safety ? SemaphorePrivate::s_locks : -1; } bool Semaphore::efficientTimedLock() diff --git a/yateclass.h b/yateclass.h index 06881ecd..4163516e 100644 --- a/yateclass.h +++ b/yateclass.h @@ -4514,7 +4514,7 @@ public: /** * Get the number of currently locked mutexes - * @return Count of locked mutexes, should be zero at program exit + * @return Count of locked mutexes, -1 if unknown (not tracked) */ static int locks(); @@ -4649,7 +4649,7 @@ public: /** * Get the number of currently locked (waiting) semaphores - * @return Count of locked semaphores, should be zero at program exit + * @return Count of locked semaphores, -1 if unknown (not tracked) */ static int locks();