vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Tue Jan 12 23:22:24 2016 +0200| [51b1df72b340b4e085a16ee4987b5cdad8555745] | committer: Rémi Denis-Courmont
tls: rename dummy socket functions > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=51b1df72b340b4e085a16ee4987b5cdad8555745 --- include/vlc_tls.h | 10 ++++++---- modules/access/http/h1conn_test.c | 2 +- modules/access/http/h2conn_test.c | 2 +- modules/access/http/transport.c | 2 +- src/libvlccore.sym | 2 +- src/network/tls.c | 32 +++++++++++++++++++------------- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/include/vlc_tls.h b/include/vlc_tls.h index 0db689f..0739e17 100644 --- a/include/vlc_tls.h +++ b/include/vlc_tls.h @@ -194,14 +194,16 @@ static inline int vlc_tls_SessionHandshake (vlc_tls_creds_t *crd, VLC_API void vlc_tls_Delete (vlc_tls_creds_t *); /** - * Fakes a TLS session. + * Creates a transport-layer stream from a socket. * - * Creates a dummy TLS session structure from a socket file descriptor. Data - * will be sent and received directly through the socket. This can be used + * Creates a transport-layer I/O stream from a socket file descriptor. + * Data will be sent and received directly through the socket. This can be used * either to share common code between non-TLS and TLS cases, or for testing * purposes. + * + * This function is not a cancellation point. */ -VLC_API vlc_tls_t *vlc_tls_DummyCreate(vlc_object_t *obj, int fd); +VLC_API vlc_tls_t *vlc_tls_SocketOpen(vlc_object_t *obj, int fd); /** @} */ diff --git a/modules/access/http/h1conn_test.c b/modules/access/http/h1conn_test.c index 1fd6d56..62b64a3 100644 --- a/modules/access/http/h1conn_test.c +++ b/modules/access/http/h1conn_test.c @@ -47,7 +47,7 @@ static void conn_create(void) if (vlc_socketpair(PF_LOCAL, SOCK_STREAM, 0, fds, false)) assert(!"socketpair"); - struct vlc_tls *tls = vlc_tls_DummyCreate(NULL, fds[1]); + struct vlc_tls *tls = vlc_tls_SocketOpen(NULL, fds[1]); assert(tls != NULL); external_fd = fds[0]; diff --git a/modules/access/http/h2conn_test.c b/modules/access/http/h2conn_test.c index a531495..e1108be 100644 --- a/modules/access/http/h2conn_test.c +++ b/modules/access/http/h2conn_test.c @@ -93,7 +93,7 @@ static void conn_create(void) if (vlc_socketpair(PF_LOCAL, SOCK_STREAM, 0, fds, false)) assert(!"socketpair"); - struct vlc_tls *tls = vlc_tls_DummyCreate(NULL, fds[1]); + struct vlc_tls *tls = vlc_tls_SocketOpen(NULL, fds[1]); assert(tls != NULL); external_fd = fds[0]; diff --git a/modules/access/http/transport.c b/modules/access/http/transport.c index 8c3ec0d..a60c116 100644 --- a/modules/access/http/transport.c +++ b/modules/access/http/transport.c @@ -115,7 +115,7 @@ vlc_tls_t *vlc_http_connect(vlc_object_t *obj, const char *name, unsigned port) if (fd == -1) return NULL; - vlc_tls_t *tls = vlc_tls_DummyCreate(obj, fd); + vlc_tls_t *tls = vlc_tls_SocketOpen(obj, fd); if (tls == NULL) net_Close(fd); return tls; diff --git a/src/libvlccore.sym b/src/libvlccore.sym index 4881791..d3be85a 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -436,7 +436,7 @@ vlc_tls_SessionDelete vlc_tls_Read vlc_tls_Write vlc_tls_GetLine -vlc_tls_DummyCreate +vlc_tls_SocketOpen ToCharset update_Check update_Delete diff --git a/src/network/tls.c b/src/network/tls.c index 066176d..988c68f 100644 --- a/src/network/tls.c +++ b/src/network/tls.c @@ -317,13 +317,13 @@ error: return NULL; } -static int vlc_tls_DummyGetFD(vlc_tls_t *tls) +static int vlc_tls_SocketGetFD(vlc_tls_t *tls) { return (intptr_t)tls->sys; } -static ssize_t vlc_tls_DummyReceive(vlc_tls_t *tls, struct iovec *iov, - unsigned count) +static ssize_t vlc_tls_SocketRead(vlc_tls_t *tls, struct iovec *iov, + unsigned count) { int fd = (intptr_t)tls->sys; struct msghdr msg = @@ -334,8 +334,8 @@ static ssize_t vlc_tls_DummyReceive(vlc_tls_t *tls, struct iovec *iov, return recvmsg(fd, &msg, 0); } -static ssize_t vlc_tls_DummySend(vlc_tls_t *tls, const struct iovec *iov, - unsigned count) +static ssize_t vlc_tls_SocketWrite(vlc_tls_t *tls, const struct iovec *iov, + unsigned count) { int fd = (intptr_t)tls->sys; const struct msghdr msg = @@ -346,18 +346,24 @@ static ssize_t vlc_tls_DummySend(vlc_tls_t *tls, const struct iovec *iov, return sendmsg(fd, &msg, MSG_NOSIGNAL); } -static int vlc_tls_DummyShutdown(vlc_tls_t *tls, bool duplex) +static int vlc_tls_SocketShutdown(vlc_tls_t *tls, bool duplex) { int fd = (intptr_t)tls->sys; return shutdown(fd, duplex ? SHUT_RDWR : SHUT_WR); } -static void vlc_tls_DummyClose(vlc_tls_t *tls) +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_DummyCreate(vlc_object_t *obj, int fd) +vlc_tls_t *vlc_tls_SocketOpen(vlc_object_t *obj, int fd) { vlc_tls_t *session = malloc(sizeof (*session)); if (unlikely(session == NULL)) @@ -365,10 +371,10 @@ vlc_tls_t *vlc_tls_DummyCreate(vlc_object_t *obj, int fd) session->obj = obj; session->sys = (void *)(intptr_t)fd; - session->get_fd = vlc_tls_DummyGetFD; - session->readv = vlc_tls_DummyReceive; - session->writev = vlc_tls_DummySend; - session->shutdown = vlc_tls_DummyShutdown; - session->close = vlc_tls_DummyClose; + session->get_fd = vlc_tls_SocketGetFD; + session->readv = vlc_tls_SocketRead; + session->writev = vlc_tls_SocketWrite; + session->shutdown = vlc_tls_SocketShutdown; + session->close = vlc_tls_SocketClose; return session; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
