gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (386f371d -> 02ff959e


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (386f371d -> 02ff959e)
Date: Sun, 01 Oct 2017 16:02:53 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 386f371d test_start_stop: silent compiler warnings
     new db6a1ba7 mhd_options.h: better detect compiler optimization option
     new 6c49371c sendfile_adapter(): fixed wrong type of return variable
     new 5ac497e2 Sending with sendfile: use chunks so MHD will be able to 
process other connections too.
     new 02ff959e sendfile_adapter(): fixed indentation

The 4 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/include/mhd_options.h   |  4 ++--
 src/microhttpd/connection.c | 34 ++++++++++++++++++++--------------
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/include/mhd_options.h b/src/include/mhd_options.h
index 8d9cedd2..36a5f575 100644
--- a/src/include/mhd_options.h
+++ b/src/include/mhd_options.h
@@ -109,9 +109,9 @@
 #if !defined(MHD_FAVOR_FAST_CODE) && !defined(MHD_FAVOR_SMALL_CODE)
 /* Try to detect user preferences */
 /* Defined by GCC and many compatible compilers */
-#ifdef __OPTIMIZE_SIZE__
+#if defined(__OPTIMIZE_SIZE__)
 #define MHD_FAVOR_SMALL_CODE 1
-#elif __OPTIMIZE__
+#elif defined(__OPTIMIZE__)
 #define MHD_FAVOR_FAST_CODE 1
 #endif /* __OPTIMIZE__ */
 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index b30c6d1b..3f62144a 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -229,7 +229,7 @@ send_param_adapter (struct MHD_Connection *connection,
 static ssize_t
 sendfile_adapter (struct MHD_Connection *connection)
 {
-  int ret;
+  ssize_t ret;
   const int file_fd = connection->response->fd;
   uint64_t left;
   uint64_t offsetu64;
@@ -238,34 +238,40 @@ sendfile_adapter (struct MHD_Connection *connection)
 #else  /* HAVE_SENDFILE64 */
   off64_t offset;
 #endif /* HAVE_SENDFILE64 */
+  const bool used_thr_p_c = (0 != (daemon->options & 
MHD_USE_THREAD_PER_CONNECTION));
+  size_t send_size;
   mhd_assert (MHD_resp_sender_sendfile == connection->resp_sender);
 
   offsetu64 = connection->response_write_position + 
connection->response->fd_off;
   left = connection->response->total_size - 
connection->response_write_position;
-  if (left > SSIZE_MAX)
-    left = SSIZE_MAX;
+  /* Do not allow system to stick sending on single fast connection:
+   * use 128KiB chunks (2MiB for thread-per-connection). */
+  if (!used_thr_p_c)
+    send_size = (left > 0x20000) ? 0x20000 : (size_t) left;
+  else
+    send_size = (left > 0x200000) ? 0x200000 : (size_t) left;
 #ifndef HAVE_SENDFILE64
   if ((uint64_t)OFF_T_MAX < offsetu64)
     { /* Retry to send with standard 'send()'. */
       connection->resp_sender = MHD_resp_sender_std;
       return MHD_ERR_AGAIN_;
     }
-    offset = (off_t) offsetu64;
-    ret = sendfile (connection->socket_fd,
-                    file_fd,
-                    &offset,
-                    left);
+  offset = (off_t) offsetu64;
+  ret = sendfile (connection->socket_fd,
+                  file_fd,
+                  &offset,
+                  send_size);
 #else  /* HAVE_SENDFILE64 */
   if ((uint64_t)OFF64_T_MAX < offsetu64)
     { /* Retry to send with standard 'send()'. */
       connection->resp_sender = MHD_resp_sender_std;
       return MHD_ERR_AGAIN_;
     }
-    offset = (off64_t) offsetu64;
-    ret = sendfile64 (connection->socket_fd,
-                      file_fd,
-                      &offset,
-                      left);
+  offset = (off64_t) offsetu64;
+  ret = sendfile64 (connection->socket_fd,
+                    file_fd,
+                    &offset,
+                    send_size);
 #endif /* HAVE_SENDFILE64 */
   if (0 > ret)
     {
@@ -292,7 +298,7 @@ sendfile_adapter (struct MHD_Connection *connection)
       return MHD_ERR_AGAIN_;
     }
 #ifdef EPOLL_SUPPORT
-  else if (left > (uint64_t)ret)
+  else if (send_size > (size_t)ret)
         connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
 #endif /* EPOLL_SUPPORT */
   return ret;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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