[vlc-commits] tls: add vlc_tls_Close() helper

Rémi Denis-Courmont git at videolan.org
Fri Dec 18 23:21:30 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Dec 18 23:03:45 2015 +0200| [8fa6f55c1afe83f3c0cbd2d2b4c46aedef153a10] | committer: Rémi Denis-Courmont

tls: add vlc_tls_Close() helper

In most cases... actually in all cases that I know of, the TCP
connection underneath the TLS session is closed at the same time.

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

 include/vlc_tls.h |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/vlc_tls.h b/include/vlc_tls.h
index af9bc0c..67b27cc 100644
--- a/include/vlc_tls.h
+++ b/include/vlc_tls.h
@@ -91,6 +91,20 @@ VLC_API int vlc_tls_Write(vlc_tls_t *, const void *buf, size_t len);
 # define tls_Recv(a,b,c) vlc_tls_Read(a,b,c,false)
 # define tls_Send(a,b,c) vlc_tls_Write(a,b,c)
 
+/**
+ * Closes a TLS session and underlying connection.
+ *
+ * This function is non-blocking and is a cancellation point.
+ */
+static inline void vlc_tls_Close(vlc_tls_t *session)
+{
+    int fd = session->fd;
+
+    vlc_tls_SessionDelete(session);
+    shutdown(fd, SHUT_RDWR);
+    net_Close(fd);
+}
+
 /** TLS credentials (certificate, private and trust settings) */
 struct vlc_tls_creds
 {



More information about the vlc-commits mailing list