[vlc-commits] httpd: don't bother processing failed connection
Rémi Denis-Courmont
git at videolan.org
Mon Jun 8 16:44:08 CEST 2020
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun 6 19:56:10 2020 +0300| [c40e0a527a394a4066aacaecd427db2e6df3606a] | 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.)
(cherry picked from commit d3ce853dd6c40681a1ad2f50d05b9f119c4b1a16)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=c40e0a527a394a4066aacaecd427db2e6df3606a
---
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 7ff90f3529..92254adb56 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1529,13 +1529,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)
@@ -1543,7 +1537,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