diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-02-20 18:22:50 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-02-20 18:23:40 +0100 |
commit | 4c10e8326447216c7d79aa87668a7b00efdb7364 (patch) | |
tree | ba3a4bf0d32a2440d3d51e2ee7f5be79dcd94876 /lib/sqfs/block_processor/winpthread.c | |
parent | 3215679c2c87f3f40809f5eb75b5c679bcb4879d (diff) |
Thread pool block processor: Cleanup after restructuring
- Merge duplicated code from append_to_work_queue and
sqfs_block_processor_finish
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor/winpthread.c')
-rw-r--r-- | lib/sqfs/block_processor/winpthread.c | 77 |
1 files changed, 15 insertions, 62 deletions
diff --git a/lib/sqfs/block_processor/winpthread.c b/lib/sqfs/block_processor/winpthread.c index da69cb7..492ad6e 100644 --- a/lib/sqfs/block_processor/winpthread.c +++ b/lib/sqfs/block_processor/winpthread.c @@ -465,10 +465,15 @@ int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block) if (status != 0) break; - if (thproc->backlog < thproc->max_backlog) { - append_block(thproc, block); - block = NULL; - break; + if (block == NULL) { + if (thproc->backlog == 0) + break; + } else { + if (thproc->backlog < thproc->max_backlog) { + append_block(thproc, block); + block = NULL; + break; + } } blk = try_dequeue_io(thproc); @@ -521,70 +526,23 @@ int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block) int sqfs_block_processor_finish(sqfs_block_processor_t *proc) { thread_pool_processor_t *thproc = (thread_pool_processor_t *)proc; - sqfs_block_t *io_list = NULL, *io_list_last = NULL; - sqfs_block_t *blk, *fragblk, *free_list = NULL; + sqfs_block_t *blk; int status; - LOCK(&thproc->mtx); - for (;;) { - status = thproc->status; - if (status != 0) - break; - - if (thproc->backlog == 0) - break; - - blk = try_dequeue_io(thproc); - if (blk != NULL) { - if (io_list_last == NULL) { - io_list = io_list_last = blk; - } else { - io_list_last->next = blk; - io_list_last = blk; - } - continue; - } - - blk = try_dequeue_done(thproc); - if (blk == NULL) { - AWAIT(&thproc->done_cond, &thproc->mtx); - continue; - } - - if (blk->flags & SQFS_BLK_IS_FRAGMENT) { - fragblk = NULL; - thproc->status = process_completed_fragment(proc, blk, - &fragblk); - blk->next = free_list; - free_list = blk; - - if (fragblk != NULL) { - fragblk->io_seq_num = thproc->io_enq_id++; - append_block(thproc, fragblk); - SIGNAL_ALL(&thproc->queue_cond); - } - } else { - if (!(blk->flags & SQFS_BLK_FRAGMENT_BLOCK)) - blk->io_seq_num = thproc->io_enq_id++; - store_io_block(thproc, blk); - } - } - UNLOCK(&thproc->mtx); + status = append_to_work_queue(proc, NULL); if (status == 0 && proc->frag_block != NULL) { blk = proc->frag_block; + blk->next = NULL; proc->frag_block = NULL; status = block_processor_do_block(blk, proc->cmp, thproc->workers[0]->scratch, proc->max_block_size); - if (io_list_last == NULL) { - io_list = io_list_last = blk; - } else { - io_list_last->next = blk; - io_list_last = blk; - } + if (status == 0) + status = handle_io_queue(thproc, blk); + free(blk); if (status != 0) { LOCK(&thproc->mtx); @@ -595,10 +553,5 @@ int sqfs_block_processor_finish(sqfs_block_processor_t *proc) } } - if (status == 0) - status = handle_io_queue(thproc, io_list); - - free_blk_list(io_list); - free_blk_list(free_list); return status; } |