vlc/vlc-3.0 | branch: master | Rémi Denis-Courmont <[email protected]> | Sat Jun 6 20:21:10 2020 +0300| [67cdaeea58641d6d515728596f8b194f52538e2b] | committer: Rémi Denis-Courmont
httpd: process client I/O before polling In case of TLS, the TCP socket poll state does not necessarily match the TLS stream state: data may be in the library-side TLS buffers. So we need to try to read/write regardless of the socket events. Refs #24824. (cherry picked from commit a1116cbad0504c09b85e1db518e61fc41d4e672f) > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=67cdaeea58641d6d515728596f8b194f52538e2b --- src/network/httpd.c | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/src/network/httpd.c b/src/network/httpd.c index dc47138c02..37ba36007d 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -1721,6 +1721,21 @@ static void httpdLoop(httpd_host_t *host) int canc = vlc_savecancel(); for (int i_client = 0; i_client < host->i_client; i_client++) { httpd_client_t *cl = host->client[i_client]; + int val = -1; + + switch (cl->i_state) { + case HTTPD_CLIENT_RECEIVING: + val = httpd_ClientRecv(cl); + break; + case HTTPD_CLIENT_SENDING: + val = httpd_ClientSend(cl); + break; + case HTTPD_CLIENT_TLS_HS_IN: + case HTTPD_CLIENT_TLS_HS_OUT: + httpd_ClientTlsHandshake(host, cl); + break; + } + if (cl->i_ref < 0 || (cl->i_ref == 0 && (cl->i_state == HTTPD_CLIENT_DEAD || (cl->i_activity_timeout > 0 && @@ -1731,6 +1746,9 @@ static void httpdLoop(httpd_host_t *host) continue; } + if (val == 0) + cl->i_activity_date = now; + struct pollfd *pufd = ufd + nfd; assert (pufd < ufd + (sizeof (ufd) / sizeof (ufd[0]))); @@ -1976,39 +1994,7 @@ static void httpdLoop(httpd_host_t *host) canc = vlc_savecancel(); vlc_mutex_lock(&host->lock); - /* Handle client sockets */ now = mdate(); - nfd = host->nfd; - - for (int i_client = 0; i_client < host->i_client; i_client++) { - httpd_client_t *cl = host->client[i_client]; - const struct pollfd *pufd = &ufd[nfd]; - int val = -1; - - assert(pufd < &ufd[sizeof(ufd) / sizeof(ufd[0])]); - - if (vlc_tls_GetFD(cl->sock) != pufd->fd) - continue; // we were not waiting for this client - ++nfd; - if (pufd->revents == 0) - continue; // no event received - - switch (cl->i_state) { - case HTTPD_CLIENT_RECEIVING: - val = httpd_ClientRecv(cl); - break; - case HTTPD_CLIENT_SENDING: - val = httpd_ClientSend(cl); - break; - case HTTPD_CLIENT_TLS_HS_IN: - case HTTPD_CLIENT_TLS_HS_OUT: - httpd_ClientTlsHandshake(host, cl); - break; - } - - if (val == 0) - cl->i_activity_date = now; - } /* Handle server sockets (accept new connections) */ for (nfd = 0; nfd < host->nfd; nfd++) { _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
