xz: Move flush_needed from mytime.h to file_pair struct in file_io.h.

This commit is contained in:
Lasse Collin 2020-01-26 20:19:19 +02:00
parent 8150356810
commit fd47fd62bb
5 changed files with 7 additions and 9 deletions

View File

@ -711,7 +711,7 @@ coder_normal(file_pair *pair)
action = LZMA_FULL_BARRIER; action = LZMA_FULL_BARRIER;
} }
if (action == LZMA_RUN && flush_needed) if (action == LZMA_RUN && pair->flush_needed)
action = LZMA_SYNC_FLUSH; action = LZMA_SYNC_FLUSH;
} }
@ -739,6 +739,7 @@ coder_normal(file_pair *pair)
// Mark that we haven't seen any new input // Mark that we haven't seen any new input
// since the previous flush. // since the previous flush.
pair->src_has_seen_input = false; pair->src_has_seen_input = false;
pair->flush_needed = false;
} else { } else {
// Start a new Block after LZMA_FULL_BARRIER. // Start a new Block after LZMA_FULL_BARRIER.
if (opt_block_list == NULL) { if (opt_block_list == NULL) {

View File

@ -750,6 +750,7 @@ io_open_src(const char *src_name)
.dest_fd = -1, .dest_fd = -1,
.src_eof = false, .src_eof = false,
.src_has_seen_input = false, .src_has_seen_input = false,
.flush_needed = false,
.dest_try_sparse = false, .dest_try_sparse = false,
.dest_pending_sparse = 0, .dest_pending_sparse = 0,
}; };
@ -1150,7 +1151,7 @@ io_read(file_pair *pair, io_buf *buf, size_t size)
return SIZE_MAX; return SIZE_MAX;
case IO_WAIT_TIMEOUT: case IO_WAIT_TIMEOUT:
flush_needed = true; pair->flush_needed = true;
return pos; return pos;
default: default:

View File

@ -53,6 +53,9 @@ typedef struct {
/// since the previous flush or the start of the file. /// since the previous flush or the start of the file.
bool src_has_seen_input; bool src_has_seen_input;
/// For --flush-timeout: True when flushing is needed.
bool flush_needed;
/// If true, we look for long chunks of zeros and try to create /// If true, we look for long chunks of zeros and try to create
/// a sparse file. /// a sparse file.
bool dest_try_sparse; bool dest_try_sparse;

View File

@ -17,7 +17,6 @@
#endif #endif
uint64_t opt_flush_timeout = 0; uint64_t opt_flush_timeout = 0;
bool flush_needed;
static uint64_t start_time; static uint64_t start_time;
static uint64_t next_flush; static uint64_t next_flush;
@ -53,7 +52,6 @@ mytime_set_start_time(void)
{ {
start_time = mytime_now(); start_time = mytime_now();
next_flush = start_time + opt_flush_timeout; next_flush = start_time + opt_flush_timeout;
flush_needed = false;
return; return;
} }
@ -69,7 +67,6 @@ extern void
mytime_set_flush_time(void) mytime_set_flush_time(void)
{ {
next_flush = mytime_now() + opt_flush_timeout; next_flush = mytime_now() + opt_flush_timeout;
flush_needed = false;
return; return;
} }

View File

@ -21,10 +21,6 @@
extern uint64_t opt_flush_timeout; extern uint64_t opt_flush_timeout;
/// \brief True when flushing is needed due to expired timeout
extern bool flush_needed;
/// \brief Store the time when (de)compression was started /// \brief Store the time when (de)compression was started
/// ///
/// The start time is also stored as the time of the first flush. /// The start time is also stored as the time of the first flush.