aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2014-06-18 19:11:52 +0300
committerLasse Collin <lasse.collin@tukaani.org>2014-06-18 19:11:52 +0300
commit3ce3e7976904fbab4e6482bafa442856f77a51fa (patch)
tree54b3fbf8a68a9d623bb0d8ee4e424b3dd4285ba3 /src
parentxzgrep: List xzgrep_expected_output in tests/Makefile.am. (diff)
downloadxz-3ce3e7976904fbab4e6482bafa442856f77a51fa.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/xz/coder.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/xz/coder.c b/src/xz/coder.c
index 9accecad..947b4721 100644
--- a/src/xz/coder.c
+++ b/src/xz/coder.c
@@ -195,15 +195,27 @@ coder_set_compression_settings(void)
// Print the selected filter chain.
message_filters_show(V_DEBUG, filters);
- // Disable encoder threads when --flush-timeout is used because
- // the threaded encoder doesn't support LZMA_SYNC_FLUSH.
- // FIXME: When LZMA_SYNC_FLUSH is supported, this should be changed.
- if (opt_mode == MODE_COMPRESS && opt_flush_timeout != 0
- && hardware_threads_get() > 1) {
- message(V_WARNING, _("Switching to single-threaded mode "
- "due to --flush-timeout=%" PRIu64),
- opt_flush_timeout);
- hardware_threads_set(1);
+ // The --flush-timeout option requires LZMA_SYNC_FLUSH support
+ // from the filter chain. Currently threaded encoder doesn't support
+ // LZMA_SYNC_FLUSH so single-threaded mode must be used.
+ if (opt_mode == MODE_COMPRESS && opt_flush_timeout != 0) {
+ for (size_t i = 0; i < filters_count; ++i) {
+ switch (filters[i].id) {
+ case LZMA_FILTER_LZMA2:
+ 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);
+ }
}
// Get the memory usage. Note that if --format=raw was used,