Parcourir la source

libdpkg: Use lzma_cputhreads() instead of sysconf(_SC_NPROCESSORS_ONLN)

The former is way more portable than the latter.
Guillem Jover il y a 9 ans
Parent
commit
4af19ef135
2 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 2 0
      debian/changelog
  2. 5 1
      lib/dpkg/compress.c

+ 2 - 0
debian/changelog

@@ -5,6 +5,8 @@ dpkg (1.18.16) UNRELEASED; urgency=medium
     which will be run successively. Closes: #671074
     which will be run successively. Closes: #671074
   * Reject empty upstream versions in C and perl code. These are not permitted
   * Reject empty upstream versions in C and perl code. These are not permitted
     by deb-version(5), but the code was letting those through.
     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:
   * Perl modules:
     - Whitelist DPKG_GENSYMBOLS_CHECK_LEVEL, DPKG_ROOT, DPKG_ADMINDIR and
     - Whitelist DPKG_GENSYMBOLS_CHECK_LEVEL, DPKG_ROOT, DPKG_ADMINDIR and
       DPKG_DATADIR environment variables in Dpkg::Build::Info.
       DPKG_DATADIR environment variables in Dpkg::Build::Info.

+ 5 - 1
lib/dpkg/compress.c

@@ -531,7 +531,6 @@ filter_xz_init(struct io_lzma *io, lzma_stream *s)
 #ifdef HAVE_LZMA_MT
 #ifdef HAVE_LZMA_MT
 	lzma_mt mt_options = {
 	lzma_mt mt_options = {
 		.flags = 0,
 		.flags = 0,
-		.threads = sysconf(_SC_NPROCESSORS_ONLN),
 		.block_size = 0,
 		.block_size = 0,
 		.timeout = 0,
 		.timeout = 0,
 		.filters = NULL,
 		.filters = NULL,
@@ -548,6 +547,11 @@ filter_xz_init(struct io_lzma *io, lzma_stream *s)
 
 
 #ifdef HAVE_LZMA_MT
 #ifdef HAVE_LZMA_MT
 	mt_options.preset = preset;
 	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);
 	ret = lzma_stream_encoder_mt(s, &mt_options);
 #else
 #else
 	ret = lzma_easy_encoder(s, preset, check);
 	ret = lzma_easy_encoder(s, preset, check);