summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sqfs/block_processor_parallel.c21
-rw-r--r--lib/sqfs/process_block.c4
2 files changed, 8 insertions, 17 deletions
diff --git a/lib/sqfs/block_processor_parallel.c b/lib/sqfs/block_processor_parallel.c
index a63135a..a00bf12 100644
--- a/lib/sqfs/block_processor_parallel.c
+++ b/lib/sqfs/block_processor_parallel.c
@@ -105,10 +105,8 @@ static void *worker_proc(void *arg)
shared->queue_last = NULL;
pthread_mutex_unlock(&shared->mtx);
- if (sqfs_block_process(blk, worker->cmp, worker->scratch,
- shared->max_block_size)) {
- blk->flags |= SQFS_BLK_COMPRESS_ERROR;
- }
+ sqfs_block_process(blk, worker->cmp, worker->scratch,
+ shared->max_block_size);
}
return NULL;
}
@@ -137,15 +135,9 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
proc->user = user;
proc->num_workers = num_workers;
proc->max_backlog = max_backlog;
-
- if (pthread_mutex_init(&proc->mtx, NULL))
- goto fail_free;
-
- if (pthread_cond_init(&proc->queue_cond, NULL))
- goto fail_mtx;
-
- if (pthread_cond_init(&proc->done_cond, NULL))
- goto fail_cond;
+ proc->mtx = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
+ proc->queue_cond = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
+ proc->done_cond = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
for (i = 0; i < num_workers; ++i) {
proc->workers[i] = alloc_flex(sizeof(compress_worker_t),
@@ -193,11 +185,8 @@ fail_init:
}
}
pthread_cond_destroy(&proc->done_cond);
-fail_cond:
pthread_cond_destroy(&proc->queue_cond);
-fail_mtx:
pthread_mutex_destroy(&proc->mtx);
-fail_free:
free(proc);
return NULL;
}
diff --git a/lib/sqfs/process_block.c b/lib/sqfs/process_block.c
index f8b4d6c..3289767 100644
--- a/lib/sqfs/process_block.c
+++ b/lib/sqfs/process_block.c
@@ -26,8 +26,10 @@ int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp,
ret = cmp->do_block(cmp, block->data, block->size,
scratch, scratch_size);
- if (ret < 0)
+ if (ret < 0) {
+ block->flags |= SQFS_BLK_COMPRESS_ERROR;
return ret;
+ }
if (ret > 0) {
memcpy(block->data, scratch, ret);