diff options
author | Robin Watts <robin.watts@artifex.com> | 2017-03-31 13:53:30 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2017-03-31 14:57:37 +0100 |
commit | 4594d29875ce6cba8132e2051360b06131323c5b (patch) | |
tree | 1f59297caf5673de897f0c203f3ed1e72af9064a | |
parent | 8ef09df1fee1566e5c16b5c6249975f6e007b950 (diff) | |
download | mupdf-4594d29875ce6cba8132e2051360b06131323c5b.tar.xz |
Fix mutex asserts seen during reaping.
As seen with:
mutool draw -o out.ppm Bug697706.epub
-rw-r--r-- | source/fitz/store.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/source/fitz/store.c b/source/fitz/store.c index f7cda31a..dcef6b86 100644 --- a/source/fitz/store.c +++ b/source/fitz/store.c @@ -94,7 +94,7 @@ void *fz_keep_key_storable(fz_context *ctx, const fz_key_storable *sc) /* Entered with FZ_LOCK_ALLOC and FZ_LOCK_REAP held. - Drops FZ_LOCK_ALLOC. + Drops FZ_LOCK_ALLOC and FZ_LOCK_REAP. */ static void do_reap(fz_context *ctx) @@ -152,6 +152,7 @@ do_reap(fz_context *ctx) remove = item; } fz_unlock(ctx, FZ_LOCK_ALLOC); + fz_unlock(ctx, FZ_LOCK_REAP); /* Now drop the remove chain */ for (item = remove; item != NULL; item = remove) @@ -189,13 +190,15 @@ int fz_drop_key_storable(fz_context *ctx, const fz_key_storable *sc) { fz_lock(ctx, FZ_LOCK_REAP); if (ctx->store->defer_reap_count > 0) + { ctx->store->needs_reaping = 1; + fz_unlock(ctx, FZ_LOCK_REAP); + } else { do_reap(ctx); unlock = 0; } - fz_unlock(ctx, FZ_LOCK_REAP); } } else @@ -489,7 +492,8 @@ fz_store_item(fz_context *ctx, void *key, void *val_, size_t itemsize, const fz_ do_reap(ctx); /* Drops alloc lock */ relock = 1; } - fz_unlock(ctx, FZ_LOCK_REAP); + else + fz_unlock(ctx, FZ_LOCK_REAP); if (relock) fz_lock(ctx, FZ_LOCK_ALLOC); size = store->size + itemsize; @@ -922,8 +926,10 @@ void fz_defer_reap_end(fz_context *ctx) --ctx->store->defer_reap_count; reap = ctx->store->defer_reap_count == 0 && ctx->store->needs_reaping; if (reap) - do_reap(ctx); /* Drops FZ_LOCK_ALLOC */ - fz_unlock(ctx, FZ_LOCK_REAP); - if (!reap) + do_reap(ctx); /* Drops FZ_LOCK_ALLOC and FZ_LOCK_REAP*/ + else + { + fz_unlock(ctx, FZ_LOCK_REAP); fz_unlock(ctx, FZ_LOCK_ALLOC); + } } |