gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (23324164 -> aca29a77


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (23324164 -> aca29a77)
Date: Wed, 22 Nov 2017 12:46:34 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 23324164 https tests: supported multi-TLS selection on libcurl >= 
7.56.0, fixed error report for failed initialisation of libcurl
     new 11e15b46 mhd_threads: Fixed thread ID data races on pthreads
     new d30195fc configure: fixed additional checks for GnuTLS
     new 79245407 mhd_limits: improved detection of OFF_T_MAX, SIZE_MAX, added 
macros for SSIZE_MAX, INT64_MAX
     new e28049cc Added support for Darwin-style sendfile()
     new aca29a77 Updated .gitignore files

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:
 .gitignore                   | 12 +--------
 configure.ac                 | 44 +++++++++++++++++++++++++++++--
 src/examples/.gitignore      |  1 +
 src/include/mhd_options.h    |  6 +++++
 src/microhttpd/.gitignore    | 10 +++++++
 src/microhttpd/connection.c  | 62 ++++++++++++++++++++++++++++++++++++--------
 src/microhttpd/internal.h    |  4 +--
 src/microhttpd/mhd_limits.h  | 34 ++++++++++++++++++++++--
 src/microhttpd/mhd_threads.h | 32 ++++++++++++++++++++---
 src/testcurl/.gitignore      |  1 +
 10 files changed, 174 insertions(+), 32 deletions(-)

diff --git a/.gitignore b/.gitignore
index 29c6987a..5f565b93 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,15 +42,5 @@ Makefile
 po/configure.acT
 po/Makevars.template
 po/POTFILES
+po/configargs.stamp
 src/examples/timeout
-src/microhttpd/test_daemon.trs
-src/microhttpd/test_shutdown_poll
-src/microhttpd/test_shutdown_select
-src/microhttpd/test_str_compare
-src/microhttpd/test_str_to_value
-src/microhttpd/test_upgrade
-src/microhttpd/test_upgrade_ssl
-src/testcurl/test_delete
-src/microhttpd/test_options
-src/microhttpd/test_start_stop
-src/microhttpd/test_str_token
diff --git a/configure.ac b/configure.ac
index 143ad648..625b74ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1311,6 +1311,46 @@ int sendfile(int, int, off_t, size_t,
    )
   ]
 )
