[vlc-commits] https: move TLS send function and remove dead non-TLS send function

Rémi Denis-Courmont git at videolan.org
Fri Dec 18 21:07:44 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Dec 18 19:05:07 2015 +0200| [b616c49e561267c1f8bad735b2e3177fb39e723e] | committer: Rémi Denis-Courmont

https: move TLS send function and remove dead non-TLS send function

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b616c49e561267c1f8bad735b2e3177fb39e723e
---

 modules/access/http/h2output.c  |   42 +++++++++++++++++++++++++++++
 modules/access/http/transport.c |   56 ---------------------------------------
 modules/access/http/transport.h |    9 -------
 3 files changed, 42 insertions(+), 65 deletions(-)

diff --git a/modules/access/http/h2output.c b/modules/access/http/h2output.c
index 26a0ff3..b5d3824 100644
--- a/modules/access/http/h2output.c
+++ b/modules/access/http/h2output.c
@@ -23,7 +23,11 @@
 #endif
 
 #include <assert.h>
+#include <errno.h>
 #include <stdlib.h>
+#ifdef HAVE_POLL
+# include <poll.h>
+#endif
 #include <vlc_common.h>
 #include <vlc_tls.h>
 #include "h2frame.h"
@@ -173,6 +177,44 @@ static void vlc_h2_output_flush_unlocked(struct vlc_h2_output *out)
 }
 
 /**
+ * Sends bytes to a connection.
+ * @note This may be a cancellation point.
+ * The caller is responsible for serializing writes on a given connection.
+ */
+static ssize_t vlc_https_send(vlc_tls_t *tls, const void *buf, size_t len)
+{
+    struct pollfd ufd;
+    size_t count = 0;
+
+    ufd.fd = tls->fd;
+    ufd.events = POLLOUT;
+
+    while (count < len)
+    {
+        int canc = vlc_savecancel();
+        ssize_t val = tls->send(tls, (char *)buf + count, len - count);
+
+        vlc_restorecancel(canc);
+
+        if (val > 0)
+        {
+            count += val;
+            continue;
+        }
+
+        if (val == 0)
+            break;
+
+        if (errno != EINTR && errno != EAGAIN)
+            return count ? (ssize_t)count : -1;
+
+        poll(&ufd, 1, -1);
+    }
+
+    return count;
+}
+
+/**
  * Sends one HTTP/2 frame through TLS.
  *
  * This function sends a whole HTTP/2 frame through a TLS session, then
diff --git a/modules/access/http/transport.c b/modules/access/http/transport.c
index c6bfeea..c02163a 100644
--- a/modules/access/http/transport.c
+++ b/modules/access/http/transport.c
@@ -92,62 +92,6 @@ ssize_t vlc_http_recv(int fd, void *buf, size_t len)
     return count;
 }
 
-ssize_t vlc_https_send(vlc_tls_t *tls, const void *buf, size_t len)
-{
-    struct pollfd ufd;
-    size_t count = 0;
-
-    ufd.fd = tls->fd;
-    ufd.events = POLLOUT;
-
-    while (count < len)
-    {
-        int canc = vlc_savecancel();
-        ssize_t val = tls->send(tls, (char *)buf + count, len - count);
-
-        vlc_restorecancel(canc);
-
-        if (val > 0)
-        {
-            count += val;
-            continue;
-        }
-
-        if (val == 0)
-            break;
-
-        if (errno != EINTR && errno != EAGAIN)
-            return -1;
-
-        poll(&ufd, 1, -1);
-    }
-
-    return count;
-}
-
-ssize_t vlc_http_send(int fd, const void *buf, size_t len)
-{
-    size_t count = 0;
-
-    while (count < len)
-    {
-        ssize_t val = send(fd, buf, len, MSG_NOSIGNAL);
-        if (val > 0)
-        {
-            count += val;
-            continue;
-        }
-
-        if (val == 0)
-            break;
-
-        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 9f57785..8b9d45a 100644
--- a/modules/access/http/transport.h
+++ b/modules/access/http/transport.h
@@ -38,15 +38,6 @@ ssize_t vlc_http_recv(int fd, void *buf, size_t len);
  */
 ssize_t vlc_https_recv(struct vlc_tls *tls, void *buf, size_t len);
 
-ssize_t vlc_http_send(int fd, const void *buf, size_t len);
-
-/**
- * Sends bytes to a connection.
- * @note This may be a cancellation point.
- * The caller is responsible for serializing writes on a given connection.
- */
-ssize_t vlc_https_send(struct vlc_tls *tls, const 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