[vlc-commits] httpd: don't bother processing failed connection

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


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun  6 19:56:10 2020 +0300| [d3ce853dd6c40681a1ad2f50d05b9f119c4b1a16] | committer: Rémi Denis-Courmont

httpd: don't bother processing failed connection

If the underlying stream failed, there's no point processing an
outstanding request. It's most likely incomplete, and in any case, we
won't be able to send the response.

That corner case only made sense for connections half-closed on read
end. (Even then, it's a little questionable, because half-closed
connections eventually time out if not fully closed.)

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

 src/network/httpd.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/network/httpd.c b/src/network/httpd.c
index 1935487c50..2eece86430 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1540,13 +1540,7 @@ static void httpd_ClientRecv(httpd_client_t *cl)
         }
     }
 
-    /* check if the client is to be set to dead */
-#if defined(_WIN32)
-    if ((i_len < 0 && WSAGetLastError() != WSAEWOULDBLOCK) || (i_len == 0))
-#else
-    if ((i_len < 0 && errno != EAGAIN) || (i_len == 0))
-#endif
-    {
+    if (i_len == 0) {
         if (cl->query.i_proto != HTTPD_PROTO_NONE && cl->query.i_type != HTTPD_MSG_NONE) {
             /* connection closed -> end of data */
             if (cl->query.i_body > 0)
@@ -1554,7 +1548,19 @@ static void httpd_ClientRecv(httpd_client_t *cl)
             cl->i_state = HTTPD_CLIENT_RECEIVE_DONE;
         }
         else
-            cl->i_state = HTTPD_CLIENT_DEAD;
+            cl->i_state = HTTPD_CLIENT_DEAD; /* connection failed */
+        return;
+    }
+
+    /* check if the client is to be set to dead */
+    if (i_len < 0) {
+#if defined(_WIN32)
+        if (WSAGetLastError() != WSAEWOULDBLOCK)
+#else
+        if (errno != EAGAIN)
+#endif
+            cl->i_state = HTTPD_CLIENT_DEAD; /* connection failed */
+        return;
     }
 
     /* XXX: for QT I have to disable timeout. Try to find why */



More information about the vlc-commits mailing list