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:
paulc 2008-09-20 10:12:00 +00:00
parent 8cc44818bf
commit 8d58354fed
1 changed files with 6 additions and 4 deletions

View File

@ -223,8 +223,12 @@ bool MutexPrivate::lock(long maxwait)
else {
u_int64_t t = Time::now() + maxwait;
do {
if (dead = Thread::check(false))
break;
if (!dead) {
dead = Thread::check(false);
// give up only if caller asked for a limited wait
if (dead && !warn)
break;
}
rval = !::pthread_mutex_trylock(&m_mutex);
if (rval)
break;
@ -248,8 +252,6 @@ bool MutexPrivate::lock(long maxwait)
else
deref();
GlobalMutex::unlock();
if (dead)
Thread::exit();
if (warn && !rval)
Debug(DebugFail,"Thread '%s' could not take lock owned by '%s' for %lu usec!",
Thread::currentName(),m_owner,maxwait);