libmicrohttpd

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

commit 7d4e3953b7667c87a766c9665d49458d2e60f229
parent 589983325b496245bb31612ff5aa6b1bb808b5fd
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 16 Mar 2017 21:28:32 +0300

Unified update of connection activity.

Diffstat:
Msrc/microhttpd/connection.c | 8++++----
Msrc/microhttpd/connection.h | 9+++++++++
Msrc/microhttpd/connection_https.c | 2+-
Msrc/microhttpd/daemon.c | 5++---
4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -2368,8 +2368,8 @@ parse_connection_headers (struct MHD_Connection *connection) * * @param connection the connection that saw some activity */ -static void -update_last_activity (struct MHD_Connection *connection) +void +MHD_update_last_activity_ (struct MHD_Connection *connection) { struct MHD_Daemon *daemon = connection->daemon; @@ -2405,7 +2405,7 @@ update_last_activity (struct MHD_Connection *connection) int MHD_connection_handle_read (struct MHD_Connection *connection) { - update_last_activity (connection); + MHD_update_last_activity_ (connection); if ( (MHD_CONNECTION_CLOSED == connection->state) || (connection->suspended) ) return MHD_YES; @@ -2480,7 +2480,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) if (connection->suspended) return MHD_YES; - update_last_activity (connection); + MHD_update_last_activity_ (connection); while (1) { #if DEBUG_STATES diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h @@ -134,5 +134,14 @@ int MHD_connection_epoll_update_ (struct MHD_Connection *connection); #endif +/** + * Update the 'last_activity' field of the connection to the current time + * and move the connection to the head of the 'normal_timeout' list if + * the timeout for the connection uses the default value. + * + * @param connection the connection that saw some activity + */ +void +update_last_activity (struct MHD_Connection *connection); #endif diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c @@ -48,7 +48,7 @@ run_tls_handshake (struct MHD_Connection *connection) { int ret; - connection->last_activity = MHD_monotonic_sec_counter (); + MHD_update_last_activity_ (connection); if (MHD_TLS_CONNECTION_INIT == connection->state) { ret = gnutls_handshake (connection->tls_session); diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -1865,10 +1865,9 @@ thread_main_handle_connection (void *data) continue; /* Check again for resume. */ } /* End of "suspended" branch. */ - if ( (was_suspended) && - (0 != con->connection_timeout) ) + if (was_suspended) { - con->last_activity = MHD_monotonic_sec_counter(); /* Reset timeout timer. */ + MHD_update_last_activity_ (con); /* Reset timeout timer. */ was_suspended = false; }