gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 02/04: MHD_send: renamed function for clarity, moved dox


From: gnunet
Subject: [libmicrohttpd] 02/04: MHD_send: renamed function for clarity, moved doxy
Date: Sun, 13 Dec 2020 15:37:51 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit cd8294e59dc3d32062c8a3ddd6e5a203f746958d
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Dec 13 14:02:51 2020 +0300

    MHD_send: renamed function for clarity, moved doxy
    
    Renamed MHD_send_on_connection2_ to MHD_send_hdr_and_body_ to reflect
    function action. Doxy moved to the header and fixed.
---
 src/microhttpd/connection.c | 24 ++++++++++----------
 src/microhttpd/mhd_send.c   | 53 +++++++++++++++------------------------------
 src/microhttpd/mhd_send.h   | 22 ++++++++++++++-----
 3 files changed, 47 insertions(+), 52 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 72d7ba7e..0ffaffff 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2933,24 +2933,24 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
       {
         /* Send response headers alongside the response body, if the body
          * data is available. */
-        ret = MHD_send_on_connection2_ (connection,
-                                        &connection->write_buffer
-                                        [connection->write_buffer_send_offset],
-                                        wb_ready,
-                                        resp->data,
-                                        resp->data_size);
+        ret = MHD_send_hdr_and_body_ (connection,
+                                      &connection->write_buffer
+                                      [connection->write_buffer_send_offset],
+                                      wb_ready,
+                                      resp->data,
+                                      resp->data_size);
       }
       else
       {
         /* This is response for HEAD request, reply body is not allowed
          * for any other reason or reply body is dynamically generated. */
         /* Do not send the body data even if it's available. */
-        ret = MHD_send_on_connection2_ (connection,
-                                        &connection->write_buffer
-                                        [connection->write_buffer_send_offset],
-                                        wb_ready,
-                                        NULL,
-                                        0);
+        ret = MHD_send_hdr_and_body_ (connection,
+                                      &connection->write_buffer
+                                      [connection->write_buffer_send_offset],
+                                      wb_ready,
+                                      NULL,
+                                      0);
       }
 
       if (ret < 0)
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index f0cdfb58..e54a251c 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -807,29 +807,12 @@ MHD_send_on_connection_ (struct MHD_Connection 
*connection,
 }
 
 
-/**
- * Send header followed by buffer on connection.
- * Uses writev if possible to send both at once
- * and returns the sum of the number of bytes sent from
- * both buffers, or -1 on error;
- * if writev is unavailable, this call MUST only send from 'header'
- * (as we cannot handle the case that the first write
- * succeeds and the 2nd fails!).
- *
- * @param connection the MHD_Connection structure
- * @param header content of header to send
- * @param header_size the size of the header (in bytes)
- * @param buffer content of the buffer to send
- * @param buffer_size the size of the buffer (in bytes)
- * @return sum of the number of bytes sent from both buffers or
- *         -1 on error
- */
 ssize_t
-MHD_send_on_connection2_ (struct MHD_Connection *connection,
-                          const char *header,
-                          size_t header_size,
-                          const char *buffer,
-                          size_t buffer_size)
+MHD_send_hdr_and_body_ (struct MHD_Connection *connection,
+                        const char *header,
+                        size_t header_size,
+                        const char *body,
+                        size_t body_size)
 {
   ssize_t ret;
 #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
@@ -841,12 +824,12 @@ MHD_send_on_connection2_ (struct MHD_Connection 
*connection,
   const bool no_vec = false;
 #endif /* ! HTTPS_SUPPORT */
 #endif /* HAVE_SENDMSG || HAVE_WRITEV */
-  mhd_assert ( (NULL != buffer) || (0 == buffer_size) );
+  mhd_assert ( (NULL != body) || (0 == body_size) );
 
   if (
 #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
     (no_vec) ||
-    (0 == buffer_size) ||
+    (0 == body_size) ||
     ((size_t) SSIZE_MAX <= header_size)
 #else  /* ! (HAVE_SENDMSG || HAVE_WRITEV) */
     true
@@ -859,19 +842,19 @@ MHD_send_on_connection2_ (struct MHD_Connection 
*connection,
                                    MHD_SSO_HDR_CORK);
     if ( ((size_t) header_size == ret) &&
          (((size_t) SSIZE_MAX > header_size)) &&
-         (0 != buffer_size) )
+         (0 != body_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));
+      if ( (((size_t) SSIZE_MAX) - ((size_t) ret)) <  body_size)
+        body_size = (((size_t) SSIZE_MAX) - ((size_t) ret));
 
       ret2 = MHD_send_on_connection_ (connection,
-                                      buffer,
-                                      buffer_size,
+                                      body,
+                                      body_size,
                                       MHD_SSO_PUSH_DATA);
       if (0 < ret2)
         return ret + ret2; /* Total data sent */
@@ -884,9 +867,9 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
   }
 #if defined(HAVE_SENDMSG) || defined(HAVE_WRITEV)
 
-  if ( ((size_t) SSIZE_MAX <= buffer_size) ||
-       ((size_t) SSIZE_MAX < (header_size + buffer_size)) )
-    buffer_size = SSIZE_MAX - header_size;
+  if ( ((size_t) SSIZE_MAX <= body_size) ||
+       ((size_t) SSIZE_MAX < (header_size + body_size)) )
+    body_size = SSIZE_MAX - header_size;
 
   /* Since we generally give the fully answer, we do not want
      corking to happen */
@@ -900,8 +883,8 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
 
   vector[0].iov_base = (void *) header;
   vector[0].iov_len = header_size;
-  vector[1].iov_base = (void *) buffer;
-  vector[1].iov_len = buffer_size;
+  vector[1].iov_base = (void *) body;
+  vector[1].iov_len = body_size;
 
 #if HAVE_SENDMSG
   {
@@ -935,7 +918,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
    * it's unknown whether sendfile() will be used or not so
    * assume that next final send() will be the same, like for
    * this response. */
-  if ((header_size + buffer_size) == (size_t) ret)
+  if ((header_size + body_size) == (size_t) ret)
     post_send_setopt (connection,
 #if HAVE_SENDMSG
                       true,
diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h
index 046e7936..bc296588 100644
--- a/src/microhttpd/mhd_send.h
+++ b/src/microhttpd/mhd_send.h
@@ -86,12 +86,24 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
                          size_t buffer_size,
                          enum MHD_SendSocketOptions options);
 
+
+/**
+ * Send reply header with optional reply body.
+ *
+ * @param connection the MHD_Connection structure
+ * @param header content of header to send
+ * @param header_size the size of the header (in bytes)
+ * @param body content of the body to send (optional, may be NULL)
+ * @param body_size the size of the body (in bytes)
+ * @return sum of the number of bytes sent from both buffers or
+ *         error code (negative)
+ */
 ssize_t
-MHD_send_on_connection2_ (struct MHD_Connection *connection,
-                          const char *header,
-                          size_t header_size,
-                          const char *buffer,
-                          size_t buffer_size);
+MHD_send_hdr_and_body_ (struct MHD_Connection *connection,
+                        const char *header,
+                        size_t header_size,
+                        const char *body,
+                        size_t body_size);
 
 #if defined(_MHD_HAVE_SENDFILE)
 ssize_t

-- 
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]