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. 9d


From: gitolite
Subject: [GNUnet-SVN] [libmicrohttpd] GNU libmicrohttpd branch master updated. 9d0ae2e223d9da00b710f0eb797343d2390f64c5
Date: Sat, 22 Oct 2016 14:48:08 +0200 (CEST)

The branch, master has been updated
       via  9d0ae2e223d9da00b710f0eb797343d2390f64c5 (commit)
       via  d7f1a95e22c3d5bde0703360f4406dde7bef31e6 (commit)
       via  54a4333bc6373eb0f3dafc6edb5581d9c39ca712 (commit)
       via  b8057a43d63e37891a4d34a8333c2b0181108b06 (commit)
       via  5f33c34ae4b9310d537c98c767e1a9f883605757 (commit)
       via  baa2d30d1cb938e03eb1e84a30bb5436797af8d8 (commit)
       via  334468c467472230b25b2640ba42639d6052c654 (commit)
       via  e573e782cea7c06b038401407863a4e7d8ccd39e (commit)
      from  69e753bce51bf54aff2304b16e64fb2918decf09 (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 9d0ae2e223d9da00b710f0eb797343d2390f64c5
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Wed Oct 19 19:29:42 2016 +0300

    mhd_sockets.h: Simplified macros

commit d7f1a95e22c3d5bde0703360f4406dde7bef31e6
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Wed Oct 19 20:14:39 2016 +0300

    test_upgrade: comments cleanup

commit 54a4333bc6373eb0f3dafc6edb5581d9c39ca712
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Wed Oct 19 19:59:59 2016 +0300

    test_upgrade: minor fix

commit b8057a43d63e37891a4d34a8333c2b0181108b06
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Wed Oct 19 19:51:27 2016 +0300

    test_upgrade{,-ssl}: portability, second step

commit 5f33c34ae4b9310d537c98c767e1a9f883605757
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Wed Oct 19 19:37:14 2016 +0300

    test_upgrade{,-ssl}: portability, first step

commit baa2d30d1cb938e03eb1e84a30bb5436797af8d8
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Wed Oct 19 18:46:16 2016 +0300

    test_upgrade: be more verbose, fixed build without poll()

commit 334468c467472230b25b2640ba42639d6052c654
Author: Karlson2k <address@hidden>
Date:   Thu Oct 20 19:54:25 2016 +0300

    test_upgrade_ssl: use 'gnutls-cli' instead of 'openssl'

commit e573e782cea7c06b038401407863a4e7d8ccd39e
Author: Evgeny Grin (Karlson2k) <address@hidden>
Date:   Wed Oct 19 20:47:02 2016 +0300

    upgrade: fixed connection states with same value

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

Summary of changes:
 src/microhttpd/connection.c          |  5 ++
 src/microhttpd/internal.h            |  2 +-
 src/microhttpd/mhd_sockets.h         | 17 ++++---
 src/microhttpd/test_upgrade.c        | 96 ++++++++++++++++++++++++++++--------
 src/microhttpd/test_upgrade_common.c | 75 +++++++++++++---------------
 src/microhttpd/test_upgrade_ssl.c    | 58 +++++++++++++++++-----
 6 files changed, 170 insertions(+), 83 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 3a121b9..da76261 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2354,6 +2354,8 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
         case MHD_CONNECTION_UPGRADE:
           EXTRA_CHECK (0);
           break;
+        case MHD_CONNECTION_UPGRADE_CLOSED:
+          break;
         default:
           /* shrink read buffer to how much is actually used */
           MHD_pool_reallocate (connection->pool,
@@ -2538,6 +2540,8 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
         case MHD_CONNECTION_UPGRADE:
           EXTRA_CHECK (0);
           break;
+        case MHD_CONNECTION_UPGRADE_CLOSED:
+          break;
         default:
           EXTRA_CHECK (0);
          CONNECTION_CLOSE_ERROR (connection,
@@ -3057,6 +3061,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
          cleanup_connection (connection);
          return MHD_NO;
         case MHD_CONNECTION_UPGRADE:
+        case MHD_CONNECTION_UPGRADE_CLOSED:
           return MHD_YES; /* keep open */
         default:
           EXTRA_CHECK (0);
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 89516d8..4a3fe58 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -508,7 +508,7 @@ enum MHD_CONNECTION_STATE
    * by the application.  We now need to do our own
    * internal cleanup.
    */
-  MHD_CONNECTION_UPGRADE_CLOSED = MHD_TLS_CONNECTION_INIT + 1
+  MHD_CONNECTION_UPGRADE_CLOSED = MHD_CONNECTION_UPGRADE + 1
 
 };
 
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index 983267c..6fefd7d 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -639,15 +639,16 @@
 
 /* Socket functions */
 
-#if defined(MHD_POSIX_SOCKETS) && defined(AF_LOCAL)
-#  define MHD_socket_pair_(fdarr) (!socketpair(AF_LOCAL, SOCK_STREAM, 0, 
(fdarr)))
+#if defined(AF_LOCAL)
+#  define MHD_SCKT_LOCAL AF_LOCAL
+#elif defined(AF_UNIX)
+#  define MHD_SCKT_LOCAL AF_UNIX
+#endif /* AF_UNIX */
+
+#if defined(MHD_POSIX_SOCKETS) && defined(MHD_SCKT_LOCAL)
+#  define MHD_socket_pair_(fdarr) (!socketpair(MHD_SCKT_LOCAL, SOCK_STREAM, 0, 
(fdarr)))
 #  if defined(HAVE_SOCK_NONBLOCK)
