gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (4ce620be -> 5f9f3f06)


From: gnunet
Subject: [libmicrohttpd] branch master updated (4ce620be -> 5f9f3f06)
Date: Sat, 12 Dec 2020 13:05:50 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 4ce620be MHD_send_on_connection2_(): handle oversized
     new 0ee242e3 mhd_send: emulate sendmsg when sendmsg unsupported
     new 5f9f3f06 fixed: really use sendmsg() for header and body

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/microhttpd/connection.c |  2 +-
 src/microhttpd/mhd_send.c   | 38 +++++++++++++++++++++++++++++++-------
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 27b1cbdc..20e31998 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2934,7 +2934,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                                         [connection->write_buffer_send_offset],
                                         wb_ready,
                                         connection->response->data,
-                                        
connection->response->data_buffer_size);
+                                        connection->response->data_size);
       }
 
       if (ret < 0)
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 85c6df93..2bf9a071 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -831,9 +831,9 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
                           const char *buffer,
                           size_t buffer_size)
 {
+  ssize_t ret;
 #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
   MHD_socket s = connection->socket_fd;
-  ssize_t ret;
   struct iovec vector[2];
 #ifdef HTTPS_SUPPORT
   const bool no_vec = (connection->daemon->options & MHD_USE_TLS);
@@ -852,11 +852,34 @@ MHD_send_on_connection2_ (struct MHD_Connection 
*connection,
 #endif /* ! (HAVE_SENDMSG || HAVE_WRITEV) */
     )
   {
-    return MHD_send_on_connection_ (connection,
-                                    header,
-                                    header_size,
-                                    MHD_SSO_HDR_CORK);
-
+    ret = MHD_send_on_connection_ (connection,
+                                   header,
+                                   header_size,
+                                   MHD_SSO_HDR_CORK);
+    if ( ((size_t) header_size == ret) &&
+         (((size_t) SSIZE_MAX > header_size)) &&
+         (0 != buffer_size) )
+    {
+      int ret2;
+      /* The header has been sent completely.
+       * Try to send the reply body without waiting for
+       * the next round. */
+      /* Make sure that sum of ret + ret2 will not exceed SSIZE_MAX. */
+      if ( (((size_t) SSIZE_MAX) - ((size_t) ret)) <  buffer_size)
+        buffer_size = (((size_t) SSIZE_MAX) - ((size_t) ret));
+
+      ret2 = MHD_send_on_connection_ (connection,
+                                      buffer,
+                                      buffer_size,
+                                      MHD_SSO_PUSH_DATA);
+      if (0 < ret2)
+        return ret + ret2; /* Total data sent */
+      if (MHD_ERR_AGAIN_ == ret2)
+        return ret;
+
+      return ret2; /* Error code */
+    }
+    return ret;
   }
 #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
 
@@ -922,7 +945,8 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
 
   return ret;
 #else  /* ! (HAVE_SENDMSG || HAVE_WRITEV) */
-  return 0; /* Unreachable. Mute warnings. */
+  mhd_assert (false);
+  return MHD_ERR_CONNRESET_; /* Unreachable. Mute warnings. */
 #endif /* ! (HAVE_SENDMSG || HAVE_WRITEV) */
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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