Commit 7c6fe437 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

tls: fix/rationalize closing the session vs closing the socket

parent 3d204990
......@@ -47,7 +47,7 @@ struct vlc_tls
int (*shutdown)(struct vlc_tls *, bool duplex);
void (*close)(struct vlc_tls *);
void *p;
struct vlc_tls *p;
};
/**
......@@ -162,11 +162,14 @@ static inline int vlc_tls_Shutdown(vlc_tls_t *tls, bool duplex)
*/
static inline void vlc_tls_Close(vlc_tls_t *session)
{
int fd = vlc_tls_GetFD(session);
vlc_tls_SessionDelete(session);
shutdown(fd, SHUT_RDWR);
net_Close(fd);
do
{
vlc_tls_t *p = session->p;
vlc_tls_SessionDelete(session);
session = p;
}
while (session != NULL);
}
/** TLS credentials (certificate, private and trust settings) */
......@@ -263,7 +266,7 @@ 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))
vlc_tls_SessionDelete(sock);
free(sock);
else
tls->p = sock;
return tls;
......
......@@ -155,17 +155,10 @@ static vlc_tls_t *vlc_tls_SessionCreate(vlc_tls_creds_t *crd,
void vlc_tls_SessionDelete (vlc_tls_t *session)
{
do
{
int canc = vlc_savecancel();
session->close(session);
vlc_restorecancel(canc);
vlc_tls_t *sock = session->p;
free(session);
session = sock;
}
while (session != NULL);
int canc = vlc_savecancel();
session->close(session);
vlc_restorecancel(canc);
free(session);
}
static void cleanup_tls(void *data)
......@@ -186,6 +179,8 @@ 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;
......@@ -379,13 +374,9 @@ static int vlc_tls_SocketShutdown(vlc_tls_t *tls, bool duplex)
static void vlc_tls_SocketClose(vlc_tls_t *tls)
{
#if 0
int fd = (intptr_t)tls->sys;
net_Close(fd);
#else
(void) tls;
#endif
}
vlc_tls_t *vlc_tls_SocketOpen(vlc_object_t *obj, int fd)
......
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