[vlc-commits] tls: inline one function, revector
Rémi Denis-Courmont
git at videolan.org
Sat Mar 4 18:56:02 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 4 16:04:44 2017 +0200| [e877f5a67a9406b6cf6e42f134c41231fe3504b8] | committer: Rémi Denis-Courmont
tls: inline one function, revector
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e877f5a67a9406b6cf6e42f134c41231fe3504b8
---
include/vlc_tls.h | 9 ++++-----
src/network/tls.c | 46 ++++++++++++++++++++++------------------------
2 files changed, 26 insertions(+), 29 deletions(-)
diff --git a/include/vlc_tls.h b/include/vlc_tls.h
index 38c0280..eb554eb 100644
--- a/include/vlc_tls.h
+++ b/include/vlc_tls.h
@@ -288,12 +288,8 @@ struct addrinfo;
/**
* Creates a transport-layer stream from a struct addrinfo.
- *
- * \note The function currently iterates through the addrinfo linked list.
- * Future versions may implement different behaviour (e.g. RFC6555).
*/
-vlc_tls_t *vlc_tls_SocketOpenAddrInfo(vlc_object_t *obj,
- const struct addrinfo *);
+vlc_tls_t *vlc_tls_SocketOpenAddrInfo(const struct addrinfo *);
/**
* Creates a transport-layer TCP stream from a name and port.
@@ -301,6 +297,9 @@ vlc_tls_t *vlc_tls_SocketOpenAddrInfo(vlc_object_t *obj,
* This function resolves a hostname, and attempts to establish a TCP/IP
* connection to the specified host and port number.
*
+ * @note The function currently iterates through the addrinfo linked list.
+ * Future versions may implement different behaviour (e.g. RFC6555).
+ *
* @return a transport layer socket on success or NULL on error
*/
VLC_API vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj,
diff --git a/src/network/tls.c b/src/network/tls.c
index 29ea85b..21ca2fd 100644
--- a/src/network/tls.c
+++ b/src/network/tls.c
@@ -537,33 +537,18 @@ static ssize_t vlc_tls_ConnectWrite(vlc_tls_t *tls,
return vlc_tls_SocketWrite(tls, iov, count);
}
-static vlc_tls_t *vlc_tls_ConnectAddrInfo(const struct addrinfo *info)
+vlc_tls_t *vlc_tls_SocketOpenAddrInfo(const struct addrinfo *restrict info)
{
- vlc_tls_t *tls = vlc_tls_SocketAddrInfo(info);
- if (tls == NULL)
+ vlc_tls_t *sock = vlc_tls_SocketAddrInfo(info);
+ if (sock == NULL)
return NULL;
- if (vlc_tls_Connect(tls))
- {
- vlc_tls_SessionDelete(tls);
- tls = NULL;
- }
- return tls;
-}
-
-vlc_tls_t *vlc_tls_SocketOpenAddrInfo(vlc_object_t *obj,
- const struct addrinfo *restrict info)
-{
- /* TODO: implement RFC6555 */
- for (const struct addrinfo *p = info; p != NULL; p = p->ai_next)
+ if (vlc_tls_Connect(sock))
{
- vlc_tls_t *tls = vlc_tls_ConnectAddrInfo(p);
- if (tls != NULL)
- return tls;
-
- msg_Err(obj, "connection error: %s", vlc_strerror_c(errno));
+ vlc_tls_SessionDelete(sock);
+ sock = NULL;
}
- return NULL;
+ return sock;
}
vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj, const char *name,
@@ -588,9 +573,22 @@ vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj, const char *name,
msg_Dbg(obj, "connecting to %s port %u ...", name, port);
- vlc_tls_t *tls = vlc_tls_SocketOpenAddrInfo(obj, res);
+ /* TODO: implement RFC6555 */
+ for (const struct addrinfo *p = res; p != NULL; p = p->ai_next)
+ {
+ vlc_tls_t *tls = vlc_tls_SocketOpenAddrInfo(p);
+ if (tls == NULL)
+ {
+ msg_Err(obj, "connection error: %s", vlc_strerror_c(errno));
+ continue;
+ }
+
+ freeaddrinfo(res);
+ return tls;
+ }
+
freeaddrinfo(res);
- return tls;
+ return NULL;
}
vlc_tls_t *vlc_tls_SocketOpenTLS(vlc_tls_creds_t *creds, const char *name,
More information about the vlc-commits
mailing list