[vlc-devel] [PATCH 2/2] network: tls: Handle errors from older kernels

Hugo Beauzée-Luyssen hugo at beauzee.fr
Fri Mar 29 11:35:17 CET 2019


If MSG_FASTOPEN is defined, but turns out to be unimplemented by the
underlying kernel (as is the case on android where the NDK claims to
support fast open but some older kernels don't) EPIPE is returned
instead of EOPNOTSUPP.
See net/ipv4/tcp.c:936 & net/core/stream.c:55
sk_stream_wait_connect will return EPIPE if no SYN was sent/received,
and sendmsg will propagate that error.
Treating EPIPE as a synonym for EOPNOTSUPP here allows us to fallback
on the regular connect + send, instead of an hard error.
---
 src/network/stream.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/network/stream.c b/src/network/stream.c
index 5a24bd7134..d38b2f2680 100644
--- a/src/network/stream.c
+++ b/src/network/stream.c
@@ -383,8 +383,12 @@ static ssize_t vlc_tls_ConnectWrite(vlc_tls_t *tls,
             return -1;
     }
     else
-    if (errno != EOPNOTSUPP)
+    if (errno != EOPNOTSUPP && errno != EPIPE)
+    {
+        /* If MSG_FASTOPEN was defined but the kernel doesn't support fast open at
+           all, EPIPE will be returned instead of EOPNOTSUPP */
         return -1;
+    }
     /* Fast open not supported or disabled... fallback to normal mode */
 #endif
 
-- 
2.20.1



More information about the vlc-devel mailing list