aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs')
-rw-r--r--lib/sqfs/block_processor.c2
-rw-r--r--lib/sqfs/block_processor_parallel.c7
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/sqfs/block_processor.c b/lib/sqfs/block_processor.c
index 3fa37fd..ef71f9e 100644
--- a/lib/sqfs/block_processor.c
+++ b/lib/sqfs/block_processor.c
@@ -27,11 +27,13 @@ struct sqfs_block_processor_t {
sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
sqfs_compressor_t *cmp,
unsigned int num_workers,
+ size_t max_backlog,
void *user,
sqfs_block_cb callback)
{
sqfs_block_processor_t *proc;
(void)num_workers;
+ (void)max_backlog;
proc = alloc_flex(sizeof(*proc), 1, max_block_size);
diff --git a/lib/sqfs/block_processor_parallel.c b/lib/sqfs/block_processor_parallel.c
index 05c07f1..a63135a 100644
--- a/lib/sqfs/block_processor_parallel.c
+++ b/lib/sqfs/block_processor_parallel.c
@@ -16,8 +16,6 @@
#include <string.h>
#include <stdlib.h>
-#define MAX_BACKLOG_FACTOR (10)
-
typedef struct {
sqfs_block_processor_t *shared;
sqfs_compressor_t *cmp;
@@ -46,6 +44,7 @@ struct sqfs_block_processor_t {
sqfs_block_cb cb;
void *user;
int status;
+ size_t max_backlog;
/* used only by workers */
size_t max_block_size;
@@ -117,6 +116,7 @@ static void *worker_proc(void *arg)
sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
sqfs_compressor_t *cmp,
unsigned int num_workers,
+ size_t max_backlog,
void *user,
sqfs_block_cb callback)
{
@@ -136,6 +136,7 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
proc->cb = callback;
proc->user = user;
proc->num_workers = num_workers;
+ proc->max_backlog = max_backlog;
if (pthread_mutex_init(&proc->mtx, NULL))
goto fail_free;
@@ -274,7 +275,7 @@ int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc,
(block->flags & SQFS_BLK_DONT_CHECKSUM)) {
store_completed_block(proc, block);
} else {
- while (proc->backlog > proc->num_workers * MAX_BACKLOG_FACTOR)
+ while (proc->backlog > proc->max_backlog)
pthread_cond_wait(&proc->done_cond, &proc->mtx);
if (proc->queue_last == NULL) {