libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 7c75a906a6adec1653d9e6e90c30de24f0fe6d31
parent 841845233e6b31d017077ff70111c4049076bd27
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 18 Nov 2011 19:18:24 +0000

fixing 1914

Diffstat:
MChangeLog | 4++++
Msrc/daemon/daemon.c | 18+++++++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Fri Nov 18 20:17:22 CET 2011 + Fixing return value of MHD_get_timeout if timeouts are not in use. + (#1914). -rboulton + Sun Nov 13 13:34:29 CET 2011 Trying to fix accidental addition of a "Connection: close" footer under certain (rare) circumstances. -CG diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -1204,6 +1204,7 @@ MHD_get_timeout (struct MHD_Daemon *daemon, time_t earliest_deadline; time_t now; struct MHD_Connection *pos; + int have_timeout = MHD_NO; if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { @@ -1215,19 +1216,22 @@ MHD_get_timeout (struct MHD_Daemon *daemon, pos = daemon->connections_head; if (pos == NULL) return MHD_NO; /* no connections */ - earliest_deadline = pos->last_activity + pos->connection_timeout; - pos = pos->next; while (pos != NULL) { - if (earliest_deadline > pos->last_activity + pos->connection_timeout) - earliest_deadline = pos->last_activity + pos->connection_timeout; + if (0 != pos->connection_timeout) { + have_timeout = MHD_YES; + if (earliest_deadline > pos->last_activity + pos->connection_timeout) + earliest_deadline = pos->last_activity + pos->connection_timeout; #if HTTPS_SUPPORT - if ( (0 != (daemon->options & MHD_USE_SSL)) && - (0 != gnutls_record_check_pending (pos->tls_session)) ) - earliest_deadline = 0; + if ( (0 != (daemon->options & MHD_USE_SSL)) && + (0 != gnutls_record_check_pending (pos->tls_session)) ) + earliest_deadline = 0; #endif + } pos = pos->next; } + if (!have_timeout) + return MHD_NO; now = time (NULL); if (earliest_deadline < now) *timeout = 0;