summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2020-05-08 14:59:49 -0700
committerMichael Pavone <pavone@retrodev.com>2020-05-08 14:59:49 -0700
commit4bc8dcfd59d3cf49190883fb13d238d2929b11fe (patch)
tree84b0c477ad8f40c53360e1bb0a285ff83d22fe5d
parentb31a9b47266bf4ea531cd43f96dc2e666948f175 (diff)
Fix "full" deflate flush so multiple remotes can successfully join
-rw-r--r--event_log.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/event_log.c b/event_log.c
index 79f2bc2..041a736 100644
--- a/event_log.c
+++ b/event_log.c
@@ -357,7 +357,8 @@ static size_t send_all(int sock, uint8_t *data, size_t size, int flags)
void deflate_flush(uint8_t full)
{
output_stream.avail_in = buffer.size - (output_stream.next_in - buffer.data);
- while (output_stream.avail_in)
+ uint8_t force = full;
+ while (output_stream.avail_in || force)
{
if (!output_stream.avail_out) {
size_t old_storage = compressed_storage;
@@ -376,12 +377,13 @@ void deflate_flush(uint8_t full)
if (result != (full ? Z_STREAM_END : Z_OK)) {
fatal_error("deflate returned %d\n", result);
}
- if (full) {
+ if (full && result == Z_STREAM_END) {
result = deflateReset(&output_stream);
if (result != Z_OK) {
fatal_error("deflateReset returned %d\n", result);
}
}
+ force = 0;
}
output_stream.next_in = buffer.data;
buffer.size = 0;