vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sat Jun 6 20:21:10 2020 +0300| [a1116cbad0504c09b85e1db518e61fc41d4e672f] | 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. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a1116cbad0504c09b85e1db518e61fc41d4e672f --- src/network/httpd.c | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/network/httpd.c b/src/network/httpd.c index ae19f81d78..6e1aed8a1b 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -1727,6 +1727,21 @@ static void httpdLoop(httpd_host_t *host) int canc = vlc_savecancel(); vlc_list_foreach(cl, &host->clients, node) { + 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_state == HTTPD_CLIENT_DEAD || (cl->i_activity_timeout > 0 && cl->i_activity_date + cl->i_activity_timeout < now)) { @@ -1735,6 +1750,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 + ARRAY_SIZE (ufd)); @@ -1984,35 +2002,6 @@ static void httpdLoop(httpd_host_t *host) now = vlc_tick_now(); nfd = host->nfd; - vlc_list_foreach(cl, &host->clients, node) { - const struct pollfd *pufd = &ufd[nfd]; - int val = -1; - - assert(pufd < &ufd[ARRAY_SIZE(ufd)]); - - 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++) { int fd = ufd[nfd].fd; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
