summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2016-12-04 02:35:27 +0100
committerGuillem Jover <guillem@debian.org>2016-12-17 01:42:07 +0100
commit4af19ef13553873dcc24e82d7984f5ce6703f0fc (patch)
treecac1688dd4616c7e5af5f6644b0ad6e03039aed7 /lib
parent0d609e2c8c0070310b531d2d470f79044121bea8 (diff)
downloaddpkg-4af19ef13553873dcc24e82d7984f5ce6703f0fc.tar.gz
libdpkg: Use lzma_cputhreads() instead of sysconf(_SC_NPROCESSORS_ONLN)
The former is way more portable than the latter.
Diffstat (limited to 'lib')
-rw-r--r--lib/dpkg/compress.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c
index 2eda658fa..45c0af505 100644
--- a/lib/dpkg/compress.c
+++ b/lib/dpkg/compress.c
@@ -531,7 +531,6 @@ filter_xz_init(struct io_lzma *io, lzma_stream *s)
#ifdef HAVE_LZMA_MT
lzma_mt mt_options = {
.flags = 0,
- .threads = sysconf(_SC_NPROCESSORS_ONLN),
.block_size = 0,
.timeout = 0,
.filters = NULL,
@@ -548,6 +547,11 @@ filter_xz_init(struct io_lzma *io, lzma_stream *s)
#ifdef HAVE_LZMA_MT
mt_options.preset = preset;
+
+ mt_options.threads = lzma_cputhreads();
+ if (mt_options.threads == 0)
+ mt_options.threads = 1;
+
ret = lzma_stream_encoder_mt(s, &mt_options);
#else
ret = lzma_easy_encoder(s, preset, check);