[vlc-commits] https: move TLS receive function and remove non-TLS one
Rémi Denis-Courmont
git at videolan.org
Fri Dec 18 21:07:45 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Dec 18 19:05:07 2015 +0200| [9a1082338a8d6e5af20e7087bc5a8a8613271a50] | committer: Rémi Denis-Courmont
https: move TLS receive function and remove non-TLS one
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9a1082338a8d6e5af20e7087bc5a8a8613271a50
---
modules/access/http/h2conn.c | 44 ++++++++++++++++++++++++++++++
modules/access/http/transport.c | 56 ---------------------------------------
modules/access/http/transport.h | 11 --------
3 files changed, 44 insertions(+), 67 deletions(-)
diff --git a/modules/access/http/h2conn.c b/modules/access/http/h2conn.c
index 42f9770..0199b51 100644
--- a/modules/access/http/h2conn.c
+++ b/modules/access/http/h2conn.c
@@ -23,8 +23,12 @@
#endif
#include <assert.h>
+#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
+#ifdef HAVE_POLL
+# include <poll.h>
+#endif
#include <vlc_common.h>
#include <vlc_block.h>
#include <vlc_interrupt.h>
@@ -505,6 +509,46 @@ static const struct vlc_h2_parser_cbs vlc_h2_conn_callbacks =
};
/**
+ * Receives TLS data.
+ *
+ * Receives bytes from the peer through a TLS session.
+ * @note This may be a cancellation point.
+ * The caller is responsible for serializing reads on a given connection.
+ */
+static ssize_t vlc_https_recv(vlc_tls_t *tls, void *buf, size_t len)
+{
+ struct pollfd ufd;
+ size_t count = 0;
+
+ ufd.fd = tls->fd;
+ ufd.events = POLLIN;
+
+ while (count < len)
+ {
+ int canc = vlc_savecancel();
+ ssize_t val = tls->recv(tls, (char *)buf + count, len - count);
+
+ vlc_restorecancel(canc);
+
+ if (val == 0)
+ break;
+
+ if (val >= 0)
+ {
+ count += val;
+ continue;
+ }
+
+ if (errno != EINTR && errno != EAGAIN)
+ return count ? (ssize_t)count : -1;
+
+ poll(&ufd, 1, -1);
+ }
+
+ return count;
+}
+
+/**
* Receives an HTTP/2 frame through TLS.
*
* This function allocates memory for and receives a whole HTTP/2 frame from a
diff --git a/modules/access/http/transport.c b/modules/access/http/transport.c
index c02163a..32ca53b 100644
--- a/modules/access/http/transport.c
+++ b/modules/access/http/transport.c
@@ -36,62 +36,6 @@
#include "transport.h"
-ssize_t vlc_https_recv(vlc_tls_t *tls, void *buf, size_t len)
-{
- struct pollfd ufd;
- size_t count = 0;
-
- ufd.fd = tls->fd;
- ufd.events = POLLIN;
-
- while (count < len)
- {
- int canc = vlc_savecancel();
- ssize_t val = tls->recv(tls, (char *)buf + count, len - count);
-
- vlc_restorecancel(canc);
-
- if (val == 0)
- break;
-
- if (val >= 0)
- {
- count += val;
- continue;
- }
-
- if (errno != EINTR && errno != EAGAIN)
- return -1;
-
- poll(&ufd, 1, -1);
- }
-
- return count;
-}
-
-ssize_t vlc_http_recv(int fd, void *buf, size_t len)
-{
- unsigned count = 0;
-
- while (count < len)
- {
- ssize_t val = recv(fd, (char *)buf + count, len - count, MSG_WAITALL);
- if (val == 0)
- break;
-
- if (val >= 0)
- {
- count += val;
- continue;
- }
-
- if (errno != EINTR)
- return -1;
- }
-
- return count;
-}
-
static void cleanup_addrinfo(void *data)
{
freeaddrinfo(data);
diff --git a/modules/access/http/transport.h b/modules/access/http/transport.h
index 8b9d45a..9c32d91 100644
--- a/modules/access/http/transport.h
+++ b/modules/access/http/transport.h
@@ -27,17 +27,6 @@
struct vlc_tls;
struct vlc_tls_creds;
-ssize_t vlc_http_recv(int fd, void *buf, size_t len);
-
-/**
- * Receives TLS data.
- *
- * Receives bytes from the peer through a TLS session.
- * @note This may be a cancellation point.
- * The caller is responsible for serializing reads on a given connection.
- */
-ssize_t vlc_https_recv(struct vlc_tls *tls, void *buf, size_t len);
-
struct vlc_tls *vlc_https_connect(struct vlc_tls_creds *creds,
const char *name, unsigned port,
bool *restrict two);
More information about the vlc-commits
mailing list