gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (e127b8a6 -> f2f1d659


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (e127b8a6 -> f2f1d659)
Date: Sun, 01 Oct 2017 20:39:21 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from e127b8a6 Added detection for Linux form of sendfile(2)
     new 23c00cd8 configure: tuned Linux sendfile detection
     new 5cbdec21 mhd_limits.h: improved macros
     new f2f1d659 Improved 5ac497e212525a12209a3c1007a129ae85055cf7

The 3 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:
 configure.ac                |  5 +++--
 src/microhttpd/connection.c |  6 ++----
 src/microhttpd/mhd_limits.h | 25 ++++++++++++++++---------
 3 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index e4810e62..e4b6f48e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1248,12 +1248,13 @@ static void empty_func(void)
 ssize_t sendfile(int, int, off_t*, size_t);
     ]],
     [[
-      int fd1, fd2;
+      int fd1=0, fd2=2;
       off_t o = 0;
       size_t s = 5;
       ssize_t r;
       r = sendfile (fd1, fd2, &o, s);
-      empty_func();  
+      if (r)
+        empty_func();
     ]]
    )
   ],
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index a7ad7220..fbe9f9d3 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -239,6 +239,7 @@ sendfile_adapter (struct MHD_Connection *connection)
   off64_t offset;
 #endif /* HAVE_SENDFILE64 */
   const bool used_thr_p_c = (0 != (connection->daemon->options & 
MHD_USE_THREAD_PER_CONNECTION));
+  const size_t chunk_size = used_thr_p_c ? 0x200000 : 0x20000;
   size_t send_size;
   mhd_assert (MHD_resp_sender_sendfile == connection->resp_sender);
 
@@ -246,10 +247,7 @@ sendfile_adapter (struct MHD_Connection *connection)
   left = connection->response->total_size - 
connection->response_write_position;
   /* 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;
+  send_size = (left > chunk_size) ? chunk_size : (size_t) left;
 #ifndef HAVE_SENDFILE64
   if ((uint64_t)OFF_T_MAX < offsetu64)
     { /* Retry to send with standard 'send()'. */
diff --git a/src/microhttpd/mhd_limits.h b/src/microhttpd/mhd_limits.h
index f0f0d577..b0778112 100644
--- a/src/microhttpd/mhd_limits.h
+++ b/src/microhttpd/mhd_limits.h
@@ -32,11 +32,17 @@
 #include <limits.h>
 #endif /* HAVE_LIMITS_H */
 
+#define MHD_UNSIGNED_TYPE_MAX_(type) ((type)-1)
+/* Assume 8 bits per byte, no padding bits. */
+#define MHD_SIGNED_TYPE_MAX_(type) \
+        ( (type)((( ((type)1) << (sizeof(type)*8 - 2)) - 1)*2 + 1) )
+#define MHD_TYPE_IS_SIGNED_(type) (((type)0)>((type)-1))
+
 #ifndef UINT_MAX
 #ifdef __UINT_MAX__
 #define UINT_MAX __UINT_MAX__
 #else  /* ! __UINT_MAX__ */
-#define UINT_MAX ((unsigned int) ~((unsigned int)0))
+#define UINT_MAX MHD_UNSIGNED_TYPE_MAX_(unsigned int)
 #endif /* ! __UINT_MAX__ */
 #endif /* !UINT_MAX */
 
@@ -44,12 +50,12 @@
 #ifdef __LONG_MAX__
 #define LONG_MAX __LONG_MAX__
 #else  /* ! __LONG_MAX__ */
-#define LONG_MAX ((long) ~(((uint64_t) 1) << (8 * sizeof(long) - 1)))
+#define LONG_MAX MHD_SIGNED_TYPE_MAX(long)
 #endif /* ! __LONG_MAX__ */
 #endif /* !OFF_T_MAX */
 
 #ifndef ULLONG_MAX
-#define ULLONG_MAX ((MHD_UNSIGNED_LONG_LONG) ~((MHD_UNSIGNED_LONG_LONG)0))
+#define ULLONG_MAX MHD_UNSIGNED_TYPE_MAX_(MHD_UNSIGNED_LONG_LONG)
 #endif /* !ULLONG_MAX */
 
 #ifndef INT32_MAX
@@ -80,22 +86,23 @@
 #ifdef __SIZE_MAX__
 #define SIZE_MAX __SIZE_MAX__
 #else  /* ! __SIZE_MAX__ */
-#define SIZE_MAX ((size_t) ~((size_t)0))
+#define SIZE_MAX MHD_UNSIGNED_TYPE_MAX_(size_t)
 #endif /* ! __SIZE_MAX__ */ 
 #endif /* !SIZE_MAX */
 
 #ifndef OFF_T_MAX
-#define OFF_T_MAX ((off_t) ~(((uint64_t) 1) << (8 * sizeof(off_t) - 1)))
+#define OFF_T_MAX MHD_SIGNED_TYPE_MAX_(off_t)
 #endif /* !OFF_T_MAX */
 
 #if defined(_LARGEFILE64_SOURCE) && !defined(OFF64_T_MAX)
-#define OFF64_T_MAX ((off64_t) ~(((uint64_t) 1) << (8 * sizeof(off64_t) - 1)))
+#define OFF64_T_MAX MHD_SIGNED_TYPE_MAX_(uint64_t)
 #endif /* _LARGEFILE64_SOURCE && !OFF64_T_MAX */
 
 #ifndef TIME_T_MAX
-/* Assume that time_t is signed type. */
-/* Even if time_t is unsigned, TIME_T_MAX will be safe limit */
-#define TIME_T_MAX ( (time_t) ~(((uint64_t) 1) << (8 * sizeof(time_t) - 1)) )
+#define TIME_T_MAX ((time_t)              \
+       ( MHD_TYPE_IS_SIGNED_(time_t) ?    \
+           MHD_SIGNED_TYPE_MAX_(time_t) : \
+           MHD_UNSIGNED_TYPE_MAX_(time_t)))
 #endif /* !TIME_T_MAX */
 
 #ifndef TIMEVAL_TV_SEC_MAX

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



reply via email to

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