gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (ad8a3e3f -> 7ef7bab3)


From: gnunet
Subject: [libmicrohttpd] branch master updated (ad8a3e3f -> 7ef7bab3)
Date: Sun, 29 Nov 2020 19:50:09 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from ad8a3e3f cosmetics
     new 7f6084e6 enum MHD_SendSocketOptions: renamed values for clarity. The 
most important is to push the last peace of response data. Without pushing 
data, MHD is limited to 5 requests/second (on typical OS) with stay-alive 
clients.
     new f06d0131 mhd_send: always call post_cork_setsockopt() after send()
     new c900f818 mhd_sockets: renamed macros for clarity
     new cf964cbd new_connection_prepare_(): fixed: CORK is never on by default
     new 7ef7bab3 mhd_send: improved setting of sk_cork_on

The 5 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  | 10 +++++-----
 src/microhttpd/daemon.c      |  7 ++++---
 src/microhttpd/mhd_send.c    | 18 ++++++++++--------
 src/microhttpd/mhd_send.h    | 13 +++++++++----
 src/microhttpd/mhd_sockets.c |  6 +++---
 src/microhttpd/mhd_sockets.h | 18 +++++++++---------
 6 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index b85597c4..be88d874 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2884,7 +2884,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                                    [connection->continue_message_write_offset],
                                    MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE)
                                    - connection->continue_message_write_offset,
-                                   MHD_SSO_NO_CORK);
+                                   MHD_SSO_PUSH_DATA);
     if (ret < 0)
     {
       if (MHD_ERR_AGAIN_ == ret)
@@ -2927,7 +2927,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                                        &connection->write_buffer
                                        [connection->write_buffer_send_offset],
                                        wb_ready,
-                                       MHD_SSO_MAY_CORK);
+                                       MHD_SSO_PREFER_BUFF);
       }
       else
       {
@@ -3004,7 +3004,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                                        [(size_t) data_write_offset],
                                        response->data_size
                                        - (size_t) data_write_offset,
-                                       MHD_SSO_NO_CORK);
+                                       MHD_SSO_PUSH_DATA);
 #if _MHD_DEBUG_SEND_DATA
         if (ret > 0)
           fprintf (stderr,
@@ -3048,7 +3048,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                                    [connection->write_buffer_send_offset],
                                    connection->write_buffer_append_offset
                                    - connection->write_buffer_send_offset,
-                                   MHD_SSO_NO_CORK);
+                                   MHD_SSO_PUSH_DATA);
     if (ret < 0)
     {
       if (MHD_ERR_AGAIN_ == ret)
@@ -3078,7 +3078,7 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                                    [connection->write_buffer_send_offset],
                                    connection->write_buffer_append_offset
                                    - connection->write_buffer_send_offset,
-                                   MHD_SSO_NO_CORK);
+                                   MHD_SSO_PUSH_DATA);
     if (ret < 0)
     {
       if (MHD_ERR_AGAIN_ == ret)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f75d02b1..d02f0258 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2458,7 +2458,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
     errno = eno;
     return MHD_NO;
   }
-  connection->sk_cork_on = true; /* default is usually ON */
+  connection->sk_cork_on = false;
 
   connection->connection_timeout = daemon->connection_timeout;
   if (NULL == (connection->addr = malloc (addrlen)))
