vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sun Feb 26 15:12:29 2017 +0200| [899f81113f62cc8e0ce8d293da077789b3930dd9] | committer: Rémi Denis-Courmont
vlc_tls_ServerSessionCreate() takes a vlc_tls_t This adds transitional vlc_tls_ServerSessionCreateFD() helper for compatiblity. This is only to maintain sequential builds. The helper will be removed shortly. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=899f81113f62cc8e0ce8d293da077789b3930dd9 --- include/vlc_tls.h | 20 +++++++++++++++++--- src/network/httpd.c | 2 +- src/network/tls.c | 18 +++++------------- test/modules/misc/tls.c | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/include/vlc_tls.h b/include/vlc_tls.h index 35c6b51..de5e90c 100644 --- a/include/vlc_tls.h +++ b/include/vlc_tls.h @@ -163,7 +163,8 @@ VLC_API vlc_tls_t *vlc_tls_ClientSessionCreate(vlc_tls_creds_t *creds, * * @return TLS session, or NULL on error. */ -VLC_API vlc_tls_t *vlc_tls_ServerSessionCreate(vlc_tls_creds_t *creds, int fd, +VLC_API vlc_tls_t *vlc_tls_ServerSessionCreate(vlc_tls_creds_t *creds, + vlc_tls_t *sock, const char *const *alpn); /** @} */ @@ -331,8 +332,21 @@ vlc_tls_ClientSessionCreateFD(vlc_tls_creds_t *crd, int fd, const char *host, vlc_tls_t *tls = vlc_tls_ClientSessionCreate(crd, sock, host, srv, lp, p); if (unlikely(tls == NULL)) free(sock); - else - tls->p = sock; + return tls; +} + +VLC_DEPRECATED +static inline vlc_tls_t * +vlc_tls_ServerSessionCreateFD(vlc_tls_creds_t *crd, int fd, + const char *const *alp) +{ + vlc_tls_t *sock = vlc_tls_SocketOpen(fd); + if (unlikely(sock == NULL)) + return NULL; + + vlc_tls_t *tls = vlc_tls_ServerSessionCreate(crd, sock, alp); + if (unlikely(tls == NULL)) + free(sock); return tls; } diff --git a/src/network/httpd.c b/src/network/httpd.c index 26c4bfe..daab75d 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -2042,7 +2042,7 @@ static void httpdLoop(httpd_host_t *host) { const char *alpn[] = { "http/1.1", NULL }; - p_tls = vlc_tls_ServerSessionCreate(host->p_tls, fd, alpn); + p_tls = vlc_tls_ServerSessionCreateFD(host->p_tls, fd, alpn); } else p_tls = NULL; diff --git a/src/network/tls.c b/src/network/tls.c index 9cde48e..3dcf2f9 100644 --- a/src/network/tls.c +++ b/src/network/tls.c @@ -139,6 +139,8 @@ static vlc_tls_t *vlc_tls_SessionCreate(vlc_tls_creds_t *crd, int canc = vlc_savecancel(); session = crd->open(crd, sock, host, alpn); vlc_restorecancel(canc); + if (session != NULL) + session->p = sock; return session; } @@ -167,8 +169,6 @@ vlc_tls_t *vlc_tls_ClientSessionCreate(vlc_tls_creds_t *crd, vlc_tls_t *sock, if (session == NULL) return NULL; - session->p = sock; - int canc = vlc_savecancel(); mtime_t deadline = mdate (); deadline += var_InheritInteger (crd, "ipv4-timeout") * 1000; @@ -209,19 +209,11 @@ error: return session; } -vlc_tls_t *vlc_tls_ServerSessionCreate(vlc_tls_creds_t *crd, int fd, +vlc_tls_t *vlc_tls_ServerSessionCreate(vlc_tls_creds_t *crd, + vlc_tls_t *sock, const char *const *alpn) { - vlc_tls_t *sock = vlc_tls_SocketOpen(fd); - if (unlikely(sock == NULL)) - return NULL; - - vlc_tls_t *tls = vlc_tls_SessionCreate(crd, sock, NULL, alpn); - if (unlikely(tls == NULL)) - vlc_tls_SessionDelete(sock); - else - tls->p = sock; - return tls; + return vlc_tls_SessionCreate(crd, sock, NULL, alpn); } ssize_t vlc_tls_Read(vlc_tls_t *session, void *buf, size_t len, bool waitall) diff --git a/test/modules/misc/tls.c b/test/modules/misc/tls.c index 60898c6..96a73d2 100644 --- a/test/modules/misc/tls.c +++ b/test/modules/misc/tls.c @@ -121,7 +121,7 @@ static int securepair(vlc_thread_t *th, vlc_tls_t **restrict client, val = tlspair(insecurev); assert(val == 0); - server = vlc_tls_ServerSessionCreate(server_creds, insecurev[0], alpnv[0]); + server = vlc_tls_ServerSessionCreateFD(server_creds, insecurev[0], alpnv[0]); assert(server != NULL); val = vlc_clone(th, tls_echo, server, VLC_THREAD_PRIORITY_LOW); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
