[vlc-devel] [PATCH 1/2] httpd: Fix answer sending from custom handlers

Hugo Beauzée-Luyssen hugo at beauzee.fr
Fri Jun 12 10:22:32 CEST 2020


On Thu, Jun 11, 2020, at 5:31 PM, Rémi Denis-Courmont wrote:
> Le torstaina 11. kesäkuuta 2020, 13.59.29 EEST Hugo Beauzée-Luyssen a écrit :
> > In case of custom handlers, the entire response is crafted by pf_fill.
> > This will in turn cause 0 bytes of headers to be sent, which is expected
> > since those headers are contained in the answer, however we will treat
> > such a case as a dead connection,
> 
> I think that's a misunderstanding and a bug. Writing can return 0 on a full 
> file system. But I don't think you can get a 0 write return other than writing 
> 0 bytes on a TCP socket.
> 

Hi,

If I understand correctly, you're saying that the correct fix would rather be something like

diff --git a/src/network/httpd.c b/src/network/httpd.c
index d4b188bad3..6170cc997d 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -1610,7 +1610,7 @@ static int 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) {
+    if (i_len < 0) {
         cl->i_state = HTTPD_CLIENT_DEAD; /* connection closed */
         return 0;
     }

?

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list