gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 01/06: mhd_send: use MSG_MORE only if it functions


From: gnunet
Subject: [libmicrohttpd] 01/06: mhd_send: use MSG_MORE only if it functions
Date: Tue, 01 Dec 2020 17:12:35 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 727be7d294a49e8ec9553d541dec17c3e40ca386
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Nov 29 22:06:59 2020 +0300

    mhd_send: use MSG_MORE only if it functions
---
 configure.ac                 | 15 ---------------
 src/microhttpd/daemon.c      |  2 +-
 src/microhttpd/mhd_send.c    |  6 +++---
 src/microhttpd/mhd_sockets.h |  8 ++++++++
 4 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index b874ee68..456650c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -843,21 +843,6 @@ AC_SEARCH_LIBS(sendmsg, socket, 
AC_DEFINE([HAVE_SENDMSG],1,[Define if your platf
 AC_MSG_CHECKING([whether writev is available])
 AC_CHECK_FUNCS([writev])
 
-# check MSG_MORE defined
-AC_MSG_CHECKING([whether MSG_MORE is defined])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <sys/types.h>
-#include <sys/socket.h>
-]],[[return MSG_MORE;]]
-    )],
-    [
-      AC_MSG_RESULT(yes)
-      AC_DEFINE(HAVE_MSG_MORE, [1], [have MSG_MORE])
-    ],
-    [
-      AC_MSG_RESULT(no)
-    ])
-
 # set GCC options
 # use '-fno-strict-aliasing', but only if the compiler
 # and linker can take it
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index d02f0258..62e981e6 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -3507,7 +3507,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
     }
     return MHD_NO;
   }
-#if defined(MHD_TCP_CORK_NOPUSH) || defined(HAVE_MSG_MORE)
+#if defined(MHD_TCP_CORK_NOPUSH) || defined(MHD_USE_MSG_MORE)
   /* We will use TCP_CORK or TCP_NOPUSH or MSG_MORE to control
      transmission, disable Nagle's algorithm (always) */
   if ( (0 != MHD_socket_set_nodelay_ (s,
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 441f7e7d..7826cbc3 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -115,7 +115,7 @@ static void
 pre_cork_setsockopt (struct MHD_Connection *connection,
                      bool want_cork)
 {
-#if HAVE_MSG_MORE
+#ifdef MHD_USE_MSG_MORE
   /* We use the MSG_MORE option for corking, no need for extra syscalls! */
 
   (void) connection; /* Mute compiler warning. */
@@ -204,7 +204,7 @@ static void
 post_cork_setsockopt (struct MHD_Connection *connection,
                       bool want_cork)
 {
-#if HAVE_MSG_MORE
+#ifdef MHD_USE_MSG_MORE
   /* We use the MSG_MORE option for corking, no need for extra syscalls! */
 
   (void) connection; /* Mute compiler warning. */
@@ -398,7 +398,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
     bool new_cork_state;
 
     pre_cork_setsockopt (connection, want_cork);
-#if HAVE_MSG_MORE
+#ifdef MHD_USE_MSG_MORE
     ret = send (s,
                 buffer,
                 buffer_size,
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index 4dfc1ca3..25286e5e 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -219,6 +219,14 @@ typedef SOCKET MHD_socket;
 #define MHD_TCP_CORK_NOPUSH TCP_NOPUSH
 #endif /* TCP_NOPUSH */
 
+#ifdef MSG_MORE
+#ifdef __linux__
+/* MSG_MORE signal kernel to buffer outbond data and works like
+ * TCP_CORK per call without actually setting TCP_CORK value.
+ * It's known to work on Linux. Add more OSes if they are compatible. */
+#define MHD_USE_MSG_MORE 1
+#endif /* __linux__ */
+#endif /* MSG_MORE */
 
 /**
  * MHD_SCKT_OPT_BOOL_ is type for bool parameters for setsockopt()/getsockopt()

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