From da0b9e46726094c47e6ae52ceca2b5dd8f2c62df Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sun, 28 Mar 2010 18:58:55 +0300 Subject: [PATCH] Fix incorrect end of stream when writing dumpstreams It turns out that dumpstream closing code can hang... Fix that. --- streamtools/frame.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/streamtools/frame.c b/streamtools/frame.c index fb84507..39c0906 100644 --- a/streamtools/frame.c +++ b/streamtools/frame.c @@ -402,8 +402,11 @@ void fos_close(struct frame_output_stream* fos) fos->fos_zlib.avail_out = INPUTBUFSZ; fos->fos_zlib.next_out = fos->fos_buffer; - int r = deflate(&fos->fos_zlib, Z_FINISH); - } while(r == Z_OK); + if(r == Z_OK) + r = deflate(&fos->fos_zlib, Z_FINISH); + } while(r == Z_OK || fos->fos_zlib.avail_out < INPUTBUFSZ); + if(r != Z_STREAM_END) + fprintf(stderr, "Error flushing tail\n"); deflateEnd(&fos->fos_zlib); fclose(fos->fos_filp); -- 2.11.4.GIT