[vlc-commits] httpd: update activity time on actual activity

Rémi Denis-Courmont git at videolan.org
Mon Jun 8 16:04:09 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun  6 20:04:16 2020 +0300| [2faa146b814fcd7e68b02ccee2d620e42f26fc48] | committer: Rémi Denis-Courmont

httpd: update activity time on actual activity

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2faa146b814fcd7e68b02ccee2d620e42f26fc48
---

 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) */



More information about the vlc-commits mailing list