gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated: Stopped using sk_cork_on for TCP_


From: gnunet
Subject: [libmicrohttpd] branch master updated: Stopped using sk_cork_on for TCP_NODELAY tracking.
Date: Thu, 03 Dec 2020 17:51:34 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new b9e0a0ac Stopped using sk_cork_on for TCP_NODELAY tracking.
b9e0a0ac is described below

commit b9e0a0ac45e195288dc1da99a8a68574d6255c03
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Dec 3 19:51:02 2020 +0300

    Stopped using sk_cork_on for TCP_NODELAY tracking.
    
    Replaced sk_cork_on with tri-state sk_corked.
    TCP_NODELAY is tracked on separate member.
---
 src/microhttpd/connection.c |  8 +++-----
 src/microhttpd/daemon.c     |  7 +++++--
 src/microhttpd/internal.h   |  5 ++---
 src/microhttpd/mhd_send.c   | 29 ++++++++++-------------------
 src/microhttpd/response.c   |  8 ++++----
 5 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index be88d874..27b1cbdc 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2408,11 +2408,9 @@ check_write_done (struct MHD_Connection *connection,
                   enum MHD_CONNECTION_STATE next_state)
 {
   if ( (connection->write_buffer_append_offset !=
-        connection->write_buffer_send_offset) ||
-       /* if we expected to turn cork off, and it is still on,
-          we are not finished sending (can happen with gnutls_record_uncork) */
-       ( (connection->sk_cork_on) &&
-         (MHD_CONNECTION_HEADERS_SENDING != connection->state) ) )
+        connection->write_buffer_send_offset)
+       /* || data_in_tls_buffers == true  */
+       )
     return MHD_NO;
   connection->write_buffer_append_offset = 0;
   connection->write_buffer_send_offset = 0;
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 797c5d49..a650eefe 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2460,9 +2460,12 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
     errno = eno;
     return MHD_NO;
   }
-  connection->sk_cork_on = false;
 #if defined(MHD_TCP_CORK_NOPUSH) || defined(MHD_USE_MSG_MORE)
-  (void) external_add; /* Mute compiler warning */
+  if (! external_add)
+    connection->sk_corked = _MHD_OFF;
+  else
+    connection->sk_corked = _MHD_UNKNOWN;
+
   /* We will use TCP_CORK or TCP_NOPUSH or MSG_MORE to control
      transmission, disable Nagle's algorithm (always) */
   if (0 != MHD_socket_set_nodelay_ (client_socket, true))
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index fd5b1748..d59735b5 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -929,10 +929,9 @@ struct MHD_Connection
   bool sk_nonblck;
 
   /**
-   * Indicate whether connection socket has TCP_CORK / Nagle’s algorithm 
turned on/off
-   * on this socket.
+   * Tracks TCP_CORK / TCP_NOPUSH of the connection socket.
    */
-  bool sk_cork_on;
+  enum MHD_tristate sk_corked;
 
   /**
    * Tracks TCP_NODELAY state of the connection socket.
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 0cdd1265..891c70b7 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -137,19 +137,16 @@ pre_send_setopt (struct MHD_Connection *connection,
 #endif /* ! MHD_USE_MSG_MORE */
 
 #if defined(MHD_TCP_CORK_NOPUSH)
-  /* If sk_cork_on is already what we pass in, return. */
-  if (connection->sk_cork_on == buffer_data)
-  {
-    /* nothing to do, success! */
+  /* If connection is already in required corked state, do nothing. */
+  if (connection->sk_corked == buffer_data)
     return;
-  }
   if (push_data)
-    return; /* nothing to do *pre* syscall! */
+    return; /* nothing to do *pre* syscall! BUG: to be fixed */
   ret = MHD_socket_cork_ (connection->socket_fd,
-                          true);
+                          buffer_data);
   if (0 != ret)
   {
-    connection->sk_cork_on = true;
+    connection->sk_corked = buffer_data;
     return;
   }
   switch (errno)
@@ -201,10 +198,7 @@ pre_send_setopt (struct MHD_Connection *connection,
   }
   if (0 == MHD_socket_set_nodelay_ (connection->socket_fd,
                                     (push_data)))
-  {
-    connection->sk_cork_on = ! push_data;
     connection->sk_nodelay = push_data;
-  }
 #endif
 }
 
@@ -240,21 +234,18 @@ post_send_setopt (struct MHD_Connection *connection,
 #endif /* ! MHD_USE_MSG_MORE */
 
 #if defined(MHD_TCP_CORK_NOPUSH)
-  /* If sk_cork_on is already what we pass in, return. */
-  if (connection->sk_cork_on == buffer_data)
-  {
-    /* nothing to do, success! */
+  /* If connection is already in required corked state, do nothing. */
+  if (connection->sk_corked == buffer_data)
     return;
-  }
   if (buffer_data)
     return; /* nothing to do *post* syscall (in fact, we should never
-               get here, as sk_cork_on should have succeeded in the
+               get here, as sk_corked should have succeeded in the
                pre-syscall) */
   ret = MHD_socket_cork_ (connection->socket_fd,
-                          false);
+                          buffer_data);
   if (0 != ret)
   {
-    connection->sk_cork_on = false;
+    connection->sk_corked = buffer_data;
     return;
   }
   switch (errno)
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 489be718..b857326f 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -892,24 +892,24 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh,
     MHD_resume_connection (connection);
     return MHD_YES;
   case MHD_UPGRADE_ACTION_CORK_ON:
-    if (connection->sk_cork_on)
+    if (_MHD_ON == connection->sk_corked)
       return MHD_YES;
     if (0 !=
         MHD_socket_cork_ (connection->socket_fd,
                           true))
     {
-      connection->sk_cork_on = true;
+      connection->sk_corked = _MHD_ON;
       return MHD_YES;
     }
     return MHD_NO;
   case MHD_UPGRADE_ACTION_CORK_OFF:
-    if (! connection->sk_cork_on)
+    if (_MHD_OFF == connection->sk_corked)
       return MHD_YES;
     if (0 !=
         MHD_socket_cork_ (connection->socket_fd,
                           false))
     {
-      connection->sk_cork_on = false;
+      connection->sk_corked = _MHD_OFF;
       return MHD_YES;
     }
     return MHD_NO;

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