20010548 pigz --index doesn't create index when only one processor
authorMichael Gerdts <mike.gerdts@oracle.com>
Mon, 26 Jan 2015 08:59:44 -0800
changeset 3687 778f019197ce
parent 3686 c1ae48efb7af
child 3688 60902922c872
20010548 pigz --index doesn't create index when only one processor 20010667 pigz calls deflateEnd() when inflateEnd() should be used
components/pigz/patches/index.patch
--- a/components/pigz/patches/index.patch	Mon Jan 26 08:43:27 2015 -0800
+++ b/components/pigz/patches/index.patch	Mon Jan 26 08:59:44 2015 -0800
@@ -1,18 +1,18 @@
-# HG changeset patch
-# User Michael Gerdts <[email protected]>
-# Date 1412600364 25200
-#      Mon Oct 06 05:59:24 2014 -0700
-# Node ID ba834c48cee26e4c43976af8477dd34863b40f18
-# Parent  1debb63439545fd0b30153eb68e884623d06c531
 parallel uncompress - developed by Oracle
 Offered to upstream at https://github.com/mgerdts/pigz
  - Branch mt-uncompress-2.2 forked from https://github.com/madler/pigz v. 2.2.6
  - Branch mt-uncompress forked from https://github.com/madler/pigz branch master
 
-diff -r 1debb6343954 -r ba834c48cee2 Makefile
+The following generated with:
+
+  git diff -W 8041c56eca89c427aa0a67f40e92675f3584b4bd \
+	be138d877c14c5a3f58c67939bf822d83e342947
+
+diff --git a/Makefile b/Makefile
+index 822902c..0c904a6 100644
 --- a/Makefile
 +++ b/Makefile
[email protected]@ -44,6 +44,15 @@
[email protected]@ -44,6 +44,15 @@ test: pigz
  	  compress -f < pigz.c | ./unpigz | cmp - pigz.c ;\
  	fi
  	@rm -f pigz.c.gz pigz.c.zz pigz.c.zip
@@ -28,10 +28,11 @@
  
  tests: dev test
  	./pigzn -kf pigz.c ; ./pigz -t pigz.c.gz
-diff -r 1debb6343954 -r ba834c48cee2 pigz.1
+diff --git a/pigz.1 b/pigz.1
+index 8d75ca2..f47414f 100644
 --- a/pigz.1
 +++ b/pigz.1
[email protected]@ -180,6 +180,14 @@
[email protected]@ -180,6 +180,14 @@ Provide more verbose output.
  .B -V --version
  Show the version of pigz.
  .TP
@@ -46,10 +47,11 @@
  .B -z --zlib
  Compress to zlib (.zz) instead of gzip format.
  .TP
-diff -r 1debb6343954 -r ba834c48cee2 pigz.c
+diff --git a/pigz.c b/pigz.c
+index ebef63e..5a61315 100644
 --- a/pigz.c
 +++ b/pigz.c
[email protected]@ -191,13 +191,27 @@
[email protected]@ -192,13 +192,27 @@
     effectiveness of deflating in a single thread.  This can be turned off using
     the --independent or -i option, so that the blocks can be decompressed
     independently for partial error recovery or for random access.
@@ -84,7 +86,7 @@
  
     pigz requires zlib 1.2.1 or later to allow setting the dictionary when doing
     raw deflate.  Since zlib 1.2.3 corrects security vulnerabilities in zlib
[email protected]@ -259,13 +273,14 @@
[email protected]@ -260,13 +274,14 @@
     can't get way ahead of the write thread and build up a large backlog of
     unwritten compressed data.  The write thread will write the compressed data,
     drop the output buffer, and then wait for the check value to be unlocked
@@ -106,7 +108,7 @@
  
     The input and output buffers are reused through their collection in pools.
     Each buffer has a use count, which when decremented to zero returns the
[email protected]@ -313,6 +328,9 @@
[email protected]@ -314,6 +329,9 @@
  #if __STDC_VERSION__-0 >= 199901L || __GNUC__-0 >= 3
  #  include <inttypes.h> /* intmax_t */
  #endif
