From 97829a9ce4b9818207d5e286179840e0b63c1938 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 15 May 2013 20:55:08 +0100 Subject: Mutex fix --- winrt/mupdfwinrt/muctx.cpp | 15 ++++++++++----- winrt/mupdfwinrt/muctx.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'winrt') diff --git a/winrt/mupdfwinrt/muctx.cpp b/winrt/mupdfwinrt/muctx.cpp index 5b9d2464..f069fbeb 100644 --- a/winrt/mupdfwinrt/muctx.cpp +++ b/winrt/mupdfwinrt/muctx.cpp @@ -81,12 +81,14 @@ static void win_close_file(fz_context *ctx, void *state) /* mutext functions see mupdf readme for details */ static void lock_mutex(void *user, int lock) { - EnterCriticalSection((LPCRITICAL_SECTION)user); + LPCRITICAL_SECTION locks = (LPCRITICAL_SECTION)user; + EnterCriticalSection(&locks[lock]); } static void unlock_mutex(void *user, int lock) { - LeaveCriticalSection((LPCRITICAL_SECTION)user); + LPCRITICAL_SECTION locks = (LPCRITICAL_SECTION)user; + LeaveCriticalSection(&locks[lock]); } void muctx::CleanUp(void) @@ -109,9 +111,12 @@ void muctx::CleanUp(void) /* Set up the context, mutex and cookie */ HRESULT muctx::InitializeContext() { - /* Get the mutex set up */ - InitializeCriticalSectionEx(&mu_criticalsec, 0, 0); - mu_locks.user = &mu_criticalsec; + int i; + + /* Get the mutexes set up */ + for (i = 0; i < FZ_LOCK_MAX; i++) + InitializeCriticalSectionEx(&mu_criticalsec[i], 0, 0); + mu_locks.user = &mu_criticalsec[0]; mu_locks.lock = lock_mutex; mu_locks.unlock = unlock_mutex; diff --git a/winrt/mupdfwinrt/muctx.h b/winrt/mupdfwinrt/muctx.h index 333a1902..15ebf5ef 100644 --- a/winrt/mupdfwinrt/muctx.h +++ b/winrt/mupdfwinrt/muctx.h @@ -69,7 +69,7 @@ typedef struct win_stream_struct_s class muctx { private: - CRITICAL_SECTION mu_criticalsec; + CRITICAL_SECTION mu_criticalsec[FZ_LOCK_MAX]; win_stream_struct win_stream; fz_locks_context mu_locks; fz_context *mu_ctx; -- cgit v1.2.3