From 7e4fee659e1020e3a6fe8a62c1b7cde838a67a72 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 2 Jan 2016 14:46:03 +1100 Subject: [PATCH] Minor fixes --- src/ckpool.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ckpool.c b/src/ckpool.c index 5fcc7c9b..442ac412 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -535,7 +535,7 @@ static void add_bufline(connsock_t *cs, const char *readbuf, const int len) size_t buflen; char *newbuf; - buflen = cs->bufofs + len + 1; + buflen = round_up_page(cs->bufofs + len + 1); while (42) { newbuf = realloc(cs->buf, buflen); if (likely(newbuf)) @@ -564,7 +564,7 @@ static int read_cs_length(connsock_t *cs, float *timeout, int len) ret = wait_read_select(cs->fd, *timeout); if (ret < 1) goto out; - readlen = len - cs->buflen; + readlen = len - cs->bufofs; if (readlen >= PAGESIZE) readlen = PAGESIZE - 4; ret = recv(cs->fd, readbuf, readlen, MSG_DONTWAIT); @@ -617,6 +617,7 @@ static int read_gz_line(connsock_t *cs, float *timeout) ret = -1; goto out; } + /* Clear out all the compressed data */ cs->buflen = cs->bufofs - compsize; cs->bufofs = compsize; @@ -626,9 +627,9 @@ static int read_gz_line(connsock_t *cs, float *timeout) res = round_up_page(decompsize); dest = ckalloc(res); ret = uncompress((Bytef *)dest, &res, (Bytef *)cs->buf, compsize); - if (ret != Z_OK || res != decompsize) { - LOGWARNING("Failed to decompress %lu bytes in read_gz_line, got %d", decompsize, ret); + LOGWARNING("Failed to decompress %lu bytes in read_gz_line, result %d got %lu", + decompsize, ret, res); ret = -1; goto out; } @@ -649,7 +650,6 @@ static int read_gz_line(connsock_t *cs, float *timeout) dest = NULL; cs->bufofs = decompsize; if (buflen) { - LOGWARNING("Remainder %s", buf); add_bufline(cs, buf, buflen); cs->buflen = buflen; cs->bufofs = decompsize;