@@ -116,7 +118,7 @@
  
  #ifdef __hpux
  #  include <sys/param.h>
[email protected]@ -420,8 +438,10 @@
[email protected]@ -421,8 +439,10 @@
  local char *prog;           /* name by which pigz was invoked */
  local int ind;              /* input file descriptor */
  local int outd;             /* output file descriptor */
@@ -127,7 +129,7 @@
  local int verbosity;        /* 0 = quiet, 1 = normal, 2 = verbose, 3 = trace */
  local int headis;           /* 1 to store name, 2 to store date, 3 both */
  local int pipeout;          /* write output to stdout even if file */
[email protected]@ -467,9 +487,12 @@
[email protected]@ -468,9 +488,12 @@ local int complain(char *fmt, ...)
      return 0;
  }
  
@@ -140,7 +142,7 @@
      if (outd != -1 && out != NULL)
          unlink(out);
      complain("abort: %s%s", why, what);
[email protected]@ -684,11 +707,23 @@
[email protected]@ -685,11 +708,23 @@ local unsigned long time2dos(time_t t)
      return dos;
  }
  
@@ -165,7 +167,7 @@
  /* write a gzip, zlib, or zip header using the information in the globals */
  local unsigned long put_header(void)
  {
[email protected]@ -982,7 +1017,7 @@
[email protected]@ -983,7 +1018,7 @@ local void new_pool(struct pool *pool, size_t size, int limit)
  
  /* get a space from a pool -- the use count is initially set to one, so there
     is no need to call use_space() for the first use */
@@ -174,7 +176,7 @@
  {
      struct space *space;
  
[email protected]@ -995,6 +1030,15 @@
[email protected]@ -996,6 +1031,15 @@ local struct space *get_space(struct pool *pool)
      if (pool->head != NULL) {
          space = pool->head;
          possess(space->use);
@@ -190,7 +192,7 @@
          pool->head = space->next;
          twist(pool->have, BY, -1);      /* one less in pool */
          twist(space->use, TO, 1);       /* initially one user */
[email protected]@ -1012,15 +1056,20 @@
[email protected]@ -1013,15 +1057,20 @@ local struct space *get_space(struct pool *pool)
      if (space == NULL)
          bail("not enough memory", "");
      space->use = new_lock(1);           /* initially one user */
@@ -213,7 +215,7 @@
  /* compute next size up by multiplying by about 2**(1/3) and round to the next
     power of 2 if we're close (so three applications results in doubling) -- if
     small, go up to at least 16, if overflow, go to max size_t value */
[email protected]@ -1109,17 +1158,35 @@
[email protected]@ -1110,17 +1159,35 @@ local int free_pool(struct pool *pool)
      return count;
  }
  
@@ -250,7 +252,7 @@
  struct job {
      long seq;                   /* sequence number */
      int more;                   /* true if this is not the last chunk */
[email protected]@ -1166,6 +1233,7 @@
[email protected]@ -1167,6 +1234,7 @@ local void setup_jobs(void)
      new_pool(&out_pool, OUTPOOL(size), -1);
      new_pool(&dict_pool, DICT, -1);
      new_pool(&lens_pool, size >> (RSYNCBITS - 1), -1);
@@ -258,7 +260,7 @@
  }
  
  /* command the compress threads to all return, then join them all (call from
[email protected]@ -1202,6 +1270,8 @@
[email protected]@ -1203,6 +1271,8 @@ local void finish_jobs(void)
      Trace(("-- freed %d output buffers", caught));
      caught = free_pool(&in_pool);
      Trace(("-- freed %d input buffers", caught));
@@ -267,7 +269,7 @@
      free_lock(write_first);
      free_lock(compress_have);
      compress_have = NULL;
[email protected]@ -1395,18 +1465,483 @@
[email protected]@ -1396,18 +1466,483 @@ local void compress_thread(void *dummy)
      (void)deflateEnd(&strm);
  }
  
@@ -753,7 +755,7 @@
      unsigned long check;            /* check value of uncompressed data */
  
      (void)dummy;
[email protected]@ -1430,23 +1965,27 @@
[email protected]@ -1431,23 +1966,27 @@ local void write_thread(void *dummy)
          /* update lengths, save uncompressed length for COMB */
          more = job->more;
          len = job->in->len;
@@ -785,7 +787,7 @@
          /* free the job */
          free_lock(job->calc);
          free(job);
[email protected]@ -1517,7 +2056,7 @@
[email protected]@ -1518,7 +2057,7 @@ local void parallel_compress(void)
      setup_jobs();
  
      /* start write thread */
@@ -794,7 +796,7 @@
  
      /* read from input and start compress threads (write thread will pick up
       the output of the compress threads) */
[email protected]@ -1913,7 +2452,7 @@
[email protected]@ -1914,7 +2453,7 @@ local size_t load(void)
  #ifndef NOTHREAD
      /* if first time in or procs == 1, read a buffer to have something to
         return, otherwise wait for the previous read job to complete */
@@ -803,7 +805,7 @@
          /* if first time, fire up the read thread, ask for a read */
          if (in_which == -1) {
              in_which = 1;
[email protected]@ -1995,12 +2534,6 @@
[email protected]@ -1996,12 +2535,6 @@ local void in_init(void)
          in_next += togo; \
      } while (0)
  
@@ -816,7 +818,7 @@
  /* convert MS-DOS date and time to a Unix time, assuming current timezone
     (you got a better idea?) */
  local time_t dos2time(unsigned long dos)
[email protected]@ -2613,6 +3146,73 @@
[email protected]@ -2614,6 +3147,73 @@ local int outb(void *desc, unsigned char *buf, unsigned len)
      return 0;
  }
  
@@ -890,7 +892,7 @@
  /* inflate for decompression or testing -- decompress from ind to outd unless
     decode != 1, in which case just test ind, and then also list if list != 0;
     look for and decode multiple, concatenated gzip and/or zlib streams;
[email protected]@ -2620,10 +3220,8 @@
[email protected]@ -2621,10 +3221,8 @@ local int outb(void *desc, unsigned char *buf, unsigned len)
  local void infchk(void)
  {
      int ret, cont;
@@ -902,7 +904,7 @@
      off_t clen;
  
      cont = 0;
[email protected]@ -2653,65 +3251,7 @@
[email protected]@ -2654,65 +3252,7 @@ local void infchk(void)
          /* compute compressed data length */
          clen = in_tot - in_left;
  
@@ -969,7 +971,7 @@
  
          /* show file information if requested */
          if (list) {
[email protected]@ -2731,6 +3271,231 @@
[email protected]@ -2732,6 +3272,231 @@ local void infchk(void)
          complain("%s OK, has trailing junk which was ignored", in);
  }
  
@@ -1090,9 +1092,9 @@
 +        *prior = job;
 +        twist(write_first, TO, write_head->seq);
 +    }