-#    define MHD_socket_pair_nblk_(fdarr) (!socketpair(AF_LOCAL, SOCK_STREAM | 
SOCK_NONBLOCK, 0, (fdarr)))
-#  endif /* HAVE_SOCK_NONBLOCK*/
-#elif defined(MHD_POSIX_SOCKETS) && defined(AF_UNIX)
-#  define MHD_socket_pair_(fdarr) (!socketpair(AF_UNIX, SOCK_STREAM, 0, 
(fdarr)))
-#  if defined(HAVE_SOCK_NONBLOCK)
-#    define MHD_socket_pair_nblk_(fdarr) (!socketpair(AF_UNIX, SOCK_STREAM | 
SOCK_NONBLOCK, 0, (fdarr)))
+#    define MHD_socket_pair_nblk_(fdarr) (!socketpair(MHD_SCKT_LOCAL, 
SOCK_STREAM | SOCK_NONBLOCK, 0, (fdarr)))
 #  endif /* HAVE_SOCK_NONBLOCK*/
 #elif defined(MHD_WINSOCK_SOCKETS)
    /**
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index 68f5c2b..b369fd7 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -39,6 +39,9 @@
 #ifdef HAVE_NETINET_IP_H
 #include <netinet/ip.h>
 #endif /* HAVE_NETINET_IP_H */
+
+static int verbose = 0;
+#include "test_helpers.h"
 #include "test_upgrade_common.c"
 
 
@@ -102,37 +105,90 @@ main (int argc,
       char *const *argv)
 {
   int error_count = 0;
+  int res;
+
+  if (has_param(argc, argv, "-v") || has_param(argc, argv, "--verbose"))
+    verbose = 1;
 
   /* try external select */
-  error_count += test_upgrade (0,
-                               0);
+  res = test_upgrade (0,
+                      0);
+  error_count += res;
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with external select, return code 
%d.\n", res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with external select.\n");
 #ifdef EPOLL_SUPPORT
-  error_count += test_upgrade (MHD_USE_EPOLL,
-                               0);
+  res = test_upgrade (MHD_USE_EPOLL,
+                      0);
+  error_count += res;
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with external select with EPOLL, return 
code %d.\n", res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with external select with EPOLL.\n");
 #endif
 
   /* Test thread-per-connection */
