deflatePending ist not available everywhere. Just treat the (very rare) case of some data being left over like all other reallocatables

master
Dirk Engling 7 months ago
parent 806a6b99cf
commit 62807ad205

@ -285,16 +285,10 @@ static void fullscrape_make_gzip(int taskid, ot_tasktype mode) {
return mutex_bucket_unlock(bucket, 0); return mutex_bucket_unlock(bucket, 0);
} }
{ /* Check if there's a last batch of data in the zlib buffer */
unsigned int pending; if (!strm.avail_out) {
int bits;
deflatePending(&strm, &pending, &bits);
pending += (bits ? 1 : 0);
if (pending) {
/* Allocate a fresh output buffer */ /* Allocate a fresh output buffer */
iovector.iov_base = malloc(pending); iovector.iov_base = malloc(OT_SCRAPE_CHUNK_SIZE);
iovector.iov_len = pending;
if (!iovector.iov_base) { if (!iovector.iov_base) {
fprintf(stderr, "Problem with iovec_fix_increase_or_free\n"); fprintf(stderr, "Problem with iovec_fix_increase_or_free\n");
@ -302,14 +296,15 @@ static void fullscrape_make_gzip(int taskid, ot_tasktype mode) {
return mutex_bucket_unlock(bucket, 0); return mutex_bucket_unlock(bucket, 0);
} }
strm.next_out = iovector.iov_base; strm.next_out = iovector.iov_base;
strm.avail_out = pending; strm.avail_out = OT_SCRAPE_CHUNK_SIZE;
if (deflate(&strm, Z_FINISH) < Z_OK) if (deflate(&strm, Z_FINISH) < Z_OK)
fprintf(stderr, "deflate() failed while in fullscrape_make()'s endgame.\n"); fprintf(stderr, "deflate() failed while in fullscrape_make()'s endgame.\n");
if (mutex_workqueue_pushchunked(taskid, &iovector)) /* Only pass the new buffer if there actually was some data left in the buffer */
iovector.iov_len = (char *)strm.next_out - (char *)iovector.iov_base;
if (!iovector.iov_len || mutex_workqueue_pushchunked(taskid, &iovector))
free(iovector.iov_base); free(iovector.iov_base);
} }
}
deflateEnd(&strm); deflateEnd(&strm);
} }

Loading…
Cancel
Save