summaryrefslogtreecommitdiff
path: root/rpmio/rpmio.c
diff options
context:
space:
mode:
Diffstat (limited to 'rpmio/rpmio.c')
-rw-r--r--rpmio/rpmio.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index 0c1a674dc..7add8536b 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -5,6 +5,7 @@
#include "system.h"
#include <stdarg.h>
#include <errno.h>
+#include <ctype.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmmacro.h>
@@ -898,6 +899,7 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
lzma_ret ret;
lzma_stream init_strm = LZMA_STREAM_INIT;
uint64_t mem_limit = rpmExpandNumeric("%{_xz_memlimit}");
+ int threads = 0;
for (; *mode; mode++) {
if (*mode == 'w')
@@ -906,6 +908,17 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
encoding = 0;
else if (*mode >= '0' && *mode <= '9')
level = *mode - '0';
+ else if (*mode == 'T') {
+ if (isdigit(*(mode+1))) {
+ threads = atoi(++mode);
+ /* skip past rest of digits in string that atoi()
+ * should've processed
+ * */
+ while(isdigit(*++mode));
+ }
+ else
+ threads = -1;
+ }
}
if (fd != -1)
fp = fdopen(fd, encoding ? "w" : "r");
@@ -925,7 +938,22 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
lzfile->strm = init_strm;
if (encoding) {
if (xz) {
- ret = lzma_easy_encoder(&lzfile->strm, level, LZMA_CHECK_SHA256);
+ if (!threads) {
+ ret = lzma_easy_encoder(&lzfile->strm, level, LZMA_CHECK_SHA256);
+ } else {
+ if (threads == -1)
+ threads = sysconf(_SC_NPROCESSORS_ONLN);
+ lzma_mt mt_options = {
+ .flags = 0,
+ .threads = threads,
+ .block_size = 0,
+ .timeout = 0,
+ .preset = level,
+ .filters = NULL,
+ .check = LZMA_CHECK_SHA256 };
+
+ ret = lzma_stream_encoder_mt(&lzfile->strm, &mt_options);
+ }
} else {
lzma_options_lzma options;
lzma_lzma_preset(&options, level);