[vlc-commits] httpd: reorder, de-indent
Rémi Denis-Courmont
git at videolan.org
Mon Jun 8 16:44:11 CEST 2020
vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun 6 19:45:10 2020 +0300| [a16a1f24dd9ddcd42aa52aa307ffbe59357b1b8a] | committer: Rémi Denis-Courmont
httpd: reorder, de-indent
(No functional changes)
(cherry picked from commit d8cc7df9628f40f8e1161316561f3fc31243fea9)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=a16a1f24dd9ddcd42aa52aa307ffbe59357b1b8a
---
src/network/httpd.c | 67 ++++++++++++++++++++++++++++-------------------------
1 file changed, 36 insertions(+), 31 deletions(-)
diff --git a/src/network/httpd.c b/src/network/httpd.c
index ced2de8ef2..0dffd6239e 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1594,44 +1594,49 @@ static void httpd_ClientSend(httpd_client_t *cl)
i_len = httpd_NetSend(cl, &cl->p_buffer[cl->i_buffer],
cl->i_buffer_size - cl->i_buffer);
- if (i_len >= 0) {
- cl->i_buffer += i_len;
- if (cl->i_buffer >= cl->i_buffer_size) {
- if (cl->answer.i_body == 0 && cl->answer.i_body_offset > 0) {
- /* catch more body data */
- int i_msg = cl->query.i_type;
- int64_t i_offset = cl->answer.i_body_offset;
-
- httpd_MsgClean(&cl->answer);
- cl->answer.i_body_offset = i_offset;
-
- cl->url->catch[i_msg].cb(cl->url->catch[i_msg].p_sys, cl,
- &cl->answer, &cl->query);
- }
-
- if (cl->answer.i_body > 0) {
- /* send the body data */
- free(cl->p_buffer);
- cl->p_buffer = cl->answer.p_body;
- cl->i_buffer_size = cl->answer.i_body;
- cl->i_buffer = 0;
+ if (i_len == 0) {
+ cl->i_state = HTTPD_CLIENT_DEAD; /* connection closed */
+ return;
+ }
- cl->answer.i_body = 0;
- cl->answer.p_body = NULL;
- } else /* send finished */
- cl->i_state = HTTPD_CLIENT_SEND_DONE;
- }
- } else {
+ if (i_len < 0) {
#if defined(_WIN32)
- if ((i_len < 0 && WSAGetLastError() != WSAEWOULDBLOCK) || (i_len == 0))
+ if (WSAGetLastError() != WSAEWOULDBLOCK)
#else
- if ((i_len < 0 && errno != EAGAIN) || (i_len == 0))
+ if (errno != EAGAIN)
#endif
- {
- /* error */
+ /* Connection failed, or hung up (EPIPE) */
cl->i_state = HTTPD_CLIENT_DEAD;
+ return;
+ }
+
+ cl->i_buffer += i_len;
+
+ if (cl->i_buffer >= cl->i_buffer_size) {
+ if (cl->answer.i_body == 0 && cl->answer.i_body_offset > 0) {
+ /* catch more body data */
+ int i_msg = cl->query.i_type;
+ int64_t i_offset = cl->answer.i_body_offset;
+
+ httpd_MsgClean(&cl->answer);
+ cl->answer.i_body_offset = i_offset;
+
+ cl->url->catch[i_msg].cb(cl->url->catch[i_msg].p_sys, cl,
+ &cl->answer, &cl->query);
}
+
+ if (cl->answer.i_body > 0) {
+ /* send the body data */
+ free(cl->p_buffer);
+ cl->p_buffer = cl->answer.p_body;
+ cl->i_buffer_size = cl->answer.i_body;
+ cl->i_buffer = 0;
+
+ cl->answer.i_body = 0;
+ cl->answer.p_body = NULL;
+ } else /* send finished */
+ cl->i_state = HTTPD_CLIENT_SEND_DONE;
}
}
More information about the vlc-commits
mailing list