gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (99f2df6d -> 17e01403)


From: gnunet
Subject: [libmicrohttpd] branch master updated (99f2df6d -> 17e01403)
Date: Sat, 17 Apr 2021 15:53:38 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 99f2df6d mhd_send: finally handle sockets errors in portable way
     new abb47a11 mhd_send: fixed log messaged broken by 
99f2df6dea40624ff82b00ebe362e587f722985f
     new e2d6e582 test_upgrade_large: do not uncork the socket
     new 17e01403 mhd_send: made MHD_connection_set_cork_state_() non-static

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:
 src/microhttpd/mhd_send.c           | 52 +++++++++++++++++++++++--------------
 src/microhttpd/mhd_send.h           | 18 ++++++++++++-
 src/microhttpd/test_upgrade_large.c |  3 +--
 3 files changed, 51 insertions(+), 22 deletions(-)

diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 793df8d0..b347503f 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -170,6 +170,7 @@ bool
 MHD_connection_set_nodelay_state_ (struct MHD_Connection *connection,
                                    bool nodelay_state)
 {
+#ifdef TCP_NODELAY
   const MHD_SCKT_OPT_BOOL_ off_val = 0;
   const MHD_SCKT_OPT_BOOL_ on_val = 1;
   int err_code;
@@ -218,11 +219,13 @@ MHD_connection_set_nodelay_state_ (struct MHD_Connection 
*connection,
   }
 #endif /* HAVE_MESSAGES */
 
+#else  /* ! TCP_NODELAY */
+  (void) connection; (void) nodelay_state; /* Mute compiler warnings */
+#endif /* ! TCP_NODELAY */
   return false;
 }
 
 
-#if defined(MHD_TCP_CORK_NOPUSH)
 /**
  * Set required cork state for connection socket
  *
@@ -230,12 +233,14 @@ MHD_connection_set_nodelay_state_ (struct MHD_Connection 
*connection,
  *
  * @param connection the connection to manipulate
  * @param cork_state the requested new state of socket
- * @return true if succeed, false if failed
+ * @return true if succeed, false if failed or not supported
+ *         by the current platform / kernel.
  */
