[vlc-devel] [PATCH 7/9] httpd: update activity time on actual activity

RĂ©mi Denis-Courmont remi at remlab.net
Sat Jun 6 19:31:19 CEST 2020


Account for actual data read or written, rather than iteration of the
poll loop.

Note: This won't count TLS handshake progress as activity. But if
the client cannot complete the handshake within a time-out interval,
we might as well drop it.
---
 src/network/httpd.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index d36c63185e..ae19f81d78 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1986,6 +1986,7 @@ static void httpdLoop(httpd_host_t *host)
 
     vlc_list_foreach(cl, &host->clients, node) {
         const struct pollfd *pufd = &ufd[nfd];
+        int val = -1;
 
         assert(pufd < &ufd[ARRAY_SIZE(ufd)]);
 
@@ -1995,16 +1996,21 @@ static void httpdLoop(httpd_host_t *host)
         if (pufd->revents == 0)
             continue; // no event received
 
-        cl->i_activity_date = now;
-
         switch (cl->i_state) {
-            case HTTPD_CLIENT_RECEIVING: httpd_ClientRecv(cl); break;
-            case HTTPD_CLIENT_SENDING:   httpd_ClientSend(cl); break;
+            case HTTPD_CLIENT_RECEIVING:
+                val = httpd_ClientRecv(cl);
+                break;
+            case HTTPD_CLIENT_SENDING:
+                val = httpd_ClientSend(cl);
+                break;
             case HTTPD_CLIENT_TLS_HS_IN:
             case HTTPD_CLIENT_TLS_HS_OUT:
                 httpd_ClientTlsHandshake(host, cl);
                 break;
         }
+
+        if (val == 0)
+            cl->i_activity_date = now;
     }
 
     /* Handle server sockets (accept new connections) */
-- 
2.27.0



More information about the vlc-devel mailing list