summaryrefslogtreecommitdiff
path: root/lib/sqfs/data_writer/pthread.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-12-13 02:00:36 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-12-13 02:05:42 +0100
commit514e9e500abdd8ea91ea3b2fca214587ee24a342 (patch)
tree6a6ae1efad3cbd073725b4dbc507259121083139 /lib/sqfs/data_writer/pthread.c
parent74f25ae0f3ebc1cd435f29c21ab164a9028af980 (diff)
Cleanup data writer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/data_writer/pthread.c')
-rw-r--r--lib/sqfs/data_writer/pthread.c56
1 files changed, 4 insertions, 52 deletions
diff --git a/lib/sqfs/data_writer/pthread.c b/lib/sqfs/data_writer/pthread.c
index cfd2d3e..8196641 100644
--- a/lib/sqfs/data_writer/pthread.c
+++ b/lib/sqfs/data_writer/pthread.c
@@ -154,8 +154,8 @@ void sqfs_data_writer_destroy(sqfs_data_writer_t *proc)
data_writer_cleanup(proc);
}
-static int append_to_work_queue(sqfs_data_writer_t *proc,
- sqfs_block_t *block, bool signal_threads)
+int append_to_work_queue(sqfs_data_writer_t *proc, sqfs_block_t *block,
+ bool signal_threads)
{
int status;
@@ -292,7 +292,7 @@ int test_and_set_status(sqfs_data_writer_t *proc, int status)
return status;
}
-static int wait_completed(sqfs_data_writer_t *proc)
+int wait_completed(sqfs_data_writer_t *proc)
{
sqfs_block_t *queue;
int status;
@@ -315,53 +315,5 @@ static int wait_completed(sqfs_data_writer_t *proc)
}
status = process_done_queue(proc, queue);
- if (status != 0)
- return test_and_set_status(proc, status);
-
- return status;
-}
-
-int data_writer_enqueue(sqfs_data_writer_t *proc, sqfs_block_t *block)
-{
- int status;
-
- while (proc->backlog > proc->max_backlog) {
- status = wait_completed(proc);
- if (status)
- return status;
- }
-
- if (proc->backlog == proc->max_backlog)
- proc->notify_threads = true;
-
- return append_to_work_queue(proc, block, proc->notify_threads);
-}
-
-int sqfs_data_writer_finish(sqfs_data_writer_t *proc)
-{
- int status;
-
- append_to_work_queue(proc, NULL, true);
-
- while (proc->backlog > 0) {
- status = wait_completed(proc);
- if (status)
- return status;
- }
-
- if (proc->frag_block != NULL) {
- status = data_writer_do_block(proc->frag_block,
- proc->workers[0]->cmp,
- proc->workers[0]->scratch,
- proc->max_block_size);
- if (status)
- return status;
-
- status = process_done_queue(proc, proc->frag_block);
- proc->frag_block = NULL;
- if (status)
- return status;
- }
-
- return 0;
+ return status ? test_and_set_status(proc, status) : status;
}