-static bool
-connection_set_cork_state_ (struct MHD_Connection *connection,
-                            bool cork_state)
+bool
+MHD_connection_set_cork_state_ (struct MHD_Connection *connection,
+                                bool cork_state)
 {
+#if defined(MHD_TCP_CORK_NOPUSH)
   const MHD_SCKT_OPT_BOOL_ off_val = 0;
   const MHD_SCKT_OPT_BOOL_ on_val = 1;
   int err_code;
@@ -265,7 +270,11 @@ connection_set_cork_state_ (struct MHD_Connection 
*connection,
       MHD_DLOG (connection->daemon,
                 _ ("Setting %s option to %s state failed "
                    "for TCP/IP socket %d: %s\n"),
-                "TCP_NODELAY",
+#ifdef TCP_CORK
+                "TCP_CORK",
+#else  /* ! TCP_CORK */
+                "TCP_NOPUSH",
+#endif /* ! TCP_CORK */
                 nodelay_state ? _ ("ON") : _ ("OFF"),
                 (int) connection->socket_fd,
                 MHD_socket_strerr_ (err_code));
@@ -277,18 +286,23 @@ connection_set_cork_state_ (struct MHD_Connection 
*connection,
   {
     MHD_DLOG (connection->daemon,
               _ ("Setting %s option to %s state failed: %s\n"),
-              "TCP_NODELAY",
+#ifdef TCP_CORK
+              "TCP_CORK",
+#else  /* ! TCP_CORK */
+              "TCP_NOPUSH",
+#endif /* ! TCP_CORK */
               nodelay_state ? _ ("ON") : _ ("OFF"),
               MHD_socket_strerr_ (err_code));
   }
 #endif /* HAVE_MESSAGES */
 
+#else  /* ! MHD_TCP_CORK_NOPUSH */
+  (void) connection; (void) cork_state; /* Mute compiler warnings. */
+#endif /* ! MHD_TCP_CORK_NOPUSH */
   return false;
 }
 
 
-#endif /* MHD_TCP_CORK_NOPUSH */
-
 /**
  * Handle pre-send setsockopt calls.
  *
@@ -330,7 +344,7 @@ pre_send_setopt (struct MHD_Connection *connection,
     if (_MHD_ON == connection->sk_corked)
       return; /* The connection was already corked. */
 
-    if (connection_set_cork_state_ (connection, true))
+    if (MHD_connection_set_cork_state_ (connection, true))
       return; /* The connection has been corked. */
 
     /* Failed to cork the connection.
@@ -410,7 +424,7 @@ pre_send_setopt (struct MHD_Connection *connection,
     {
       /* Setting TCP_NODELAY may push data.
        * Cork socket here and uncork after send(). */
-      if (connection_set_cork_state_ (connection, true))
+      if (MHD_connection_set_cork_state_ (connection, true))
         return; /* The connection has been corked.
                  * Data can be pushed by resetting of
                  * TCP_CORK / TCP_NOPUSH after send() */
@@ -454,7 +468,7 @@ pre_send_setopt (struct MHD_Connection *connection,
          * to uncork the socket after send(). */
         /* Ignore possible error here as no other options exist to
          * push data. */
-        connection_set_cork_state_ (connection, true);
+        MHD_connection_set_cork_state_ (connection, true);
         /* The connection has been (hopefully) corked.
          * Data can be pushed by resetting of TCP_CORK / TCP_NOPUSH
          * after send() */
@@ -464,7 +478,7 @@ pre_send_setopt (struct MHD_Connection *connection,
   }
   /* Corked state is unknown. Need to make sys-call here otherwise
    * data may not be pushed. */
-  if (connection_set_cork_state_ (connection, true))
+  if (MHD_connection_set_cork_state_ (connection, true))
     return; /* The connection has been corked.
              * Data can be pushed by resetting of
              * TCP_CORK / TCP_NOPUSH after send() */
@@ -497,7 +511,7 @@ pre_send_setopt (struct MHD_Connection *connection,
 
   /* Uncork socket if socket wasn't uncorked. */
   if (_MHD_OFF != connection->sk_corked)
-    connection_set_cork_state_ (connection, false);
+    MHD_connection_set_cork_state_ (connection, false);
 
   /* Set TCP_NODELAY if it wasn't set. */
   if (_MHD_ON != connection->sk_nodelay)
@@ -610,7 +624,7 @@ post_send_setopt (struct MHD_Connection *connection,
       return; /* Data has been pushed by TCP_NODELAY. */
     /* Failed to set TCP_NODELAY for the socket.
      * Really unlikely to happen on TCP connections. */
-    if (connection_set_cork_state_ (connection, false))
+    if (MHD_connection_set_cork_state_ (connection, false))
       return; /* Data has been pushed by uncorking the socket. */
     /* Failed to uncork the socket.
      * Really unlikely to happen on TCP connections. */
@@ -619,7 +633,7 @@ post_send_setopt (struct MHD_Connection *connection,
   }
   else
   {
-    if (connection_set_cork_state_ (connection, false))
+    if (MHD_connection_set_cork_state_ (connection, false))
       return; /* Data has been pushed by uncorking the socket. */
     /* Failed to uncork the socket.
      * Really unlikely to happen on TCP connections. */
@@ -637,7 +651,7 @@ post_send_setopt (struct MHD_Connection *connection,
     return; /* Data was pushed by TCP_NODELAY. */
   /* Failed to set TCP_NODELAY for the socket.
    * Really unlikely to happen on TCP connections. */
-  if (connection_set_cork_state_ (connection, false))
+  if (MHD_connection_set_cork_state_ (connection, false))
     return; /* Data was pushed by uncorking the socket. */
   /* Failed to uncork the socket.
    * Really unlikely to happen on TCP connections. */
@@ -645,7 +659,7 @@ post_send_setopt (struct MHD_Connection *connection,
   /* The socket remains corked, no way to push data */
 #endif /* ! MHD_USE_MSG_MORE */
 #else  /* ! _MHD_NODELAY_SET_PUSH_DATA_ALWAYS */
-  if (connection_set_cork_state_ (connection, false))
+  if (MHD_connection_set_cork_state_ (connection, false))
     return; /* Data was pushed by uncorking the socket. */
   /* Failed to uncork the socket.
    * Really unlikely to happen on TCP connections. */
@@ -679,7 +693,7 @@ post_send_setopt (struct MHD_Connection *connection,
 #endif /* _MHD_CORK_RESET_PUSH_DATA */
     /* The socket is corked or cork state is unknown. */
 
-    if (connection_set_cork_state_ (connection, false))
+    if (MHD_connection_set_cork_state_ (connection, false))
     {
 #ifdef _MHD_CORK_RESET_PUSH_DATA
       /* FreeBSD kernel */
diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h
index 57f6319b..3d440b84 100644
--- a/src/microhttpd/mhd_send.h
+++ b/src/microhttpd/mhd_send.h
@@ -120,13 +120,29 @@ MHD_send_sendfile_ (struct MHD_Connection *connection);
  * The function automatically updates sk_nodelay state.
  * @param connection the connection to manipulate
  * @param nodelay_state the requested new state of socket
- * @return true if succeed, false if failed
+ * @return true if succeed, false if failed or not supported
+ *         by the current platform / kernel.
  */
 bool
 MHD_connection_set_nodelay_state_ (struct MHD_Connection *connection,
                                    bool nodelay_state);
 
 
+/**
+ * Set required cork state for connection socket
+ *
+ * The function automatically updates sk_corked state.
+ *
+ * @param connection the connection to manipulate
+ * @param cork_state the requested new state of socket
+ * @return true if succeed, false if failed or not supported
+ *         by the current platform / kernel.
+ */
+bool
+MHD_connection_set_cork_state_ (struct MHD_Connection *connection,
+                                bool cork_state);
+
+
 /**
  * Function for sending responses backed by a an array of memory buffers.
  *
diff --git a/src/microhttpd/test_upgrade_large.c 
b/src/microhttpd/test_upgrade_large.c
index 7de8de2d..aeae5127 100644
--- a/src/microhttpd/test_upgrade_large.c
+++ b/src/microhttpd/test_upgrade_large.c
@@ -511,8 +511,7 @@ wr_send (struct wr_socket *s,
     ssize_t ret;
 
     ret = MHD_send_ (s->fd, buf, len);
-    (void) MHD_socket_cork_ (s->fd,
-                             false);
+
     return ret;
   }
 #ifdef HTTPS_SUPPORT

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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