[vlc-devel] [PATCH 1/5] httpd: store timeout date rather than activity date

remi at remlab.net remi at remlab.net
Sun Nov 22 17:53:24 CET 2020


From: RĂ©mi Denis-Courmont <remi at remlab.net>

This should not make any functional differences.
---
 src/network/httpd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 52c8e5bdf3..24f7912e27 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -146,7 +146,7 @@ struct httpd_client_t
     bool    b_stream_mode;
     uint8_t i_state;
 
-    vlc_tick_t i_activity_date;
+    vlc_tick_t i_timeout_date;
     vlc_tick_t i_activity_timeout;
 
     /* buffer for reading header */
@@ -1204,8 +1204,8 @@ void httpd_MsgAdd(httpd_message_t *msg, const char *name, const char *psz_value,
 static void httpd_ClientInit(httpd_client_t *cl, vlc_tick_t now)
 {
     cl->i_state = HTTPD_CLIENT_RECEIVING;
-    cl->i_activity_date = now;
     cl->i_activity_timeout = VLC_TICK_FROM_SEC(10);
+    cl->i_timeout_date = now + cl->i_activity_timeout;
     cl->i_buffer_size = HTTPD_CL_BUFSIZE;
     cl->i_buffer = 0;
     cl->p_buffer = xmalloc(cl->i_buffer_size);
@@ -1744,15 +1744,14 @@ static void httpdLoop(httpd_host_t *host)
         }
 
         if (cl->i_state == HTTPD_CLIENT_DEAD
-         || (cl->i_activity_timeout > 0
-          && cl->i_activity_date + cl->i_activity_timeout < now)) {
+         || (cl->i_activity_timeout > 0 && cl->i_timeout_date < now)) {
             host->client_count--;
             httpd_ClientDestroy(cl);
             continue;
         }
 
         if (val == 0) {
-            cl->i_activity_date = now;
+            cl->i_timeout_date = now + cl->i_activity_timeout;
             delay = 0;
         }
 
-- 
2.29.2



More information about the vlc-devel mailing list