summaryrefslogtreecommitdiff
path: root/winrt
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-05-15 20:55:08 +0100
committerRobin Watts <robin.watts@artifex.com>2013-05-16 19:26:01 +0100
commit97829a9ce4b9818207d5e286179840e0b63c1938 (patch)
treebde7c338672dcfa564fc84052b0662e01b5ac4a4 /winrt
parent510eb5217cac45c4009e287ede6aa92fbfb8b93d (diff)
downloadmupdf-97829a9ce4b9818207d5e286179840e0b63c1938.tar.xz
Mutex fix
Diffstat (limited to 'winrt')
-rw-r--r--winrt/mupdfwinrt/muctx.cpp15
-rw-r--r--winrt/mupdfwinrt/muctx.h2
2 files changed, 11 insertions, 6 deletions
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;