xz: Check for filter chain compatibility for --flush-timeout.

This avoids LZMA_PROG_ERROR from lzma_code() with filter chains
that don't support LZMA_SYNC_FLUSH.
This commit is contained in:
Lasse Collin 2014-06-18 19:11:52 +03:00
parent 381ac14ed7
commit 3ce3e79769
1 changed files with 21 additions and 9 deletions

View File

@ -195,16 +195,28 @@ coder_set_compression_settings(void)
// Print the selected filter chain. // Print the selected filter chain.
message_filters_show(V_DEBUG, filters); message_filters_show(V_DEBUG, filters);
// Disable encoder threads when --flush-timeout is used because // The --flush-timeout option requires LZMA_SYNC_FLUSH support
// the threaded encoder doesn't support LZMA_SYNC_FLUSH. // from the filter chain. Currently threaded encoder doesn't support
// FIXME: When LZMA_SYNC_FLUSH is supported, this should be changed. // LZMA_SYNC_FLUSH so single-threaded mode must be used.
if (opt_mode == MODE_COMPRESS && opt_flush_timeout != 0 if (opt_mode == MODE_COMPRESS && opt_flush_timeout != 0) {
&& hardware_threads_get() > 1) { for (size_t i = 0; i < filters_count; ++i) {
message(V_WARNING, _("Switching to single-threaded mode " switch (filters[i].id) {
"due to --flush-timeout=%" PRIu64), case LZMA_FILTER_LZMA2:
opt_flush_timeout); case LZMA_FILTER_DELTA:
break;
default:
message_fatal(_("The filter chain is "
"incompatible with --flush-timeout"));
}
}
if (hardware_threads_get() > 1) {
message(V_WARNING, _("Switching to single-threaded "
"mode due to --flush-timeout"));
hardware_threads_set(1); hardware_threads_set(1);
} }
}
// Get the memory usage. Note that if --format=raw was used, // Get the memory usage. Note that if --format=raw was used,
// we can be decompressing. // we can be decompressing.