[vlc-commits] tls: add support for TCP Fast Open (refs #16067)

Rémi Denis-Courmont git at videolan.org
Sat Feb 25 22:41:58 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 25 23:07:16 2017 +0200| [72f0a2e63548685870403f51d725cd0650c5e8be] | committer: Rémi Denis-Courmont

tls: add support for TCP Fast Open (refs #16067)

This only works underneath client-side TLS so far.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=72f0a2e63548685870403f51d725cd0650c5e8be
---

 src/network/tls.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/network/tls.c b/src/network/tls.c
index 2d04eb4..d7450d2 100644
--- a/src/network/tls.c
+++ b/src/network/tls.c
@@ -480,6 +480,31 @@ static ssize_t vlc_tls_Connect(vlc_tls_t *tls)
 static ssize_t vlc_tls_ConnectWrite(vlc_tls_t *tls,
                                     const struct iovec *iov,unsigned count)
 {
+#ifdef MSG_FASTOPEN
+    vlc_tls_socket_t *sock = (vlc_tls_socket_t *)tls;
+    const struct msghdr msg =
+    {
+        .msg_name = sock->peer,
+        .msg_namelen = sock->peerlen,
+        .msg_iov = (struct iovec *)iov,
+        .msg_iovlen = count,
+    };
+    ssize_t ret;
+
+    ret = sendmsg(vlc_tls_SocketGetFD(tls), &msg, MSG_NOSIGNAL|MSG_FASTOPEN);
+    if (ret >= 0)
+    {   /* Fast open in progress */
+        tls->writev = vlc_tls_SocketWrite;
+        return ret;
+    }
+
+    if (errno == EINPROGRESS)
+        return vlc_tls_WaitConnect(tls);
+    if (errno != EOPNOTSUPP)
+        return -1;
+    /* Fast open not supported or disabled... fallback to normal mode */
+#endif
+
     if (vlc_tls_Connect(tls))
         return -1;
 



More information about the vlc-commits mailing list