-  error_count += test_upgrade (MHD_USE_THREAD_PER_CONNECTION,
-                               0);
-  error_count += test_upgrade (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL,
-                               0);
+  res = test_upgrade (MHD_USE_THREAD_PER_CONNECTION,
+                      0);
+  error_count += res;
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with thread per connection, return code 
%d.\n", res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with thread per connection.\n");
+#ifdef HAVE_POLL
+  res = test_upgrade (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL,
+                      0);
+  error_count += res;
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with thread per connection and poll, 
return code %d.\n", res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with thread per connection and poll.\n");
+#endif /* HAVE_POLL */
 
   /* Test different event loops, with and without thread pool */
-  error_count += test_upgrade (MHD_USE_SELECT_INTERNALLY,
-                               0);
-  error_count += test_upgrade (MHD_USE_SELECT_INTERNALLY,
-                               2);
+  res = test_upgrade (MHD_USE_SELECT_INTERNALLY,
+                      0);
+  error_count += res;
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with internal select, return code 
%d.\n", res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with internal select.\n");
+  res = test_upgrade (MHD_USE_SELECT_INTERNALLY,
+                      2);
+  error_count += res;
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with internal select, return code 
%d.\n", res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with internal select.\n");
 #ifdef HAVE_POLL
-  error_count += test_upgrade (MHD_USE_POLL_INTERNALLY,
-                               0);
-  error_count += test_upgrade (MHD_USE_POLL_INTERNALLY,
-                               2);
+  res = test_upgrade (MHD_USE_POLL_INTERNALLY,
+                      0);
+  error_count += res;
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with internal poll, return code %d.\n", 
res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with internal poll.\n");
+  res = test_upgrade (MHD_USE_POLL_INTERNALLY,
+                      2);
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with internal poll with thread pool, 
return code %d.\n", res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with internal poll with thread pool.\n");
 #endif
 #ifdef EPOLL_SUPPORT
-  error_count += test_upgrade (MHD_USE_EPOLL_INTERNALLY,
-                               0);
-  error_count += test_upgrade (MHD_USE_EPOLL_INTERNALLY,
-                               2);
+  res = test_upgrade (MHD_USE_EPOLL_INTERNALLY,
+                      0);
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with internal epoll, return code %d.\n", 
res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with internal epoll.\n");
+  res = test_upgrade (MHD_USE_EPOLL_INTERNALLY,
+                      2);
+  if (res)
+    fprintf (stderr, "FAILED: Upgrade with internal epoll, return code %d.\n", 
res);
+  else if (verbose)
+    printf ("PASSED: Upgrade with internal epoll.\n");
 #endif
   /* report result */
   if (0 != error_count)
diff --git a/src/microhttpd/test_upgrade_common.c 
b/src/microhttpd/test_upgrade_common.c
index ee3f699..f04288d 100644
--- a/src/microhttpd/test_upgrade_common.c
+++ b/src/microhttpd/test_upgrade_common.c
@@ -24,6 +24,7 @@
  * @author Christian Grothoff
  */
 
