xz: Set the --flush-timeout deadline when the first input byte arrives.
xz --flush-timeout=2000, old version: 1. xz is started. The next flush will happen after two seconds. 2. No input for one second. 3. A burst of a few kilobytes of input. 4. No input for one second. 5. Two seconds have passed and flushing starts. The first second counted towards the flush-timeout even though there was no pending data. This can cause flushing to occur more often than needed. xz --flush-timeout=2000, after this commit: 1. xz is started. 2. No input for one second. 3. A burst of a few kilobytes of input. The next flush will happen after two seconds counted from the time when the first bytes of the burst were read. 4. No input for one second. 5. No input for another second. 6. Two seconds have passed and flushing starts.
This commit is contained in:
parent
acc0ef3ac8
commit
4433c2dc57
|
@ -733,9 +733,6 @@ coder_normal(file_pair *pair)
|
||||||
if (coder_write_output(pair))
|
if (coder_write_output(pair))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Set the time of the most recent flushing.
|
|
||||||
mytime_set_flush_time();
|
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -906,8 +903,7 @@ coder_run(const char *filename)
|
||||||
// is used.
|
// is used.
|
||||||
if (opt_mode == MODE_TEST || !io_open_dest(pair)) {
|
if (opt_mode == MODE_TEST || !io_open_dest(pair)) {
|
||||||
// Remember the current time. It is needed
|
// Remember the current time. It is needed
|
||||||
// for progress indicator and for timed
|
// for progress indicator.
|
||||||
// flushing.
|
|
||||||
mytime_set_start_time();
|
mytime_set_start_time();
|
||||||
|
|
||||||
// Initialize the progress indicator.
|
// Initialize the progress indicator.
|
||||||
|
|
|
@ -1167,7 +1167,11 @@ io_read(file_pair *pair, io_buf *buf, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += (size_t)(amount);
|
pos += (size_t)(amount);
|
||||||
pair->src_has_seen_input = true;
|
|
||||||
|
if (!pair->src_has_seen_input) {
|
||||||
|
pair->src_has_seen_input = true;
|
||||||
|
mytime_set_flush_time();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
|
|
|
@ -51,7 +51,6 @@ extern void
|
||||||
mytime_set_start_time(void)
|
mytime_set_start_time(void)
|
||||||
{
|
{
|
||||||
start_time = mytime_now();
|
start_time = mytime_now();
|
||||||
next_flush = start_time + opt_flush_timeout;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue