瀏覽代碼

mhd_send: use MSG_MORE only if it functions

Evgeny Grin (Karlson2k) 5 年之前
父節點
當前提交
727be7d294
共有 4 個文件被更改,包括 12 次插入19 次删除
  1. 0 15
      configure.ac
  2. 1 1
      src/microhttpd/daemon.c
  3. 3 3
      src/microhttpd/mhd_send.c
  4. 8 0
      src/microhttpd/mhd_sockets.h

+ 0 - 15
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

+ 1 - 1
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,

+ 3 - 3
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,

+ 8 - 0
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()