gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. bc


From: gitolite
Subject: [GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. bc83858f65b0f6465ded232ce551b149beaa12d2
Date: Mon, 14 Nov 2016 20:35:49 +0100 (CET)

The branch, master has been updated
       via  bc83858f65b0f6465ded232ce551b149beaa12d2 (commit)
       via  0af992b3a2aee012ae06ad9873694f581549d0c7 (commit)
       via  8f6c5894b30ea08e9b03b4fcf0d154ddfec124a9 (commit)
       via  b484461cd399f4071d5787041f0bd3250b516d26 (commit)
       via  e5eade4a320e9a36ffe54548802172e30e418da3 (commit)
      from  0310cef0141d5deb3917a7c322833cfd46b18bb7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bc83858f65b0f6465ded232ce551b149beaa12d2
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Mon Nov 14 22:31:40 2016 +0300

    Updated documentation about MHD_OPTION_LISTENING_ADDRESS_REUSE

commit 0af992b3a2aee012ae06ad9873694f581549d0c7
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Mon Nov 14 21:27:22 2016 +0300

    Fixed usage of MHD with MHD_OPTION_LISTENING_ADDRESS_REUSE on Linux 3.2, 
3.4 (longterm)

commit 8f6c5894b30ea08e9b03b4fcf0d154ddfec124a9
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Mon Nov 14 21:15:30 2016 +0300

    Fixed unintentional usage of SO_REUSEPORT on W32.

commit b484461cd399f4071d5787041f0bd3250b516d26
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Mon Nov 14 20:53:24 2016 +0300

    Added support for SO_EXCLBIND socket option on Solaris.
    Enabled by MHD_OPTION_LISTENING_ADDRESS_REUSE with zero.

commit e5eade4a320e9a36ffe54548802172e30e418da3
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Mon Nov 14 15:51:47 2016 +0300

    Used 'bool' for struct MHD_Connection::tls_read_ready

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                 |  9 ++++++-
 doc/libmicrohttpd.texi    |  5 ++--
 src/include/microhttpd.h  |  2 +-
 src/microhttpd/daemon.c   | 66 +++++++++++++++++++++--------------------------
 src/microhttpd/internal.h |  8 +++---
 5 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 68f4a11..c1773e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Nov 14 22:18:30 MSK 2016
+       Fixed unintentional usage of SO_REUSEADDR on W32.
+       Added support for SO_EXCLBIND on Solaris.
+       Fixed using MHD with MHD_OPTION_LISTENING_ADDRESS_REUSE
+       on Linux kernels before 3.9 (longterm 3.2 and 3.4
+       are still supported). -EG
+
 Sun Nov 13 19:16:38 CET 2016
        Fixed a few race issues on suspend-resume in cases where the
        application uses threads even though MHD did not (or at least
@@ -5,7 +12,7 @@ Sun Nov 13 19:16:38 CET 2016
        the timeout list, avoiding manipulating it for suspended
        connections.  Finally, eliminated calling application logic
        on suspended connections (which before could happen under
-       certain circumstances).
+       certain circumstances). -CG
 
 Thu Nov 11 20:49:23 MSK 2016
        Added support for various forms of
diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi
index fae5454..70bef1c 100644
--- a/doc/libmicrohttpd.texi
+++ b/doc/libmicrohttpd.texi
@@ -977,9 +977,8 @@ the address:port of the listening socket (using 
@code{SO_REUSEPORT} on most
 platforms, and @code{SO_REUSEADDR} on Windows).  If a false (zero) parameter is
 given, disallow reusing the the address:port of the listening socket (this
 usually requires no special action, but @code{SO_EXCLUSIVEADDRUSE} is needed on
-Windows).  If this option is not present, default behaviour is undefined
-(currently, @code{SO_REUSEADDR} is used on all platforms, which disallows
-address:port reusing with the exception of Windows).
+Windows).  If this option is not present @code{SO_REUSEADDR} is used on all
+platforms except Windows so reusing of address:port is disallowed.
 
 @end table
 @end deftp
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index c91d0a5..d25ea8c 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -126,7 +126,7 @@ typedef intptr_t ssize_t;
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00095209
+#define MHD_VERSION 0x00095210
 
 /**
  * MHD-internal return code for "YES".
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index b964331..ee43900 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -428,10 +428,10 @@ recv_tls_adapter (struct MHD_Connection *connection,
 {
   ssize_t res;
 
-  if (MHD_YES == connection->tls_read_ready)
+  if (connection->tls_read_ready)
     {
       connection->daemon->num_tls_read_ready--;
-      connection->tls_read_ready = MHD_NO;
+      connection->tls_read_ready = 0;
     }
   res = gnutls_record_recv (connection->tls_session,
                             other,
@@ -455,7 +455,7 @@ recv_tls_adapter (struct MHD_Connection *connection,
     }
   if ((size_t)res == i)
     {
-      connection->tls_read_ready = MHD_YES;
+      connection->tls_read_ready = !0;
       connection->daemon->num_tls_read_ready++;
     }
   return res;
@@ -893,7 +893,7 @@ call_handlers (struct MHD_Connection *con,
   bool was_initing = (con->state == MHD_CONNECTION_INIT);
 
 #ifdef HTTPS_SUPPORT
-  if (MHD_YES == con->tls_read_ready)
+  if (con->tls_read_ready)
     read_ready = MHD_YES;
 #endif /* HTTPS_SUPPORT */
   if (read_ready)
