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

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


vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun  6 20:04:16 2020 +0300| [6e81e9b5870a9ace20077881fc7e17f7e618284c] | 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.

(cherry picked from commit 2faa146b814fcd7e68b02ccee2d620e42f26fc48)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=6e81e9b5870a9ace20077881fc7e17f7e618284c
---

 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 6b7e3328f5..dc47138c02 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1983,6 +1983,7 @@ static void httpdLoop(httpd_host_t *host)
     for (int i_client = 0; i_client < host->i_client; i_client++) {
         httpd_client_t *cl = host->client[i_client];
         const struct pollfd *pufd = &ufd[nfd];
+        int val = -1;
 
         assert(pufd < &ufd[sizeof(ufd) / sizeof(ufd[0])]);
 
@@ -1992,16 +1993,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