+#include "mhd_sockets.h"
 
 /**
  * Thread we use to run the interaction with the upgraded socket.
@@ -166,12 +167,12 @@ send_all (MHD_socket sock,
   make_blocking (sock);
   for (size_t off = 0; off < len; off += ret)
     {
-      ret = write (sock,
-                   &text[off],
-                   len - off);
-      if (-1 == ret)
+      ret = MHD_send_ (sock,
+                       &text[off],
+                       len - off);
+      if (0 > ret)
         {
-          if (EAGAIN == errno)
+          if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
             {
               ret = 0;
               continue;
@@ -199,12 +200,12 @@ recv_hdr (MHD_socket sock)
   i = 0;
   while (i < 4)
     {
-      ret = read (sock,
-                  &c,
-                  1);
-      if (-1 == ret)
+      ret = MHD_recv_ (sock,
+                       &c,
+                       1);
+      if (0 > ret)
         {
-          if (EAGAIN == errno)
+          if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
             continue;
           abort ();
         }
@@ -242,12 +243,12 @@ recv_all (MHD_socket sock,
   make_blocking (sock);
   for (size_t off = 0; off < len; off += ret)
     {
-      ret = read (sock,
-                  &buf[off],
-                  len - off);
-      if (-1 == ret)
+      ret = MHD_recv_ (sock,
+                       &buf[off],
+                       len - off);
+      if (0 > ret)
         {
-          if (EAGAIN == errno)
+          if (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ()))
             {
               ret = 0;
               continue;
@@ -314,25 +315,14 @@ run_usock_client (void *cls)
  * successfully and the socket should now be controlled by some
  * protocol other than HTTP.
  *
- * Any data received on the socket will be made available in
- * 'data_in'.  The function should update 'data_in_size' to
- * reflect the number of bytes consumed from 'data_in' (the remaining
- * bytes will be made available in the next call to the handler).
+ * Any data already received on the socket will be made available in
+ * @e extra_in.  This can happen if the application sent extra data
+ * before MHD send the upgrade response.  The application should
+ * treat data from @a extra_in as if it had read it from the socket.
  *
- * Any data that should be transmitted on the socket should be
- * stored in 'data_out'.  '*data_out_size' is initially set to
- * the available buffer space in 'data_out'.  It should be set to
- * the number of bytes stored in 'data_out' (which can be zero).
- *
- * The return value is a BITMASK that indicates how the function
- * intends to interact with the event loop.  It can request to be
- * notified for reading, writing, request to UNCORK the send buffer
- * (which MHD is allowed to ignore, if it is not possible to uncork on
- * the local platform), to wait for the 'external' select loop to
- * trigger another round.  It is also possible to specify "no events"
- * to terminate the connection; in this case, the
- * #MHD_RequestCompletedCallback will be called and all resources of
- * the connection will be released.
+ * Note that the application must not close() @a sock directly,
+ * but instead use #MHD_upgrade_action() for special operations
+ * on @a sock.
  *
  * Except when in 'thread-per-connection' mode, implementations
  * of this function should never block (as it will still be called
@@ -342,7 +332,7 @@ run_usock_client (void *cls)
  * @param connection original HTTP connection handle,
  *                   giving the function a last chance
  *                   to inspect the original HTTP request
- * @param con_cls last value left in `*con_cls` in the 
`MHD_AccessHandlerCallback`
+ * @param con_cls last value left in `con_cls` of the 
`MHD_AccessHandlerCallback`
  * @param extra_in if we happened to have read bytes after the
  *                 HTTP header already (because the client sent
  *                 more than the HTTP header of the request before
@@ -356,10 +346,13 @@ run_usock_client (void *cls)
  *        that is directly connected to the client and thus certain
  *        operations (TCP-specific setsockopt(), getsockopt(), etc.)
  *        may not work as expected (as the socket could be from a
- *        socketpair() or a TCP-loopback)
+ *        socketpair() or a TCP-loopback).  The application is expected
+ *        to perform read()/recv() and write()/send() calls on the socket.
+ *        The application may also call shutdown(), but must not call
+ *        close() directly.
  * @param urh argument for #MHD_upgrade_action()s on this @a connection.
- *        Applications must eventually use this function to perform the
- *        close() action on the @a sock.
+ *        Applications must eventually use this callback to (indirectly)
+ *        perform the close() action on the @a sock.
  */
 static void
 upgrade_cb (void *cls,
@@ -452,7 +445,6 @@ ahc_upgrade (void *cls,
  * Run the MHD external event loop using select.
  *
  * @param daemon daemon to run it for
- * @param flags the flags the daemon was started with
  */
 static void
 run_mhd_select_loop (struct MHD_Daemon *daemon)
@@ -481,6 +473,8 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
         abort ();
       (void) MHD_get_timeout (daemon,
                               &to);
+      if (1000 < to)
+        to = 1000;
       tv.tv_sec = to / 1000;
       tv.tv_usec = 1000 * (to % 1000);
       if (0 > MHD_SYS_select_ (max_fd + 1,
@@ -501,7 +495,6 @@ run_mhd_select_loop (struct MHD_Daemon *daemon)
  * Run the MHD external event loop using select.
  *
  * @param daemon daemon to run it for
- * @param flags the flags the daemon was started with
  */
 static void
 run_mhd_poll_loop (struct MHD_Daemon *daemon)
@@ -514,7 +507,6 @@ run_mhd_poll_loop (struct MHD_Daemon *daemon)
  * Run the MHD external event loop using select.
  *
  * @param daemon daemon to run it for
- * @param flags the flags the daemon was started with
  */
 static void
 run_mhd_epoll_loop (struct MHD_Daemon *daemon)
@@ -536,6 +528,8 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
       FD_SET (ep, &rs);
       (void) MHD_get_timeout (daemon,
                               &to);
+      if (1000 < to)
+        to = 1000;
       tv.tv_sec = to / 1000;
       tv.tv_usec = 1000 * (to % 1000);
       select (ep + 1,
@@ -552,7 +546,6 @@ run_mhd_epoll_loop (struct MHD_Daemon *daemon)
  * Run the MHD external event loop using select.
  *
  * @param daemon daemon to run it for
- * @param flags the flags the daemon was started with
  */
 static void
 run_mhd_loop (struct MHD_Daemon *daemon,
diff --git a/src/microhttpd/test_upgrade_ssl.c 
b/src/microhttpd/test_upgrade_ssl.c
index 145c733..07031cf 100644
--- a/src/microhttpd/test_upgrade_ssl.c
+++ b/src/microhttpd/test_upgrade_ssl.c
@@ -47,6 +47,15 @@
 #include "../testcurl/https/tls_test_keys.h"
 
 
+enum tls_cli_tool
+{
+  TLS_CLI_NO_TOOL = 0,
+  TLS_CLI_GNUTLS,
+  TLS_CLI_OPENSSL
+};
+
+enum tls_cli_tool use_tool;
+
 /**
  * Fork child that connects via OpenSSL to our @a port.  Allows us to
  * talk to our port over a socket in @a sp without having to worry
@@ -81,17 +90,35 @@ openssl_connect (int *sock,
   dup2 (sp[0], 0);
   dup2 (sp[0], 1);
   MHD_socket_close_chk_ (sp[0]);
-  sprintf (destination,
-           "localhost:%u",
-           (unsigned int) port);
-  execlp ("openssl",
-          "openssl",
-          "s_client",
-          "-connect",
-          destination,
-          "-verify",
-          "0",
-          (char *) NULL);
+  if (TLS_CLI_GNUTLS == use_tool)
+    {
+      snprintf (destination,
+               sizeof(destination),
+               "%u",
+               (unsigned int) port);
+      execlp ("gnutls-cli",
+             "gnutls-cli",
+             "--insecure",
+             "-p",
+             destination,
+             "localhost",
+             (char *) NULL);
+    }
+  else if (TLS_CLI_OPENSSL == use_tool)
+    {
+      snprintf (destination,
+               sizeof(destination),
+               "localhost:%u",
+               (unsigned int) port);
+      execlp ("openssl",
+             "openssl",
+             "s_client",
+             "-connect",
+             destination,
+             "-verify",
+             "0",
+             (char *) NULL);
+    }
   _exit (1);
 }
 
@@ -160,8 +187,13 @@ main (int argc,
 {
   int error_count = 0;
 
-  if (0 != system ("openssl version 1> /dev/null"))
-    return 77; /* openssl not available, can't run the test */
+  use_tool = TLS_CLI_NO_TOOL;
+  if (0 == system ("gnutls-cli --version 1> /dev/null"))
+    use_tool = TLS_CLI_GNUTLS;
+  else if (0 != system ("openssl version 1> /dev/null"))
+    use_tool = TLS_CLI_OPENSSL;
+  else
+    return 77; /* not possible to test */
 
   /* try external select */
   error_count += test_upgrade (0,


hooks/post-receive
-- 
GNU libmicrohttpd



reply via email to

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