diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-26 17:21:44 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-26 17:22:53 +0200 |
commit | ff4a9235feb4237854ff102c4dc7cf4645d6a116 (patch) | |
tree | 18017f7f1b6776ef76360fef0ff127d42f3007cd /lib/sqfs/data_writer/pthread.c | |
parent | 248765bd9f6ead4fbe4e5822bcaf46b85fe1687f (diff) |
Add file API stub to sqfs data writer
Basically move the state tracking from the old data writer over to
the new one.
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.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/lib/sqfs/data_writer/pthread.c b/lib/sqfs/data_writer/pthread.c index 3170c11..9c9b0a2 100644 --- a/lib/sqfs/data_writer/pthread.c +++ b/lib/sqfs/data_writer/pthread.c @@ -156,18 +156,6 @@ static void append_to_work_queue(sqfs_data_writer_t *proc, pthread_cond_broadcast(&proc->queue_cond); } -static int test_and_set_status(sqfs_data_writer_t *proc, int status) -{ - pthread_mutex_lock(&proc->mtx); - if (proc->status == 0) { - proc->status = status; - } else { - status = proc->status; - } - pthread_cond_broadcast(&proc->queue_cond); - return status; -} - static sqfs_block_t *try_dequeue(sqfs_data_writer_t *proc) { sqfs_block_t *queue, *it, *prev; @@ -260,16 +248,23 @@ static int process_done_queue(sqfs_data_writer_t *proc, sqfs_block_t *queue) return status; } -int sqfs_data_writer_enqueue(sqfs_data_writer_t *proc, sqfs_block_t *block) +int test_and_set_status(sqfs_data_writer_t *proc, int status) +{ + pthread_mutex_lock(&proc->mtx); + if (proc->status == 0) { + proc->status = status; + } else { + status = proc->status; + } + pthread_cond_broadcast(&proc->queue_cond); + return status; +} + +int data_writer_enqueue(sqfs_data_writer_t *proc, sqfs_block_t *block) { sqfs_block_t *queue; int status; - if (block->flags & ~SQFS_BLK_USER_SETTABLE_FLAGS) { - free(block); - return test_and_set_status(proc, SQFS_ERROR_UNSUPPORTED); - } - pthread_mutex_lock(&proc->mtx); while (proc->backlog > proc->max_backlog && proc->status == 0) pthread_cond_wait(&proc->done_cond, &proc->mtx); |