-+    /* found job with seq == -1 -- free deflate memory and return to join */
++    /* found job with seq == -1 -- free inflate memory and return to join */
 +    release(compress_have);
-+    (void)deflateEnd(&strm);
++    (void)inflateEnd(&strm);
 +}
 +
 +local void parallel_infchk(void)
@@ -1201,7 +1203,7 @@
  /* --- decompress Unix compress (LZW) input --- */
  
  /* memory for unlzw() --
[email protected]@ -3159,7 +3924,7 @@
[email protected]@ -3160,7 +3925,7 @@ local void process(char *path)
          /* if requested, test input file (possibly a special list) */
          if (decode == 2) {
              if (method == 8)
@@ -1210,7 +1212,7 @@
              else {
                  unlzw();
                  if (list) {
[email protected]@ -3219,19 +3984,8 @@
[email protected]@ -3220,19 +3985,8 @@ local void process(char *path)
  
          /* if exists and not -f, give user a chance to overwrite */
          if (outd < 0 && errno == EEXIST && isatty(0) && verbosity) {
@@ -1232,17 +1234,15 @@
          }
  
          /* if exists and no overwrite, report and go on to next */
[email protected]@ -3254,17 +4008,22 @@
[email protected]@ -3255,17 +4009,21 @@ local void process(char *path)
      /* process ind to outd */
      if (verbosity > 1)
          fprintf(stderr, "%s to %s ", in, out);
 +
      if (decode) {
--        if (method == 8)
+         if (method == 8)
 -            infchk();
-+        if (method == 8) {
 +            best_infchk();
-+        }
          else if (method == 256)
              unlzw();
          else
@@ -1250,15 +1250,15 @@
      }
  #ifndef NOTHREAD
 -    else if (procs > 1)
-+    else if (procs > 1) {
-+        if (index != NULL && idx_open(index) != 0)
++    else if (index != NULL) {
++        if (idx_open(index) != 0)
 +            bail("invalid index file", "");
          parallel_compress();
 +    }
  #endif
      else
          single_compress(0);
[email protected]@ -3273,6 +4032,10 @@
[email protected]@ -3274,6 +4032,10 @@ local void process(char *path)
          fflush(stderr);
      }
  
@@ -1269,7 +1269,7 @@
      /* finish up, copy attributes, set times, delete original */
      if (ind != 0)
          close(ind);
[email protected]@ -3331,6 +4094,9 @@
[email protected]@ -3332,6 +4094,9 @@ local char *helptext[] = {
  "  -v, --verbose        Provide more verbose output",
  #endif
  "  -V  --version        Show the version of pigz",
@@ -1279,7 +1279,7 @@
  "  -z, --zlib           Compress to zlib (.zz) instead of gzip format",
  "  --                   All arguments after \"--\" are treated as files"
  };
[email protected]@ -3400,11 +4166,11 @@
[email protected]@ -3401,11 +4166,11 @@ local void defaults(void)
  local char *longopts[][2] = {
      {"LZW", "Z"}, {"ascii", "a"}, {"best", "9"}, {"bits", "Z"},
      {"blocksize", "b"}, {"decompress", "d"}, {"fast", "1"}, {"force", "f"},
@@ -1296,7 +1296,7 @@
      {"version", "V"}, {"zip", "K"}, {"zlib", "z"}};
  #define NLOPTS (sizeof(longopts) / (sizeof(char *) << 1))
  
[email protected]@ -3444,7 +4210,7 @@
[email protected]@ -3445,7 +4210,7 @@ local int option(char *arg)
  
      /* if no argument or dash option, check status of get */
      if (get && (arg == NULL || *arg == '-')) {
@@ -1305,7 +1305,7 @@
          bail("missing parameter after ", bad);
      }
      if (arg == NULL)
[email protected]@ -3503,6 +4269,7 @@
[email protected]@ -3504,6 +4269,7 @@ local int option(char *arg)
              case 'R':  rsync = 1;  break;
              case 'S':  get = 3;  break;
              case 'V':  fputs(VERSION, stderr);  exit(0);
@@ -1313,7 +1313,7 @@
              case 'Z':
                  bail("invalid option: LZW output not supported: ", bad);
              case 'a':
[email protected]@ -3530,7 +4297,7 @@
[email protected]@ -3531,7 +4297,7 @@ local int option(char *arg)
              return 0;
      }
  
@@ -1322,7 +1322,7 @@
      if (get) {
          size_t n;
  
[email protected]@ -3543,7 +4310,7 @@
[email protected]@ -3544,7 +4310,7 @@ local int option(char *arg)
                  OUTPOOL(size) < size ||
                  (ssize_t)OUTPOOL(size) < 0 ||
                  size > (1UL << 22))
@@ -1331,7 +1331,7 @@
              new_opts();
          }
          else if (get == 2) {
[email protected]@ -3561,6 +4328,9 @@
[email protected]@ -3562,6 +4328,9 @@ local int option(char *arg)
          }
          else if (get == 3)
              sufx = arg;                         /* gz suffix */