From aa5206b42bf3415da09b8030040fc038951c8f45 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Sat, 26 Jan 2013 17:57:24 -0500 Subject: [PATCH] Prevent pipeline starvation due to needless block popping --- read.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/read.c b/read.c index 3555430..874e1fc 100644 --- a/read.c +++ b/read.c @@ -519,13 +519,6 @@ static void read_thread(void) { } debug("read: want %llu", iter.block.number_in_file); - // Get a block to work with - pipeline_item_t *pi; - queue_pop(gPipelineStartQ, (void**)&pi); - io_block_t *ib = (io_block_t*)(pi->data); - block_capacity(ib, iter.block.unpadded_size, - iter.block.uncompressed_size); - // Seek if needed, and get the data if (offset != boffset) { fseeko(gInFile, boffset, SEEK_SET); @@ -537,6 +530,13 @@ static void read_thread(void) { rbuf_consume(gRbuf->insize); // clear read_block(true, iter.stream.flags->check); } else { + // Get a block to work with + pipeline_item_t *pi; + queue_pop(gPipelineStartQ, (void**)&pi); + io_block_t *ib = (io_block_t*)(pi->data); + block_capacity(ib, iter.block.unpadded_size, + iter.block.uncompressed_size); + ib->insize = fread(ib->input, 1, bsize, gInFile); if (ib->insize < bsize) die("Error reading block contents");