+AS_VAR_IF([[found_sendfile]], [["no"]],
+  [
+   AC_MSG_CHECKING([[for Darwin-style sendfile(2)]])
+   AC_LINK_IFELSE(
+     [AC_LANG_PROGRAM(
+       [[
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+
+static void empty_func(void)
+{
+/* Check for declaration */
+  (void)sendfile;
+}
+/* Declare again to check form match */
+int sendfile(int, int, off_t, off_t*,
+             struct sf_hdtr *, int);
+       ]],
+       [[
+         int fd=0, s=1;
+         off_t o = 0;
+         off_t l = 5;
+         int r;
+         r = sendfile (fd, s, o, &l, (void*)0, 0);
+         if (r)
+           empty_func();
+       ]]
+      )
+     ],
+     [
+       AC_DEFINE([HAVE_DARWIN_SENDFILE], [1], [Define to 1 if you have 
Darwin-style sendfile(2).])
+       found_sendfile="yes, Darwin-style"
+       AC_MSG_RESULT([[yes]])
+     ],
+     [AC_MSG_RESULT([[no]])
+     ]
+   )
+  ]
+)
 
 AS_VAR_IF([[found_sendfile]], [["no"]],
   [
@@ -1570,7 +1610,8 @@ AS_IF([test "x$with_gnutls" != "xno" && test 
"x$have_gnutls" != "xyes"],
        # A bit of hack: unset cache variable to force recheck
        AS_UNSET([ac_cv_header_gnutls_gnutls_h])
        AC_CHECK_HEADERS([gnutls/gnutls.h],
-        [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
+        [AS_UNSET([ac_cv_lib_gnutls_gnutls_priority_set]) # A bit of hack: 
unset cache variable to force recheck
+         AC_CHECK_LIB([gnutls], [gnutls_priority_set],
           [
             GNUTLS_CPPFLAGS="$LIBGCRYPT_CFLAGS"
             GNUTLS_CFLAGS="$LIBGCRYPT_CFLAGS"
@@ -1654,7 +1695,6 @@ choke me now
          # LIBGCRYPT_CFLAGS can be actually a CPPFLAGS, so check them both
          CPPFLAGS="$CPPFLAGS $LIBGCRYPT_CFLAGS"
          AC_CHECK_HEADERS([gcrypt.h], [], [have_gcrypt=no], 
[AC_INCLUDES_DEFAULT])
-         # Check for GnuTLS with gcrypt flags
          CPPFLAGS="$SAVE_CPPFLAGS"
          CFLAGS="$SAVE_CFLAGS"
        ]
diff --git a/src/examples/.gitignore b/src/examples/.gitignore
index eaa6336a..e5e696d0 100644
--- a/src/examples/.gitignore
+++ b/src/examples/.gitignore
@@ -32,3 +32,4 @@
 /https_echo_client_example.c
 /authorization_example
 upgrade_example
+/timeout
\ No newline at end of file
diff --git a/src/include/mhd_options.h b/src/include/mhd_options.h
index d009630e..25b5cd52 100644
--- a/src/include/mhd_options.h
+++ b/src/include/mhd_options.h
@@ -65,6 +65,12 @@
 #define _MHD_FD_SETSIZE_IS_DEFAULT 1
 #endif /* !FD_SETSIZE && !WinSock*/
 
+#if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE) || \
+    defined(HAVE_DARWIN_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE)
+/* Have any supported sendfile() function. */
+#define _MHD_HAVE_SENDFILE
+#endif /* HAVE_LINUX_SENDFILE || HAVE_FREEBSD_SENDFILE ||
+          HAVE_DARWIN_SENDFILE || HAVE_SOLARIS_SENDFILE */
 #if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE)
 #define MHD_LINUX_SOLARIS_SENDFILE 1
 #endif /* HAVE_LINUX_SENDFILE || HAVE_SOLARIS_SENDFILE */
diff --git a/src/microhttpd/.gitignore b/src/microhttpd/.gitignore
index cf17abd7..bc340b7e 100644
--- a/src/microhttpd/.gitignore
+++ b/src/microhttpd/.gitignore
@@ -43,3 +43,13 @@
 *.exe
 test_upgrade_tls
 test_http_reasons
+/test_daemon.trs
+/test_shutdown_poll_ignore
+/test_shutdown_select_ignore
+/test_str_compare
+/test_str_to_value
+/test_upgrade
+/test_upgrade_ssl
+/test_options
+/test_start_stop
+/test_str_token
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 623b40a5..ef61fdb6 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -39,11 +39,11 @@
 #ifdef MHD_LINUX_SOLARIS_SENDFILE
 #include <sys/sendfile.h>
 #endif /* MHD_LINUX_SOLARIS_SENDFILE */
-#ifdef HAVE_FREEBSD_SENDFILE
+#if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_DARWIN_SENDFILE)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
-#endif /* HAVE_FREEBSD_SENDFILE */
+#endif /* HAVE_FREEBSD_SENDFILE || HAVE_DARWIN_SENDFILE */
 #ifdef HTTPS_SUPPORT
 #include "connection_https.h"
 #endif /* HTTPS_SUPPORT */
@@ -272,7 +272,7 @@ send_param_adapter (struct MHD_Connection *connection,
 }
 
 
-#if defined(MHD_LINUX_SOLARIS_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE)
+#if defined(_MHD_HAVE_SENDFILE)
 /**
  * Function for sending responses backed by file FD.
  *
@@ -302,6 +302,9 @@ sendfile_adapter (struct MHD_Connection *connection)
   off_t sent_bytes;
   int flags = 0;
 #endif
+#ifdef HAVE_DARWIN_SENDFILE
+  off_t len;
+#endif /* HAVE_DARWIN_SENDFILE */
   const bool used_thr_p_c = (0 != (connection->daemon->options & 
MHD_USE_THREAD_PER_CONNECTION));
   const size_t chunk_size = used_thr_p_c ? MHD_SENFILE_CHUNK_THR_P_C_ : 
MHD_SENFILE_CHUNK_;
   size_t send_size = 0;
@@ -407,10 +410,47 @@ sendfile_adapter (struct MHD_Connection *connection)
   mhd_assert (0 < sent_bytes);
   mhd_assert (SSIZE_MAX >= sent_bytes);
   ret = (ssize_t)sent_bytes;
+#elif defined(HAVE_DARWIN_SENDFILE)
+  len = (off_t)send_size; /* chunk always fit */
+  if (0 != sendfile (file_fd,
+                     connection->socket_fd,
+                     (off_t) offsetu64,
+                     &len,
+                     NULL,
+                     0))
+    {
+      const int err = MHD_socket_get_error_();
+      if (MHD_SCKT_ERR_IS_EAGAIN_(err) ||
+          MHD_SCKT_ERR_IS_EINTR_(err))
+        {
+          mhd_assert (0 <= len);
+          mhd_assert (SSIZE_MAX >= len);
+          mhd_assert (send_size >= (size_t)len);
+          if (0 != len)
+            return (ssize_t)len;
+
+          return MHD_ERR_AGAIN_;
+        }
+      if (ENOTCONN == err ||
+          EPIPE == err)
+        return MHD_ERR_CONNRESET_;
+      if (ENOTSUP == err ||
+          EOPNOTSUPP == err)
+        { /* This file FD is not suitable for sendfile().
+           * Retry with standard send(). */
+          connection->resp_sender = MHD_resp_sender_std;
+          return MHD_ERR_AGAIN_;
+        }
+      return MHD_ERR_BADF_; /* Return hard error. */
+    }
+  mhd_assert (0 <= len);
+  mhd_assert (SSIZE_MAX >= len);
+  mhd_assert (send_size >= (size_t)len);
+  ret = (ssize_t)len;
 #endif /* HAVE_FREEBSD_SENDFILE */
   return ret;
 }
-#endif /* MHD_LINUX_SOLARIS_SENDFILE || HAVE_FREEBSD_SENDFILE */
+#endif /* _MHD_HAVE_SENDFILE */
 
 
 /**
@@ -1042,13 +1082,13 @@ try_ready_normal_body (struct MHD_Connection 
*connection)
        (response->data_size + response->data_start >
        connection->response_write_position) )
     return MHD_YES; /* response already ready */
-#if defined(MHD_LINUX_SOLARIS_SENDFILE) || defined (HAVE_FREEBSD_SENDFILE)
+#if defined(_MHD_HAVE_SENDFILE)
   if (MHD_resp_sender_sendfile == connection->resp_sender)
     {
       /* will use sendfile, no need to bother response crc */
       return MHD_YES;
     }
-#endif /* MHD_LINUX_SOLARIS_SENDFILE || HAVE_FREEBSD_SENDFILE */
+#endif /* _MHD_HAVE_SENDFILE */
 
   ret = response->crc (response->crc_cls,
                        connection->response_write_position,
@@ -2986,15 +3026,15 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
               /* mutex was already unlocked by try_ready_normal_body */
               return;
             }
-#if defined(MHD_LINUX_SOLARIS_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE)
+#if defined(_MHD_HAVE_SENDFILE)
           if (MHD_resp_sender_sendfile == connection->resp_sender)
             {
               ret = sendfile_adapter (connection);
             }
           else
-#else  /* ! (MHD_LINUX_SOLARIS_SENDFILE || HAVE_FREEBSD_SENDFILE) */
+#else  /* ! _MHD_HAVE_SENDFILE */
           if (1)
-#endif /* ! (MHD_LINUX_SOLARIS_SENDFILE || HAVE_FREEBSD_SENDFILE) */
+#endif /* ! _MHD_HAVE_SENDFILE */
             {
               data_write_offset = connection->response_write_position
                                   - response->data_start;
@@ -3934,13 +3974,13 @@ MHD_queue_response (struct MHD_Connection *connection,
   MHD_increment_response_rc (response);
   connection->response = response;
   connection->responseCode = status_code;
-#if defined(MHD_LINUX_SOLARIS_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE)
+#if defined(_MHD_HAVE_SENDFILE)
   if ( (response->fd == -1) ||
        (0 != (connection->daemon->options & MHD_USE_TLS)) )
     connection->resp_sender = MHD_resp_sender_std;
   else
     connection->resp_sender = MHD_resp_sender_sendfile;
-#endif /* MHD_LINUX_SOLARIS_SENDFILE || HAVE_FREEBSD_SENDFILE */
+#endif /* _MHD_HAVE_SENDFILE */
 
   if ( ( (NULL != connection->method) &&
          (MHD_str_equal_caseless_ (connection->method,
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 0c986196..70566ea1 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -806,13 +806,13 @@ struct MHD_Connection
    */
   uint64_t response_write_position;
 
-#if defined(MHD_LINUX_SOLARIS_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE)
+#if defined(_MHD_HAVE_SENDFILE)
   enum MHD_resp_sender_
   {
     MHD_resp_sender_std = 0,
     MHD_resp_sender_sendfile
   } resp_sender;
-#endif /* MHD_LINUX_SOLARIS_SENDFILE || HAVE_FREEBSD_SENDFILE */
+#endif /* _MHD_HAVE_SENDFILE */
 
   /**
    * Position in the 100 CONTINUE message that
diff --git a/src/microhttpd/mhd_limits.h b/src/microhttpd/mhd_limits.h
index b0778112..1b0f5d7d 100644
--- a/src/microhttpd/mhd_limits.h
+++ b/src/microhttpd/mhd_limits.h
@@ -72,7 +72,7 @@
 #else  /* ! __UINT32_MAX__ */
 #define UINT32_MAX ((int32_t)0xFFFFFFFF)
 #endif /* ! __UINT32_MAX__ */
-#endif /* !UNT32_MAX */
+#endif /* !UINT32_MAX */
 
 #ifndef UINT64_MAX
 #ifdef __UINT64_MAX__
@@ -80,18 +80,48 @@
 #else  /* ! __UINT64_MAX__ */
 #define UINT64_MAX ((uint64_t)0xFFFFFFFFFFFFFFFF)
 #endif /* ! __UINT64_MAX__ */
-#endif /* !INT32_MAX */
+#endif /* !UINT64_MAX */
+
+#ifndef INT64_MAX
+#ifdef __INT64_MAX__
+#define INT64_MAX __INT64_MAX__
+#else  /* ! __INT64_MAX__ */
+#define INT64_MAX ((int64_t)0x7FFFFFFFFFFFFFFF)
+#endif /* ! __UINT64_MAX__ */
+#endif /* !INT64_MAX */
 
 #ifndef SIZE_MAX
 #ifdef __SIZE_MAX__
 #define SIZE_MAX __SIZE_MAX__
+#elif defined(UINTPTR_MAX)
+#define SIZE_MAX UINTPTR_MAX
 #else  /* ! __SIZE_MAX__ */
 #define SIZE_MAX MHD_UNSIGNED_TYPE_MAX_(size_t)
 #endif /* ! __SIZE_MAX__ */ 
 #endif /* !SIZE_MAX */
 
+#ifndef SSIZE_MAX
+#ifdef __SSIZE_MAX__
+#define SSIZE_MAX __SSIZE_MAX__
+#elif defined(PTRDIFF_MAX)
+#define SSIZE_MAX PTRDIFF_MAX
+#elif defined(INTPTR_MAX)
+#define SSIZE_MAX INTPTR_MAX
+#else
+#define SSIZE_MAN MHD_SIGNED_TYPE_MAX_(ssize_t)
+#endif
+#endif /* ! SSIZE_MAX */
+
 #ifndef OFF_T_MAX
+#ifdef OFF_MAX
+#define OFF_T_MAX OFF_MAX
+#elif defined(OFFT_MAX)
+#define OFF_T_MAX OFFT_MAX
+#elif defined(__APPLE__) && defined(__MACH__)
+#define OFF_T_MAX INT64_MAX
+#else
 #define OFF_T_MAX MHD_SIGNED_TYPE_MAX_(off_t)
+#endif
 #endif /* !OFF_T_MAX */
 
 #if defined(_LARGEFILE64_SOURCE) && !defined(OFF64_T_MAX)
diff --git a/src/microhttpd/mhd_threads.h b/src/microhttpd/mhd_threads.h
index 1a06c64a..3778ad09 100644
--- a/src/microhttpd/mhd_threads.h
+++ b/src/microhttpd/mhd_threads.h
@@ -91,18 +91,34 @@
   typedef DWORD MHD_thread_ID_;
 #endif
 
+/* Depending on implementation, pthread_create() MAY set thread ID into
+ * provided pointer and after it start thread OR start thread and after
+ * if set thread ID. In latter case, to avoid data races, additional
+ * pthread_self() call is required in thread routine. Is some platform
+ * is known for setting thread ID BEFORE starting thread macro
+ * MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD could be defined
+ * to save some resources. */
 #if defined(MHD_USE_POSIX_THREADS)
+#  ifdef MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD
   union _MHD_thread_handle_ID_
   {
-    MHD_thread_handle_  handle;
-    MHD_thread_ID_      ID;
+    MHD_thread_handle_  handle; /**< To be used in other threads */
+    MHD_thread_ID_      ID;     /**< To be used in thread itself */
   };
   typedef union _MHD_thread_handle_ID_ MHD_thread_handle_ID_;
+#  else  /* ! MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD */
+  struct _MHD_thread_handle_ID_
+  {
+    MHD_thread_handle_  handle; /**< To be used in other threads */
+    MHD_thread_ID_      ID;     /**< To be used in thread itself */
+  };
+  typedef struct _MHD_thread_handle_ID_ MHD_thread_handle_ID_;
+#  endif /* ! MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD */
 #elif defined(MHD_USE_W32_THREADS)
   struct _MHD_thread_handle_ID_
   {
-    MHD_thread_handle_  handle;
-    MHD_thread_ID_      ID;
+    MHD_thread_handle_  handle; /**< To be used in other threads */
+    MHD_thread_ID_      ID;     /**< To be used in thread itself */
   };
   typedef struct _MHD_thread_handle_ID_ MHD_thread_handle_ID_;
 #endif
@@ -140,11 +156,19 @@
 #endif
 
 #if defined(MHD_USE_POSIX_THREADS)
+#  ifdef MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD
 /**
  * Initialise thread ID.
  * @param thread_handle_ID_ptr pointer to thread handle-ID
  */
 #define MHD_thread_init_(thread_handle_ID_ptr) (void)0
+#  else  /* ! MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD */
+/**
+ * Initialise thread ID.
+ * @param thread_handle_ID_ptr pointer to thread handle-ID
+ */
+#define MHD_thread_init_(thread_handle_ID_ptr) 
((thread_handle_ID_ptr)->ID=pthread_self())
+#  endif /* ! MHD_PTHREAD_CREATE__SET_ID_BEFORE_START_THREAD */
 #elif defined(MHD_USE_W32_THREADS)
 /**
  * Initialise thread ID.
diff --git a/src/testcurl/.gitignore b/src/testcurl/.gitignore
index 0e709821..5f2e7da2 100644
--- a/src/testcurl/.gitignore
+++ b/src/testcurl/.gitignore
@@ -104,3 +104,4 @@
 *.exe
 test_quiesce_stream
 test_large_put_inc11
+/test_delete
\ No newline at end of file

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



reply via email to

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