Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2011-02-12 08:03:33 +0300
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2011-02-12 08:05:15 +0300
commit64a750eff3f8e676dcbb793785053991acbc731b (patch)
tree018bc4ba7f8e33f860258201390a5dd2e12b4ff7 /support
parentc365c9a8f29e07f0f7790c28937fea9a6727608d (diff)
[gzip] Allow partial flush
When Flush() is called explicitly, do a Z_PARTIAL_FLUSH to force gzip into giving us whatever is available. Less efficient, but compatible with MS.
Diffstat (limited to 'support')
-rw-r--r--support/zlib-helper.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/support/zlib-helper.c b/support/zlib-helper.c
index 66b58663a5e..6cfeb8c442c 100644
--- a/support/zlib-helper.c
+++ b/support/zlib-helper.c
@@ -42,6 +42,7 @@ gint CloseZStream (ZStream *zstream);
gint Flush (ZStream *stream);
gint ReadZStream (ZStream *stream, guchar *buffer, gint length);
gint WriteZStream (ZStream *stream, guchar *buffer, gint length);
+static gint flush_internal (ZStream *stream, gboolean is_final);
static void *
z_alloc (void *opaque, gsize nitems, gsize item_size)
@@ -106,7 +107,7 @@ CloseZStream (ZStream *zstream)
if (zstream->stream->total_in > 0) {
do {
status = deflate (zstream->stream, Z_FINISH);
- flush_status = Flush (zstream);
+ flush_status = flush_internal (zstream, TRUE);
} while (status == Z_OK); /* We want Z_STREAM_END or error here here */
if (status == Z_STREAM_END)
status = flush_status;
@@ -132,23 +133,36 @@ write_to_managed (ZStream *stream)
if (zs->avail_out != BUFFER_SIZE) {
n = stream->func (stream->buffer, BUFFER_SIZE - zs->avail_out, stream->gchandle);
zs->next_out = stream->buffer;
- zs->avail_out = BUFFER_SIZE;
+ zs->avail_out = BUFFER_SIZE;
if (n < 0)
return IO_ERROR;
}
return 0;
}
-gint
-Flush (ZStream *stream)
+static gint
+flush_internal (ZStream *stream, gboolean is_final)
{
+ gint status;
+
if (!stream->compress)
return 0;
+ if (!is_final) {
+ status = deflate (stream->stream, Z_PARTIAL_FLUSH);
+ if (status != Z_OK && status != Z_STREAM_END)
+ return status;
+ }
return write_to_managed (stream);
}
gint
+Flush (ZStream *stream)
+{
+ return flush_internal (stream, FALSE);
+}
+
+gint
ReadZStream (ZStream *stream, guchar *buffer, gint length)
{
gint n;