gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 03/03: mhd_send: made MHD_connection_set_cork_state_() n


From: gnunet
Subject: [libmicrohttpd] 03/03: mhd_send: made MHD_connection_set_cork_state_() non-static
Date: Sat, 17 Apr 2021 15:53:41 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 17e01403c603fef2c2d5bd1ff6195be6416fa219
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Apr 17 16:42:41 2021 +0300

    mhd_send: made MHD_connection_set_cork_state_() non-static
---
 src/microhttpd/mhd_send.c | 40 +++++++++++++++++++++++-----------------
 src/microhttpd/mhd_send.h | 18 +++++++++++++++++-
 2 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 62f94e59..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;
@@ -291,12 +296,13 @@ connection_set_cork_state_ (struct MHD_Connection 
*connection,
   }
 #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.
  *
@@ -338,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.
@@ -418,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() */
@@ -462,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() */
@@ -472,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() */
@@ -505,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)
@@ -618,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. */
@@ -627,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. */
@@ -645,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. */
@@ -653,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. */
@@ -687,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.
  *

-- 
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]