From 85ab3b266912a1ee26aa2d8e9b40482d401502e8 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sun, 19 Apr 2009 14:45:44 -0400 Subject: [PATCH] Flush the data buffer before sending the final XFER status message. --- src/commands.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/commands.c b/src/commands.c index 1e818711..498c8c49 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1513,6 +1513,7 @@ static gpg_error_t xfer_data(assuan_context_t ctx, const gchar *line, gpg_error_t rc; struct assuan_cmd_s data; int progress = get_key_file_integer("global", "xfer_progress"); + int flush = 0; progress = progress>0 ? (progress/ASSUAN_LINELENGTH)*ASSUAN_LINELENGTH : 0; @@ -1527,21 +1528,27 @@ static gpg_error_t xfer_data(assuan_context_t ctx, const gchar *line, if (rc) return rc; +again: do { if (sent + to_send > total) to_send = total - sent; - data.line = (gchar *)line+sent; - data.line_len = to_send; + data.line = flush ? NULL : (gchar *)line+sent; + data.line_len = flush ? 0 : to_send; rc = do_assuan_command(ctx, send_data_cb, &data); if (!rc) { - sent += to_send; + sent += flush ? 0 : to_send; - if ((progress && !(sent % progress)) || sent == total) + if ((progress && !(sent % progress) && sent != total) || + (sent == total && flush)) rc = send_status(ctx, STATUS_XFER, "%li %li", sent, total); - } + if (!flush && !rc && sent == total) { + flush = 1; + goto again; + } + } } while (!rc && sent < total); return rc; -- 2.11.4.GIT