[vlc-commits] chromecast: disable httpd timeout

Thomas Guillem git at videolan.org
Fri Oct 30 13:14:59 CET 2020


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Oct 29 13:30:45 2020 +0100| [518ed638bccefecabfbbb48908d543274ac1680e] | committer: Thomas Guillem

chromecast: disable httpd timeout

Fixes #25151
Fixes #25192

This is a hotfix for VLC 3.0 only. A proper solution need to be found in
VLC 4.0 (likely using a hls or dash server).

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

 modules/stream_out/chromecast/cast.cpp | 9 +++++++++
 src/network/httpd.c                    | 7 +++++++
 2 files changed, 16 insertions(+)

diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index f3840cf4c4..d09c8a8b88 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -1415,7 +1415,16 @@ static int Open(vlc_object_t *p_this)
     var_SetInteger(p_stream, "http-port", i_local_server_port);
     var_Create(p_stream, "http-host", VLC_VAR_STRING);
     var_SetString(p_stream, "http-host", "");
+
+    /* Chromecast clients buffer lot of data (burst mode) and can wait more
+     * than 10 seconds between 2 consecutive I/O. Tell httpd that the
+     * timeout of this client should not be handled (infinite timeout) to
+     * avoid closing the client connection after 10 seconds without any
+     * socket activity */
+    var_Create(p_stream, "http-no-timeout", VLC_VAR_VOID);
+
     httpd_host = vlc_http_HostNew(VLC_OBJECT(p_stream));
+    var_Destroy(p_stream, "http-no-timeout");
     if (httpd_host == NULL)
         goto error;
 
diff --git a/src/network/httpd.c b/src/network/httpd.c
index 3197fb2ec9..69e6399483 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -93,6 +93,7 @@ struct httpd_host_t
     int         i_url;
     httpd_url_t **url;
 
+    bool           b_no_timeout;
     int            i_client;
     httpd_client_t **client;
 
@@ -947,6 +948,10 @@ static httpd_host_t *httpd_HostCreate(vlc_object_t *p_this,
     vlc_cond_init(&host->wait);
     host->i_ref = 1;
 
+    host->b_no_timeout = var_Type(p_this, "http-no-timeout") != 0;
+    if (host->b_no_timeout)
+        msg_Warn(p_this, "httpd timeout disabled");
+
     char *hostname = var_InheritString(p_this, hostvar);
 
     host->fds = net_ListenTCP(p_this, hostname, port);
@@ -2031,6 +2036,8 @@ static void httpdLoop(httpd_host_t *host)
         }
 
         cl = httpd_ClientNew(sk, now);
+        if (host->b_no_timeout)
+            cl->i_activity_timeout = 0;
 
         if (host->p_tls != NULL)
             cl->i_state = HTTPD_CLIENT_TLS_HS_OUT;



More information about the vlc-commits mailing list