gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] 23/154: mhd_send: change send_tls_adapter()


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 23/154: mhd_send: change send_tls_adapter() to non-static and export its prototype, use it in mhd_send.c
Date: Mon, 19 Aug 2019 10:15:35 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository libmicrohttpd.

commit 1f08febcc06a20ba2ce4412b8a3b04943965d7d3
Author: ng0 <address@hidden>
AuthorDate: Fri Jul 19 14:38:09 2019 +0000

    mhd_send: change send_tls_adapter() to non-static and export its
    prototype, use it in mhd_send.c
---
 src/microhttpd/connection_https.c |  2 +-
 src/microhttpd/connection_https.h | 14 +++++++
 src/microhttpd/mhd_send.c         | 85 +++++++++++++++++++--------------------
 src/microhttpd/mhd_send.h         |  1 -
 4 files changed, 57 insertions(+), 45 deletions(-)

diff --git a/src/microhttpd/connection_https.c 
b/src/microhttpd/connection_https.c
index 5efced33..8202329b 100644
--- a/src/microhttpd/connection_https.c
+++ b/src/microhttpd/connection_https.c
@@ -98,7 +98,7 @@ recv_tls_adapter (struct MHD_Connection *connection,
  * @return positive value for number of bytes actually sent or
  *         negative value for error number MHD_ERR_xxx_
  */
-static ssize_t
+ssize_t
 send_tls_adapter (struct MHD_Connection *connection,
                   const void *other,
                   size_t i)
diff --git a/src/microhttpd/connection_https.h 
b/src/microhttpd/connection_https.h
index 1c12ea9f..e91a84d3 100644
--- a/src/microhttpd/connection_https.h
+++ b/src/microhttpd/connection_https.h
@@ -60,6 +60,20 @@ MHD_run_tls_handshake_ (struct MHD_Connection *connection);
  */
 bool
 MHD_tls_connection_shutdown (struct MHD_Connection *connection);
+
+/**
+ * Callback for writing data to the socket.
+ *
+ * @param connection the MHD connection structure
+ * @param other data to write
+ * @param i number of bytes to write
+ * @return positive value for number of bytes actually sent or
+ *         negative value for error number MHD_ERR_xxx_
+ */
+ssize_t
+send_tls_adapter (struct MHD_Connection *connection,
+                  const void *other,
+                  size_t i);
 #endif /* HTTPS_SUPPORT */
 
 #endif
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 18996c00..36ee0c50 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -207,49 +207,6 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
   ret = send (connection->socket_fd, buffer, buffer_size, 0);
 #endif
 
-  /*
-  // pseudo-code for gnutls corking
-  if (have_more_data && !corked)
-    gnutls_record_cork(connection->tls_session);
-  if (!have_more_data && corked)
-    gnutls_record_uncork(connection->tls_session);
-  */
-
-  /* for TLS*/
-
-  if (0 != (connection->daemon->options & MHD_USE_TLS))
-    send_tls_adapter(connection, buffer, buffer_size);
-  else
-    ;
-
-  // shouldn't we return 0 or -1? Why re-use the _ERR_ functions?
-  // error handling from send_param_adapter():
-  if (0 > ret)
-  {
-    if (MHD_SCKT_ERR_IS_EAGAIN_ (err))
-    {
-#if EPOLL_SUPPORT
-      /* EAGAIN, no longer write-ready */
-      connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
-#endif /* EPOLL_SUPPORT */
-      return MHD_ERR_AGAIN_;
-    }
-    if (MHD_SCKT_ERR_IS_EINTR_ (err))
-      return MHD_ERR_AGAIN_;
-    if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_))
-      return MHD_ERR_CONNRESET_;
-    /* Treat any other error as hard error. */
-    return MHD_ERR_NOTCONN_;
-  }
-#if EPOLL_SUPPORT
-  else if (buffer_size > (size_t) ret)
-    connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
-#endif /* EPOLL_SUPPORT */
-    //  return ret; // should be return at the end of the function?
-
-    // previous error save:
-    // eno = errno;
-
 #if TCP_CORK
   if (use_corknopush)
   {
@@ -295,6 +252,48 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
     // ...
   }
 #endif
+
+  /*
+  // pseudo-code for gnutls corking
+  if (have_more_data && !corked)
+    gnutls_record_cork(connection->tls_session);
+  if (!have_more_data && corked)
+    gnutls_record_uncork(connection->tls_session);
+  */
+
+  /* for TLS*/
+
+  if (0 != (connection->daemon->options & MHD_USE_TLS))
+    send_tls_adapter(connection, buffer, buffer_size);
+  else {
+
+    // shouldn't we return 0 or -1? Why re-use the _ERR_ functions?
+    // error handling from send_param_adapter():
+    if (0 > ret)
+      {
+        if (MHD_SCKT_ERR_IS_EAGAIN_ (err))
+          {
+#if EPOLL_SUPPORT
+            /* EAGAIN, no longer write-ready */
+            connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
+#endif /* EPOLL_SUPPORT */
+            return MHD_ERR_AGAIN_;
+          }
+        if (MHD_SCKT_ERR_IS_EINTR_ (err))
+          return MHD_ERR_AGAIN_;
+        if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_))
+          return MHD_ERR_CONNRESET_;
+        /* Treat any other error as hard error. */
+        return MHD_ERR_NOTCONN_;
+      }
+#if EPOLL_SUPPORT
+    else if (buffer_size > (size_t) ret)
+      connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
+#endif /* EPOLL_SUPPORT */
+    // return ret; // should be return at the end of the function?
+    // previous error save:
+    // eno = errno;
+  }
   errno = eno;
   return ret;
 }
diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h
index 7bd79a16..9d2065f0 100644
--- a/src/microhttpd/mhd_send.h
+++ b/src/microhttpd/mhd_send.h
@@ -67,5 +67,4 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
                           size_t header_size,
                           const char *buffer,
                           size_t buffer_size);
-
 #endif /* MHD_SEND_H */

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]