[dpkg] 59/200: libdpkg: Use lzma_cputhreads() instead of sysconf(_SC_NPROCESSORS_ONLN)

Ximin Luo infinity0 at debian.org
Wed Apr 5 15:17:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository dpkg.

commit 4af19ef13553873dcc24e82d7984f5ce6703f0fc
Author: Guillem Jover <guillem at debian.org>
Date:   Sun Dec 4 02:35:27 2016 +0100

    libdpkg: Use lzma_cputhreads() instead of sysconf(_SC_NPROCESSORS_ONLN)
    
    The former is way more portable than the latter.
---
 debian/changelog    | 2 ++
 lib/dpkg/compress.c | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index ac2aeda..ef98459 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 2eda658..45c0af5 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);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list