From aea81fb5c84aea447f1d12d8f77a179f52d8a70e Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Wed, 3 Apr 2013 19:35:45 +0200 Subject: [PATCH] winpr/mutex: Support for bInitialOwner in CreateMutex --- winpr/libwinpr/synch/mutex.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/winpr/libwinpr/synch/mutex.c b/winpr/libwinpr/synch/mutex.c index d4b001dd9..62c2e2611 100644 --- a/winpr/libwinpr/synch/mutex.c +++ b/winpr/libwinpr/synch/mutex.c @@ -39,15 +39,18 @@ HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCWSTR lpName) { - HANDLE handle; + HANDLE handle = NULL; pthread_mutex_t* pMutex; pMutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t)); if (pMutex) + { pthread_mutex_init(pMutex, 0); - - handle = winpr_Handle_Insert(HANDLE_TYPE_MUTEX, pMutex); + handle = winpr_Handle_Insert(HANDLE_TYPE_MUTEX, pMutex); + if (bInitialOwner) + pthread_mutex_lock(pMutex); + } return handle; }