summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-11-09 12:05:14 +0000
committerRobin Watts <robin.watts@artifex.com>2017-11-09 12:41:27 +0000
commit9f32fdff17f9d6cb114c4f70d1e4b8364e8b5d11 (patch)
treecfbe1efc6808ce85ac97a8b7d21343b3e8a1fc80 /source
parent721180d208d2398934db4353617737cbd2f325a4 (diff)
downloadmupdf-9f32fdff17f9d6cb114c4f70d1e4b8364e8b5d11.tar.xz
Avoid mu-office-lib calling fz_lock.
It was only ever calling fz_lock for its own lock. This was an abuse at best, and could potentially have caused trouble with the deadlock detection code. Instead, lock the same lock, but do so using custom (static) functions.
Diffstat (limited to 'source')
-rw-r--r--source/helpers/mu-office-lib/mu-office-lib.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/source/helpers/mu-office-lib/mu-office-lib.c b/source/helpers/mu-office-lib/mu-office-lib.c
index 2e69d448..98baf1bb 100644
--- a/source/helpers/mu-office-lib/mu-office-lib.c
+++ b/source/helpers/mu-office-lib/mu-office-lib.c
@@ -138,6 +138,16 @@ static void muoffice_unlock(void *user, int lock)
mu_unlock_mutex(&mu->mutexes[lock]);
}
+static void muoffice_doc_lock(MuOfficeLib *mu)
+{
+ mu_lock_mutex(&mu->mutexes[DOCLOCK]);
+}
+
+static void muoffice_doc_unlock(MuOfficeLib *mu)
+{
+ mu_unlock_mutex(&mu->mutexes[DOCLOCK]);
+}
+
static void fin_muoffice_locks(MuOfficeLib *mu)
{
int i;
@@ -339,7 +349,7 @@ static void load_worker(void *arg)
return;
}
- fz_lock(ctx, DOCLOCK);
+ muoffice_doc_lock(doc->mu);
fz_try(ctx)
{
@@ -377,7 +387,7 @@ static void load_worker(void *arg)
err = MuOfficeDocErrorType_UnableToLoadDocument;
fail:
- fz_unlock(ctx, DOCLOCK);
+ muoffice_doc_unlock(doc->mu);
if (err)
doc->error(doc->cookie, err);
@@ -672,7 +682,7 @@ MuError MuOfficeDoc_getPage( MuOfficeDoc *doc,
if (page == NULL)
return MuError_OOM;
- fz_lock(ctx, DOCLOCK);
+ muoffice_doc_lock(doc->mu);
fz_try(ctx)
{
@@ -691,7 +701,7 @@ MuError MuOfficeDoc_getPage( MuOfficeDoc *doc,
err = MuError_Generic;
}
- fz_unlock(ctx, DOCLOCK);
+ muoffice_doc_unlock(doc->mu);
return err;
}
@@ -736,14 +746,14 @@ MuError MuOfficeDoc_run(MuOfficeDoc *doc, void (*fn)(fz_context *ctx, fz_documen
if (ctx == NULL)
return MuError_OOM;
- fz_lock(ctx, DOCLOCK);
+ muoffice_doc_lock(doc->mu);
fz_try(ctx)
fn(ctx, doc->doc, arg);
fz_catch(ctx)
err = MuError_Generic;
- fz_unlock(ctx, DOCLOCK);
+ muoffice_doc_unlock(doc->mu);
fz_drop_context(ctx);
@@ -946,14 +956,14 @@ MuError MuOfficePage_run(MuOfficePage *page, void (*fn)(fz_context *ctx, fz_page
if (ctx == NULL)
return MuError_OOM;
- fz_lock(ctx, DOCLOCK);
+ muoffice_doc_lock(page->doc->mu);
fz_try(ctx)
fn(ctx, page->page, arg);
fz_catch(ctx)
err = MuError_Generic;
- fz_unlock(ctx, DOCLOCK);
+ muoffice_doc_unlock(page->doc->mu);
fz_drop_context(ctx);
@@ -985,11 +995,11 @@ static void render_worker(void *arg)
{
if (page->list == NULL)
{
- fz_lock(ctx, DOCLOCK);
+ muoffice_doc_lock(page->doc->mu);
locked = 1;
page->list = fz_new_display_list_from_page(ctx, page->page);
locked = 0;
- fz_unlock(ctx, DOCLOCK);
+ muoffice_doc_unlock(page->doc->mu);
}
/* Make a pixmap from the bitmap */
if (!render->area_valid)
@@ -1032,7 +1042,7 @@ static void render_worker(void *arg)
fz_catch(ctx)
{
if (locked)
- fz_unlock(ctx, DOCLOCK);
+ muoffice_doc_unlock(page->doc->mu);
err = MuError_Generic;
goto fail;
}