gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] branch master updated: Fix busy waiting up to one second


From: gnunet
Subject: [libmicrohttpd] branch master updated: Fix busy waiting up to one second using connection timeout
Date: Wed, 11 Aug 2021 22:42:11 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new f5d387df Fix busy waiting up to one second using connection timeout
f5d387df is described below

commit f5d387df7e7fb8de1a5dd0739ddb83a8b19fe64b
Author: Alexander Irion <alexander_irion@mentor.com>
AuthorDate: Wed Aug 11 17:13:12 2021 +0200

    Fix busy waiting up to one second using connection timeout
    
    MHD_daemon_get_timeout computes the time to wait as:
    timeout = (last_activity + connection_timeout - MHD_monotonic_sec_counter 
()) * 1000
    
    After sleeping timeout milliseconds, MHD_monotonic_sec_counter () will be:
    
    MHD_monotonic_sec_counter () = last_activity + connection_timeout
    
    With that (timeout < (MHD_monotonic_sec_counter () - 
connection->last_activity)) evaluates to false and the MHD_connection_close_ is 
not done.
    For the next cycle, MHD_daemon_get_timeout() will return 0 and this goes 
on, until MHD_monotonic_sec_counter jumps to the next second.
    
    This bug causes thousands of unnecessary calls to MHD_run, when a 
connection timed out.
---
 src/lib/connection_call_handlers.c | 4 ++--
 src/microhttpd/connection.c        | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/lib/connection_call_handlers.c 
b/src/lib/connection_call_handlers.c
index aa082ebb..5f2b9d24 100644
--- a/src/lib/connection_call_handlers.c
+++ b/src/lib/connection_call_handlers.c
@@ -3582,8 +3582,8 @@ MHD_request_handle_idle_ (struct MHD_Request *request)
     time_t timeout;
     timeout = connection->connection_timeout;
     if ( (0 != timeout) &&
-         (timeout < (MHD_monotonic_sec_counter ()
-                     - connection->last_activity)) )
+         (timeout <= (MHD_monotonic_sec_counter ()
+                      - connection->last_activity)) )
     {
       MHD_connection_close_ (connection,
                              MHD_REQUEST_TERMINATED_TIMEOUT_REACHED);
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index f9852a06..8de231aa 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -4306,8 +4306,8 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
     time_t timeout;
     timeout = connection->connection_timeout;
     if ( (0 != timeout) &&
-         (timeout < (MHD_monotonic_sec_counter ()
-                     - connection->last_activity)) )
+         (timeout <= (MHD_monotonic_sec_counter ()
+                      - connection->last_activity)) )
     {
       MHD_connection_close_ (connection,
                              MHD_REQUEST_TERMINATED_TIMEOUT_REACHED);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]