diff options
Diffstat (limited to 'ot_fullscrape.c')
-rw-r--r-- | ot_fullscrape.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/ot_fullscrape.c b/ot_fullscrape.c index b147b6a..86b9e26 100644 --- a/ot_fullscrape.c +++ b/ot_fullscrape.c | |||
@@ -262,33 +262,36 @@ fprintf(stderr, "GZIP path\n"); | |||
262 | if( deflate( &strm, Z_FINISH ) < Z_OK ) | 262 | if( deflate( &strm, Z_FINISH ) < Z_OK ) |
263 | fprintf( stderr, "deflate() failed while in fullscrape_make()'s endgame.\n" ); | 263 | fprintf( stderr, "deflate() failed while in fullscrape_make()'s endgame.\n" ); |
264 | 264 | ||
265 | if( !strm.avail_out ) { | 265 | iovector.iov_len = (char *)strm.next_out - (char *)iovector.iov_base; |
266 | if (mutex_workqueue_pushchunked(taskid, &iovector) ) { | ||
267 | free(iovector.iov_base); | ||
268 | return mutex_bucket_unlock( bucket, 0 ); | ||
269 | } | ||
270 | |||
271 | { | ||
266 | unsigned int pending; | 272 | unsigned int pending; |
267 | int bits; | 273 | int bits; |
268 | deflatePending( &strm, &pending, &bits); | 274 | deflatePending( &strm, &pending, &bits); |
269 | pending += ( bits ? 1 : 0 ); | 275 | pending += ( bits ? 1 : 0 ); |
270 | 276 | ||
271 | iovector.iov_len = (char *)strm.next_out - (char *)iovector.iov_base; | 277 | if (pending) { |
272 | if (mutex_workqueue_pushchunked(taskid, &iovector) ) { | 278 | /* Allocate a fresh output buffer */ |
273 | free(iovector.iov_base); | 279 | iovector.iov_base = malloc( pending ); |
280 | iovector.iov_len = pending; | ||
281 | |||
282 | if( !iovector.iov_base ) { | ||
283 | fprintf( stderr, "Problem with iovec_fix_increase_or_free\n" ); | ||
284 | deflateEnd(&strm); | ||
274 | return mutex_bucket_unlock( bucket, 0 ); | 285 | return mutex_bucket_unlock( bucket, 0 ); |
275 | } | 286 | } |
276 | /* Allocate a fresh output buffer */ | 287 | strm.next_out = iovector.iov_base; |
277 | iovector.iov_base = malloc( pending ); | 288 | strm.avail_out = pending; |
278 | iovector.iov_len = pending; | 289 | if( deflate( &strm, Z_FINISH ) < Z_OK ) |
290 | fprintf( stderr, "deflate() failed while in fullscrape_make()'s endgame.\n" ); | ||
279 | 291 | ||
280 | if( !iovector.iov_base ) { | 292 | if( mutex_workqueue_pushchunked(taskid, &iovector) ) |
281 | fprintf( stderr, "Problem with iovec_fix_increase_or_free\n" ); | 293 | free(iovector.iov_base); |
282 | deflateEnd(&strm); | ||
283 | return mutex_bucket_unlock( bucket, 0 ); | ||
284 | } | 294 | } |
285 | strm.next_out = iovector.iov_base; | ||
286 | strm.avail_out = pending; | ||
287 | if( deflate( &strm, Z_FINISH ) < Z_OK ) | ||
288 | fprintf( stderr, "deflate() failed while in fullscrape_make()'s endgame.\n" ); | ||
289 | |||
290 | if( mutex_workqueue_pushchunked(taskid, &iovector) ) | ||
291 | free(iovector.iov_base); | ||
292 | } | 295 | } |
293 | 296 | ||
294 | deflateEnd(&strm); | 297 | deflateEnd(&strm); |