[vlc-devel] [PATCH] core: network: recover from reading on invalid sockets
Xie Zhigang
zighouse at hotmail.com
Tue Jan 15 12:52:12 CET 2019
Fix the bug on Windows: if pausing the on-line VOD playing
for a long time (5 minutes or so), and the remote VOD server drops the
tcp connection, vlc_tls_Read() will be in an endless loop of retrial
with errno as EAGAIN. Use a max retrial count to recover vlc from the
endless reading loop.
---
src/network/stream.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/network/stream.c b/src/network/stream.c
index 6e015d5..7324f78 100644
--- a/src/network/stream.c
+++ b/src/network/stream.c
@@ -55,6 +55,7 @@ ssize_t vlc_tls_Read(vlc_tls_t *session, void *buf, size_t len, bool waitall)
{
struct pollfd ufd;
struct iovec iov;
+ int turn = 0;
ufd.events = POLLIN;
ufd.fd = vlc_tls_GetPollFD(session, &ufd.events);
@@ -89,6 +90,12 @@ ssize_t vlc_tls_Read(vlc_tls_t *session, void *buf, size_t len, bool waitall)
}
vlc_poll_i11e(&ufd, 1, -1);
+ /*
+ * Use an arbitrary max retrial count (10) to recover from endless loop
+ * on an invalid connection.
+ */
+ if (++turn > 10)
+ return rcvd ? (ssize_t)rcvd : -1;
}
}
--
2.7.4
More information about the vlc-devel
mailing list