@@ -1501,7 +1501,7 @@ thread_main_handle_connection (void *data)
 
       tvp = NULL;
 #ifdef HTTPS_SUPPORT
-      if (MHD_YES == con->tls_read_ready)
+      if (con->tls_read_ready)
        {
          /* do not block (more data may be inside of TLS buffers waiting for 
us) */
          tv.tv_sec = 0;
@@ -4990,8 +4990,11 @@ MHD_start_daemon_va (unsigned int flags,
       /* Apply the socket options according to listening_address_reuse. */
       if (0 == daemon->listening_address_reuse)
         {
-          /* No user requirement, use "traditional" default SO_REUSEADDR,
-           and do not fail if it doesn't work */
+#ifndef _WIN32
+          /* No user requirement, use "traditional" default SO_REUSEADDR
+           * on non-W32 platforms, and do not fail if it doesn't work.
+           * Don't use it on W32, because on W32 it will allow multiple
+           * bind to the same address:port, like SO_REUSEPORT on others. */
           if (0 > setsockopt (socket_fd,
                               SOL_SOCKET,
                               SO_REUSEADDR,
@@ -5003,41 +5006,24 @@ MHD_start_daemon_va (unsigned int flags,
                       MHD_socket_last_strerr_ ());
 #endif
           }
+#endif /* ! _WIN32 */
         }
       else if (daemon->listening_address_reuse > 0)
         {
           /* User requested to allow reusing listening address:port.
            * Use SO_REUSEADDR on Windows and SO_REUSEPORT on most platforms.
-           * Fail if SO_REUSEPORT does not exist or setsockopt fails.
+           * Fail if SO_REUSEPORT is not defined or setsockopt fails.
            */
-#ifdef _WIN32
           /* SO_REUSEADDR on W32 has the same semantics
              as SO_REUSEPORT on BSD/Linux */
+#if defined(_WIN32) || defined(SO_REUSEPORT)
           if (0 > setsockopt (socket_fd,
                               SOL_SOCKET,
-                              SO_REUSEADDR,
-                              (void*)&on, sizeof (on)))
-            {
-#ifdef HAVE_MESSAGES
-              MHD_DLOG (daemon,
-                        "setsockopt failed: %s\n",
-                        MHD_socket_last_strerr_ ());
-#endif
-              goto free_and_fail;
-            }
-#else
-#ifndef SO_REUSEPORT
-#ifdef LINUX
-/* Supported since Linux 3.9, but often not present (or commented out)
-   in the headers at this time; but 15 is reserved for this and
-   thus should be safe to use. */
-#define SO_REUSEPORT 15
-#endif
-#endif
-#ifdef SO_REUSEPORT
-          if (0 > setsockopt (socket_fd,
-                              SOL_SOCKET,
+#ifndef _WIN32
                               SO_REUSEPORT,
+#else  /* _WIN32 */
+                              SO_REUSEADDR,
+#endif /* _WIN32 */
                               (void *) &on,
                               sizeof (on)))
             {
@@ -5048,7 +5034,7 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
               goto free_and_fail;
             }
-#else
+#else  /* !_WIN32 && !SO_REUSEPORT */
           /* we're supposed to allow address:port re-use, but
              on this platform we cannot; fail hard */
 #ifdef HAVE_MESSAGES
@@ -5056,20 +5042,26 @@ MHD_start_daemon_va (unsigned int flags,
                     _("Cannot allow listening address reuse: SO_REUSEPORT not 
defined\n"));
 #endif
           goto free_and_fail;
-#endif
-#endif
+#endif /* !_WIN32 && !SO_REUSEPORT */
         }
       else /* if (daemon->listening_address_reuse < 0) */
         {
           /* User requested to disallow reusing listening address:port.
            * Do nothing except for Windows where SO_EXCLUSIVEADDRUSE
-           * is used. Fail if it does not exist or setsockopt fails.
+           * is used and Solaris with SO_EXCLBIND.
+           * Fail if MHD was compiled for W32 without SO_EXCLUSIVEADDRUSE
+           * or setsockopt fails.
            */
-#ifdef _WIN32
+#if (defined(_WIN32) && defined(SO_EXCLUSIVEADDRUSE)) || \
+    (defined(__sun) && defined(SO_EXCLBIND))
 #ifdef SO_EXCLUSIVEADDRUSE
           if (0 > setsockopt (socket_fd,
                               SOL_SOCKET,
+#ifdef SO_EXCLUSIVEADDRUSE
                               SO_EXCLUSIVEADDRUSE,
+#else  /* SO_EXCLBIND */
+                              SO_EXCLBIND,
+#endif /* SO_EXCLBIND */
                               (void *) &on,
                               sizeof (on)))
             {
@@ -5080,7 +5072,7 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
               goto free_and_fail;
             }
-#else /* SO_EXCLUSIVEADDRUSE not defined on W32? */
+#elif defined(_WIN32) /* SO_EXCLUSIVEADDRUSE not defined on W32? */
 #ifdef HAVE_MESSAGES
           MHD_DLOG (daemon,
                     _("Cannot disallow listening address reuse: 
SO_EXCLUSIVEADDRUSE not defined\n"));
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index a58d85a..64f3c65 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -930,7 +930,7 @@ struct MHD_Connection
    * Could it be that we are ready to read due to TLS buffers
    * even though the socket is not?
    */
-  int tls_read_ready;
+  bool tls_read_ready;
 
   /**
    * TLS layer was shut down?
@@ -1377,9 +1377,11 @@ struct MHD_Daemon
   /**
    * Whether to allow/disallow/ignore reuse of listening address.
    * The semantics is the following:
-   * 0: ignore (user did not ask for neither allow/disallow, use SO_REUSEADDR)
+   * 0: ignore (user did not ask for neither allow/disallow, use SO_REUSEADDR
+   *    except W32)
    * >0: allow (use SO_REUSEPORT on most platforms, SO_REUSEADDR on Windows)
-   * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows)
+   * <0: disallow (mostly no action, SO_EXCLUSIVEADDRUSE on Windows or 
SO_EXCLBIND
+   *     on Solaris)
    */
   int listening_address_reuse;
 


hooks/post-receive
-- 
GNU libmicrohttpd



reply via email to

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