Do not exit a soft cancelled thread while trying to acquire a mutex.
Immediately fail the wait of a non mandatory locking if thread is cancelled. git-svn-id: http://voip.null.ro/svn/yate@2230 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
8cc44818bf
commit
8d58354fed
|
@ -223,8 +223,12 @@ bool MutexPrivate::lock(long maxwait)
|
||||||
else {
|
else {
|
||||||
u_int64_t t = Time::now() + maxwait;
|
u_int64_t t = Time::now() + maxwait;
|
||||||
do {
|
do {
|
||||||
if (dead = Thread::check(false))
|
if (!dead) {
|
||||||
break;
|
dead = Thread::check(false);
|
||||||
|
// give up only if caller asked for a limited wait
|
||||||
|
if (dead && !warn)
|
||||||
|
break;
|
||||||
|
}
|
||||||
rval = !::pthread_mutex_trylock(&m_mutex);
|
rval = !::pthread_mutex_trylock(&m_mutex);
|
||||||
if (rval)
|
if (rval)
|
||||||
break;
|
break;
|
||||||
|
@ -248,8 +252,6 @@ bool MutexPrivate::lock(long maxwait)
|
||||||
else
|
else
|
||||||
deref();
|
deref();
|
||||||
GlobalMutex::unlock();
|
GlobalMutex::unlock();
|
||||||
if (dead)
|
|
||||||
Thread::exit();
|
|
||||||
if (warn && !rval)
|
if (warn && !rval)
|
||||||
Debug(DebugFail,"Thread '%s' could not take lock owned by '%s' for %lu usec!",
|
Debug(DebugFail,"Thread '%s' could not take lock owned by '%s' for %lu usec!",
|
||||||
Thread::currentName(),m_owner,maxwait);
|
Thread::currentName(),m_owner,maxwait);
|
||||||
|
|
Loading…
Reference in New Issue