Commit 899f8111 authored by Rémi Denis-Courmont's avatar 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.
parent 33a1df5a
......@@ -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;
}
......
......@@ -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;
......
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment