Ensuring mutex is unlocked on destroy.

This commit is contained in:
Armin Novak 2015-04-28 09:42:46 +02:00
parent ac15ce2da8
commit fe27913859
1 changed files with 5 additions and 4 deletions

View File

@ -67,9 +67,9 @@ BOOL MutexCloseHandle(HANDLE handle)
if (!MutexIsHandled(handle)) if (!MutexIsHandled(handle))
return FALSE; return FALSE;
#if defined(WITH_DEBUG_MUTEX)
if (pthread_mutex_trylock(&mutex->mutex)) if (pthread_mutex_trylock(&mutex->mutex))
{ {
#if defined(WITH_DEBUG_MUTEX)
size_t used = 0, i; size_t used = 0, i;
void* stack = winpr_backtrace(20); void* stack = winpr_backtrace(20);
char **msg = NULL; char **msg = NULL;
@ -84,10 +84,11 @@ BOOL MutexCloseHandle(HANDLE handle)
} }
free (msg); free (msg);
winpr_backtrace_free(stack); winpr_backtrace_free(stack);
}
else
pthread_mutex_unlock(&mutex->mutex);
#endif #endif
}
if (pthread_mutex_unlock(&mutex->mutex))
return FALSE;
if (!pthread_mutex_destroy(&mutex->mutex)) if (!pthread_mutex_destroy(&mutex->mutex))
return FALSE; return FALSE;