Added possibility to repeat the -Dm option to halve the mutex maximum wait time.

git-svn-id: http://yate.null.ro/svn/yate/trunk@2982 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2009-12-10 11:20:50 +00:00
parent 516b0aa9ef
commit 966a1201b9
4 changed files with 22 additions and 2 deletions

View File

@ -97,7 +97,7 @@ Special debugging options
Abort (coredumps if allowed) if bugs are encountered
.TP
.B \-Dm
Attempt to debug mutex deadlocks by setting a maximum 10s limit
Attempt to debug mutex deadlocks by setting a maximum 10s limit, if repeated halves the limit
.TP
.B \-Dl
Attempt to load modules without having their symbols globally visible

View File

@ -1682,7 +1682,17 @@ int Engine::main(int argc, const char** argv, const char** env, RunMode mode, bo
s_lateabrt = true;
break;
case 'm':
Lockable::wait(10000000);
{
unsigned long lockWait = Lockable::wait();
if (lockWait) {
lockWait /= 2;
if (lockWait < Thread::idleUsec())
lockWait = Thread::idleUsec();
}
else
lockWait = 10000000;
Lockable::wait(lockWait);
}
break;
#ifdef RTLD_GLOBAL
case 'l':

View File

@ -511,6 +511,10 @@ void Lockable::wait(unsigned long maxwait)
s_maxwait = maxwait;
}
unsigned long Lockable::wait()
{
return s_maxwait;
}
Mutex::Mutex(bool recursive, const char* name)
: m_private(0)

View File

@ -3637,6 +3637,12 @@ public:
*/
static void wait(unsigned long maxwait);
/**
* Get the maximum wait time used for debugging purposes
* @return Maximum time in microseconds, zero if no maximum is set
*/
static unsigned long wait();
/**
* Start actually using lockables, for platforms where these objects are not
* usable in global object constructors.