libmicrohttpd

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

commit 396aab2e1190425c9085e697e502522f4e249cff
parent 605bb70bdec54203561a0ba5917c78e2848cc74c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 16 Mar 2017 22:30:20 +0300

Do not update last activity time on connections without timeout timer

Diffstat:
Msrc/include/microhttpd.h | 2++
Msrc/microhttpd/connection.c | 11+++++++++--
Msrc/microhttpd/connection.h | 2+-
3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -3143,6 +3143,8 @@ enum MHD_CONNECTION_OPTION * Set a custom timeout for the given connection. Specified * as the number of seconds, given as an `unsigned int`. Use * zero for no timeout. + * If timeout was set to zero (or unset) before, setup of new value by + * MHD_set_connection_option() will reset timeout timer. */ MHD_CONNECTION_OPTION_TIMEOUT diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -2373,11 +2373,15 @@ MHD_update_last_activity_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; + if (0 == connection->connection_timeout) + return; /* Skip update of activity for connections + without timeout timer. */ + if (connection->suspended) + return; /* no activity on suspended connections */ + connection->last_activity = MHD_monotonic_sec_counter(); if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) return; /* each connection has personal timeout */ - if (connection->suspended) - return; /* not timeouts for suspended connections */ if (connection->connection_timeout != daemon->connection_timeout) return; /* custom timeout, no need to move it in "normal" DLL */ @@ -3373,6 +3377,9 @@ MHD_set_connection_option (struct MHD_Connection *connection, switch (option) { case MHD_CONNECTION_OPTION_TIMEOUT: + if (0 == connection->connection_timeout) + connection->last_activity = MHD_monotonic_sec_counter(); + MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); if ( (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && (! connection->suspended) ) diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h @@ -142,6 +142,6 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection); * @param connection the connection that saw some activity */ void -update_last_activity (struct MHD_Connection *connection); +MHD_update_last_activity_ (struct MHD_Connection *connection); #endif