Commit d3ce853d authored by Rémi Denis-Courmont's avatar 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.)
parent 58e9b8a5
...@@ -1540,13 +1540,7 @@ static void httpd_ClientRecv(httpd_client_t *cl) ...@@ -1540,13 +1540,7 @@ static void httpd_ClientRecv(httpd_client_t *cl)
} }
} }
/* check if the client is to be set to dead */ if (i_len == 0) {
#if defined(_WIN32)
if ((i_len < 0 && WSAGetLastError() != WSAEWOULDBLOCK) || (i_len == 0))
#else
if ((i_len < 0 && errno != EAGAIN) || (i_len == 0))
#endif
{
if (cl->query.i_proto != HTTPD_PROTO_NONE && cl->query.i_type != HTTPD_MSG_NONE) { if (cl->query.i_proto != HTTPD_PROTO_NONE && cl->query.i_type != HTTPD_MSG_NONE) {
/* connection closed -> end of data */ /* connection closed -> end of data */
if (cl->query.i_body > 0) if (cl->query.i_body > 0)
...@@ -1554,7 +1548,19 @@ static void httpd_ClientRecv(httpd_client_t *cl) ...@@ -1554,7 +1548,19 @@ static void httpd_ClientRecv(httpd_client_t *cl)
cl->i_state = HTTPD_CLIENT_RECEIVE_DONE; cl->i_state = HTTPD_CLIENT_RECEIVE_DONE;
} }
else 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 */ /* XXX: for QT I have to disable timeout. Try to find why */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment