summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2015-11-26 11:07:47 +0100
committerpark <sk7.park@samsung.com>2017-01-02 02:41:23 -0800
commit002013d7ce56a3d8e253cf276170af58f930a391 (patch)
treeab76253f136952174601f42923bca836cdf2bdbc
parentaa6c5c9e76c87804048f478588928d5061ee9dea (diff)
downloadrpm-002013d7ce56a3d8e253cf276170af58f930a391.tar.gz
rpm-002013d7ce56a3d8e253cf276170af58f930a391.tar.bz2
rpm-002013d7ce56a3d8e253cf276170af58f930a391.zip
Only use multi thread support with liblzma >= 5.2.0submit/tizen_base/20170102.104445accepted/tizen/base/20170106.101320
Change-Id: Icac0310111aa3b59197af934659f7b94ca403059
-rw-r--r--rpmio/rpmio.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index e8c55ff39..34bb3f55d 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -878,6 +878,10 @@ static const char * getFdErrstr (FD_t fd)
#include <sys/types.h>
#include <inttypes.h>
#include <lzma.h>
+/* Multithreading support in stable API since xz 5.2.0 */
+#if LZMA_VERSION >= 50020002
+#define HAVE_LZMA_MT
+#endif
#define kBufferSize (1 << 15)
@@ -903,8 +907,9 @@ 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}");
+#ifdef HAVE_LZMA_MT
int threads = 0;
-
+#endif
for (; *mode; mode++) {
if (*mode == 'w')
encoding = 1;
@@ -914,14 +919,18 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
level = *mode - '0';
else if (*mode == 'T') {
if (isdigit(*(mode+1))) {
+#ifdef HAVE_LZMA_MT
threads = atoi(++mode);
+#endif
/* skip past rest of digits in string that atoi()
* should've processed
* */
while(isdigit(*++mode));
}
+#ifdef HAVE_LZMA_MT
else
threads = -1;
+#endif
}
}
if (fd != -1)
@@ -942,8 +951,11 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
lzfile->strm = init_strm;
if (encoding) {
if (xz) {
+#ifdef HAVE_LZMA_MT
if (!threads) {
+#endif
ret = lzma_easy_encoder(&lzfile->strm, level, LZMA_CHECK_SHA256);
+#ifdef HAVE_LZMA_MT
} else {
if (threads == -1)
threads = sysconf(_SC_NPROCESSORS_ONLN);
@@ -997,12 +1009,13 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
ret = lzma_stream_encoder_mt(&lzfile->strm, &mt_options);
}
+#endif
} else {
lzma_options_lzma options;
lzma_lzma_preset(&options, level);
ret = lzma_alone_encoder(&lzfile->strm, &options);
}
- } else { /* lzma_easy_decoder_memusage(level) is not ready yet, use hardcoded limit for now */
+ } else { /* lzma_easy_decoder_memusage(level) is not ready yet, use hardcoded limit for now */
ret = lzma_auto_decoder(&lzfile->strm, mem_limit ? mem_limit : 100<<20, 0);
}
if (ret != LZMA_OK) {