[vlc-devel] [PATCH] tls: fix ignored interrupts

Thomas Guillem thomas at gllm.fr
Tue Oct 10 13:06:07 CEST 2017


If session->readv() or session->writev() are interrupted, the next call to
vlc_poll_i11e() will hang since the interrupt context is already finished (by
readv/writev).
---

This fixes a deadlock that is easy to reproduce when the playlist fetcher is
stuck downloading a covert/art. In that case, the interrupt context is killed
from the playlist/fetcher, and cause the session->writev() call to exit with
errno == EINTR. Since vlc_interrupt_finish() is called from every vlc_i11e
functions, the variable ctx->interrupted is reset to false, so the next call to
a vlc_i11e function will hang.

 src/network/tls.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/network/tls.c b/src/network/tls.c
index 4ebcfb319c..1fae1d0e0f 100644
--- a/src/network/tls.c
+++ b/src/network/tls.c
@@ -253,8 +253,13 @@ ssize_t vlc_tls_Read(vlc_tls_t *session, void *buf, size_t len, bool waitall)
         }
         if (iov.iov_len == 0 || val == 0)
             return rcvd;
-        if (val == -1 && errno != EINTR && errno != EAGAIN)
-            return rcvd ? (ssize_t)rcvd : -1;
+        if (val == -1)
+        {
+            if (vlc_killed())
+                return -1;
+            if (errno != EINTR && errno != EAGAIN)
+                return rcvd ? (ssize_t)rcvd : -1;
+        }
 
         vlc_poll_i11e(&ufd, 1, -1);
     }
@@ -287,8 +292,13 @@ ssize_t vlc_tls_Write(vlc_tls_t *session, const void *buf, size_t len)
         }
         if (iov.iov_len == 0 || val == 0)
             return sent;
-        if (val == -1 && errno != EINTR && errno != EAGAIN)
-            return sent ? (ssize_t)sent : -1;
+        if (val == -1)
+        {
+            if (vlc_killed())
+                return -1;
+            if (errno != EINTR && errno != EAGAIN)
+                return sent ? (ssize_t)sent : -1;
+        }
 
         vlc_poll_i11e(&ufd, 1, -1);
     }
-- 
2.11.0



More information about the vlc-devel mailing list