Ensure chunker is refilled up to capacity - dedup - deduplicating backup program
 (HTM) git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9af5dd1c8a0f4ed051b7247ca759263f5cfee054
 (DIR) parent 1f27546ac6b0a4fd6f0c5198afa34d5220e57107
 (HTM) Author: sin <sin@2f30.org>
       Date:   Thu, 21 Feb 2019 14:57:30 +0000
       
       Ensure chunker is refilled up to capacity
       
       Previously we were not refilling the chunker up to its max capacity
       when reading from a pipe.
       
       Diffstat:
         M chunker.c                           |      15 ++++++++++-----
       
       1 file changed, 10 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/chunker.c b/chunker.c
       @@ -81,11 +81,16 @@ fill_chunker(struct chunker *chunker)
                uint8_t *bp;
                ssize_t n;
        
       -        bp = &chunker->buf[chunker->wpos];
       -        n = read(chunker->fd, bp, chunker->cap - chunker->wpos);
       -        if (n < 0)
       -                err(1, "read");
       -        chunker->wpos += n;
       +        while (chunker->cap != chunker->wpos) {
       +                bp = &chunker->buf[chunker->wpos];
       +                n = read(chunker->fd, bp, chunker->cap - chunker->wpos);
       +                if (n < 0)
       +                        err(1, "read");
       +                else if (n == 0)
       +                        break;
       +                chunker->wpos += n;
       +        }
       +
                return chunker->wpos;
        }