@@ -3444,8 +3444,9 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
   s = accept4 (fd,
                addr,
                &addrlen,
-               MAYBE_SOCK_CLOEXEC | MAYBE_SOCK_NONBLOCK | 
MAYBE_SOCK_NOSIGPIPE);
-  sk_nonbl = (MAYBE_SOCK_NONBLOCK != 0);
+               SOCK_CLOEXEC_OR_ZERO | SOCK_NONBLOCK_OR_ZERO
+               | SOCK_NOSIGPIPE_OR_ZERO);
+  sk_nonbl = (SOCK_NONBLOCK_OR_ZERO != 0);
 #else  /* ! USE_ACCEPT4 */
   s = accept (fd,
               addr,
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 6e362252..441f7e7d 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -329,11 +329,11 @@ MHD_send_on_connection_ (struct MHD_Connection 
*connection,
   switch (options)
   {
   /* No corking */
-  case MHD_SSO_NO_CORK:
+  case MHD_SSO_PUSH_DATA:
     want_cork = false;
     break;
   /* Do corking, consider MSG_MORE instead if available. */
-  case MHD_SSO_MAY_CORK:
+  case MHD_SSO_PREFER_BUFF:
     want_cork = true;
     break;
   /* Cork the header. */
@@ -395,18 +395,19 @@ MHD_send_on_connection_ (struct MHD_Connection 
*connection,
 #endif /* HTTPS_SUPPORT  */
   {
     /* plaintext transmission */
+    bool new_cork_state;
+
     pre_cork_setsockopt (connection, want_cork);
 #if HAVE_MSG_MORE
     ret = send (s,
                 buffer,
                 buffer_size,
-                MAYBE_MSG_NOSIGNAL | (want_cork ? MSG_MORE : 0));
-    connection->sk_cork_on = want_cork; /* pretend corking happened as 
requested */
+                MSG_NOSIGNAL_OR_ZERO | (want_cork ? MSG_MORE : 0));
 #else
     ret = send (connection->socket_fd,
                 buffer,
                 buffer_size,
-                MAYBE_MSG_NOSIGNAL);
+                MSG_NOSIGNAL_OR_ZERO);
 #endif
 
     if (0 > ret)
@@ -432,8 +433,9 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
     else if (buffer_size > (size_t) ret)
       connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
 #endif /* EPOLL_SUPPORT */
-    if (buffer_size == (size_t) ret)
-      post_cork_setsockopt (connection, want_cork);
+    new_cork_state = want_cork ? (buffer_size == (size_t) ret) : false;
+    post_cork_setsockopt (connection, new_cork_state);
+    connection->sk_cork_on = new_cork_state;
   }
 
   return ret;
@@ -511,7 +513,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
     msg.msg_iov = vector;
     msg.msg_iovlen = 2;
 
-    ret = sendmsg (s, &msg, MAYBE_MSG_NOSIGNAL);
+    ret = sendmsg (s, &msg, MSG_NOSIGNAL_OR_ZERO);
     if ( (-1 == ret) &&
          (EAGAIN == errno) )
       return MHD_ERR_AGAIN_;
diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h
index 12ac1ac6..638dbade 100644
--- a/src/microhttpd/mhd_send.h
+++ b/src/microhttpd/mhd_send.h
@@ -54,13 +54,18 @@ MHD_send_init_static_vars_ (void);
 enum MHD_SendSocketOptions
 {
   /**
-   * definitely no corking (use NODELAY, or explicitly disable cork)
+   * Need to flush buffers after send to push data to the network.
+   * Used to avoid delay before the last part of data (which is usually
+   * incomplete IP packet / MSS) is pushed by kernel to the network.
    */
-  MHD_SSO_NO_CORK = 0,
+  MHD_SSO_PUSH_DATA = 0,
   /**
-   * should enable corking (use MSG_MORE, or explicitly enable cork)
+   * Buffer data if possible.
+   * If more response data is to be sent than try to buffer data in
+   * the local buffers so kernel able to send complete packets with
+   * lower overhead.
    */
-  MHD_SSO_MAY_CORK = 1,
+  MHD_SSO_PREFER_BUFF = 1,
   /**
    * consider tcpi_snd_mss and consider not corking for the header
    * part if the size of the header is close to the MSS.
diff --git a/src/microhttpd/mhd_sockets.c b/src/microhttpd/mhd_sockets.c
index 89bcb0ac..d5da49bd 100644
--- a/src/microhttpd/mhd_sockets.c
+++ b/src/microhttpd/mhd_sockets.c
@@ -585,11 +585,11 @@ MHD_socket_create_listen_ (int pf)
 #if defined(MHD_POSIX_SOCKETS) && (defined(SOCK_CLOEXEC) || \
   defined(SOCK_NOSIGPIPE) )
   fd = socket (pf,
-               SOCK_STREAM | SOCK_CLOEXEC | MAYBE_SOCK_NOSIGPIPE,
+               SOCK_STREAM | SOCK_CLOEXEC | SOCK_NOSIGPIPE_OR_ZERO,
                0);
-  cloexec_set = (MAYBE_SOCK_CLOEXEC != 0);
+  cloexec_set = (SOCK_CLOEXEC_OR_ZERO != 0);
 #if defined(SOCK_NOSIGPIPE) || defined(MHD_socket_nosignal_)
-  nosigpipe_set = (MAYBE_SOCK_NOSIGPIPE != 0);
+  nosigpipe_set = (SOCK_NOSIGPIPE_OR_ZERO != 0);
 #endif /* SOCK_NOSIGPIPE ||  MHD_socket_nosignal_ */
 #elif defined(MHD_WINSOCK_SOCKETS) && defined (WSA_FLAG_NO_HANDLE_INHERIT)
   fd = WSASocketW (pf,
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index 0241ef28..4dfc1ca3 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -157,27 +157,27 @@ typedef SOCKET MHD_socket;
 #endif /* ! MHD_SOCKET_DEFINED */
 
 #ifdef SOCK_CLOEXEC
-#  define MAYBE_SOCK_CLOEXEC SOCK_CLOEXEC
+#  define SOCK_CLOEXEC_OR_ZERO SOCK_CLOEXEC
 #else  /* ! SOCK_CLOEXEC */
-#  define MAYBE_SOCK_CLOEXEC 0
+#  define SOCK_CLOEXEC_OR_ZERO 0
 #endif /* ! SOCK_CLOEXEC */
 
 #ifdef HAVE_SOCK_NONBLOCK
-#  define MAYBE_SOCK_NONBLOCK SOCK_NONBLOCK
+#  define SOCK_NONBLOCK_OR_ZERO SOCK_NONBLOCK
 #else  /* ! HAVE_SOCK_NONBLOCK */
-#  define MAYBE_SOCK_NONBLOCK 0
+#  define SOCK_NONBLOCK_OR_ZERO 0
 #endif /* ! HAVE_SOCK_NONBLOCK */
 
 #ifdef SOCK_NOSIGPIPE
-#  define MAYBE_SOCK_NOSIGPIPE SOCK_NOSIGPIPE
+#  define SOCK_NOSIGPIPE_OR_ZERO SOCK_NOSIGPIPE
 #else  /* ! HAVE_SOCK_NONBLOCK */
-#  define MAYBE_SOCK_NOSIGPIPE 0
+#  define SOCK_NOSIGPIPE_OR_ZERO 0
 #endif /* ! HAVE_SOCK_NONBLOCK */
 
 #ifdef MSG_NOSIGNAL
-#  define MAYBE_MSG_NOSIGNAL MSG_NOSIGNAL
+#  define MSG_NOSIGNAL_OR_ZERO MSG_NOSIGNAL
 #else  /* ! MSG_NOSIGNAL */
-#  define MAYBE_MSG_NOSIGNAL 0
+#  define MSG_NOSIGNAL_OR_ZERO 0
 #endif /* ! MSG_NOSIGNAL */
 
 #if ! defined(SHUT_WR) && defined(SD_SEND)
@@ -284,7 +284,7 @@ typedef int MHD_SCKT_SEND_SIZE_;
  */
 #define MHD_send_(s,b,l) \
   ((ssize_t) send ((s),(const void*) (b),(MHD_SCKT_SEND_SIZE_) (l), \
-                   MAYBE_MSG_NOSIGNAL))
+                   MSG_NOSIGNAL_OR_ZERO))
 
 
 /**

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