From a4503766837b845c9ae330116745e77147c61757 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Mon, 7 Jan 2013 23:09:56 -0500 Subject: [PATCH] Reset the KEEPALIVE timer when the previous buffer size is smaller. This means some packets have been sent and the connection is still alive. --- src/commands.c | 3 +++ src/common.h | 4 ++-- src/status.c | 13 +++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/commands.c b/src/commands.c index 9a7e428f..83a81811 100644 --- a/src/commands.c +++ b/src/commands.c @@ -3838,6 +3838,9 @@ command_finalize (assuan_context_t ctx, gpg_error_t rc) log_write1 (_("command completed: rc=%u"), client->last_rc); client->last_rc = gpg_error (GPG_ERR_UNKNOWN_COMMAND); +#ifdef WITH_GNUTLS + client->thd->buffer_timeout = 0; +#endif } static gpg_error_t diff --git a/src/common.h b/src/common.h index 5316a86e..68c9dbba 100644 --- a/src/common.h +++ b/src/common.h @@ -65,10 +65,10 @@ struct client_thread_s int status_msg_pipe[2]; struct client_s *cl; int atfork; - /* For remote connections. */ +#ifdef WITH_GNUTLS int timeout; int buffer_timeout; -#ifdef WITH_GNUTLS + int last_buffer_size; int remote; struct tls_s *tls; #endif diff --git a/src/status.c b/src/status.c index b21ec6a8..8dd230d7 100644 --- a/src/status.c +++ b/src/status.c @@ -129,9 +129,16 @@ send_status (assuan_context_t ctx, status_msg_t which, const char *fmt, ...) int interval = config_get_integer ("global", "keepalive_interval"); int timeout = config_get_integer ("global", "tls_timeout"); + if (buffered < client->thd->last_buffer_size) + client->thd->buffer_timeout = 0; + + client->thd->last_buffer_size = buffered; + if (++client->thd->buffer_timeout * interval >= timeout) rc = gpg_error (GPG_ERR_ETIMEDOUT); } + else + client->thd->buffer_timeout = client->thd->last_buffer_size = 0; #endif } #endif @@ -139,8 +146,10 @@ send_status (assuan_context_t ctx, status_msg_t which, const char *fmt, ...) if (!rc) rc = assuan_write_status (ctx, status, line); - if (which != STATUS_KEEPALIVE) - client->thd->buffer_timeout = 0; +#ifdef WITH_GNUTLS + if (client && which != STATUS_KEEPALIVE) + client->thd->buffer_timeout = client->thd->last_buffer_size = 0; +#endif return rc; } -- 2.11.4.GIT