From 8eba9a202e4c7d3457d15b7f2f05c5e795363a61 Mon Sep 17 00:00:00 2001 From: Andrew Reading Date: Sat, 23 Feb 2019 21:09:44 -0800 Subject: [PATCH] Make threaded decompression more robust on failure. This changes the decompression worker thread to signal the main thread in case of failure, allowing the main thread to handle this appropriately instead of just assuming the resulting data is always good. --- stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stream.c b/stream.c index 357f921..4dd2d82 100644 --- a/stream.c +++ b/stream.c @@ -1543,7 +1543,7 @@ retry: * parallel */ if (unlikely(ret)) { if (unlikely(waited)) - failure_return(("Failed to decompress in ucompthread\n"), NULL); + failure_return(("Failed to decompress in ucompthread\n"), (void*)1); print_maxverbose("Unable to decompress in parallel, waiting for previous thread to complete before trying again\n"); /* We do not strictly need to wait for this, so it's used when * decompression fails due to inadequate memory to try again @@ -1568,6 +1568,7 @@ static int fill_buffer(rzip_control *control, struct stream_info *sinfo, struct uchar enc_head[25 + SALT_LEN], blocksalt[SALT_LEN]; stream_thread_struct *st; uchar c_type, *s_buf; + void *thr_return; dealloc(s->buf); if (s->eos) @@ -1702,7 +1703,8 @@ out: unlock_mutex(control, &output_lock); /* join_pthread here will make it wait till the data is ready */ - if (unlikely(!join_pthread(control, threads[s->unext_thread], NULL))) + thr_return = NULL; + if (unlikely(!join_pthread(control, threads[s->unext_thread], &thr_return) || !!thr_return)) return -1; ucthread[s->unext_thread].busy = 0;