2
0
Эх сурвалжийг харах

Unified update of connection activity.

Evgeny Grin (Karlson2k) 9 жил өмнө
parent
commit
7d4e3953b7

+ 4 - 4
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

+ 9 - 0
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

+ 1 - 1
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);

+ 2 - 3
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;
         }