summaryrefslogtreecommitdiff
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
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.
-rw-r--r--debian/changelog2
-rw-r--r--lib/dpkg/compress.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index ac2aeda16..ef9845982 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ dpkg (1.18.16) UNRELEASED; urgency=medium
which will be run successively. Closes: #671074
* Reject empty upstream versions in C and perl code. These are not permitted
by deb-version(5), but the code was letting those through.
+ * Use lzma_cputhreads() instead of sysconf(_SC_NPROCESSORS_ONLN) as the
+ former is way more portable.
* Perl modules:
- Whitelist DPKG_GENSYMBOLS_CHECK_LEVEL, DPKG_ROOT, DPKG_ADMINDIR and
DPKG_DATADIR environment variables in Dpkg::Build::Info.
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);