gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 04/06: Removed gnutls_record_(un)cork() usage.


From: gnunet
Subject: [libmicrohttpd] 04/06: Removed gnutls_record_(un)cork() usage.
Date: Tue, 01 Dec 2020 17:12:38 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 958d8704e85fd94f76aea7a666557de9794df480
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Nov 30 00:35:18 2020 +0300

    Removed gnutls_record_(un)cork() usage.
    
    gnutls_record_cork()/gnutls_record_uncork() needs
    special handling to periodically push part of the buffer.
---
 src/microhttpd/mhd_send.c | 48 +++++++----------------------------------------
 src/microhttpd/response.c | 44 ++++++++-----------------------------------
 2 files changed, 15 insertions(+), 77 deletions(-)

diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 4dedec14..161c515e 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -349,18 +349,10 @@ MHD_send_on_connection_ (struct MHD_Connection 
*connection,
     break;
   }
 
-#ifdef HTTPS_SUPPORT
+  pre_cork_setsockopt (connection, tls_conn, want_cork);
   if (tls_conn)
   {
-    bool have_cork = connection->sk_cork_on;
-
-#if GNUTLS_VERSION_NUMBER >= 0x030109
-    if (want_cork && ! have_cork)
-    {
-      gnutls_record_cork (connection->tls_session);
-      connection->sk_cork_on = true;
-    }
-#endif /* GNUTLS_VERSION_NUMBER >= 0x030109 */
+#ifdef HTTPS_SUPPORT
     if (buffer_size > SSIZE_MAX)
       buffer_size = SSIZE_MAX;
     ret = gnutls_record_send (connection->tls_session,
@@ -386,25 +378,12 @@ MHD_send_on_connection_ (struct MHD_Connection 
*connection,
      * sent amount smaller than provided amount, as TLS
      * connections may break data into smaller parts for sending. */
 #endif /* EPOLL_SUPPORT */
-
-#if GNUTLS_VERSION_NUMBER >= 0x030109
-    if (! want_cork && have_cork)
-    {
-      int err = gnutls_record_uncork (connection->tls_session, 0);
-
-      if (0 > err)
-        return MHD_ERR_AGAIN_;
-      connection->sk_cork_on = false;
-    }
-#endif /* GNUTLS_VERSION_NUMBER >= 0x030109 */
+#endif /* HTTPS_SUPPORT  */
+    (void) 0; /* Mute compiler warning for non-TLS builds. */
   }
   else
-#endif /* HTTPS_SUPPORT  */
   {
     /* plaintext transmission */
-    bool new_cork_state;
-
-    pre_cork_setsockopt (connection, tls_conn, want_cork);
 #ifdef MHD_USE_MSG_MORE
     ret = send (s,
                 buffer,
@@ -440,10 +419,10 @@ MHD_send_on_connection_ (struct MHD_Connection 
*connection,
     else if (buffer_size > (size_t) ret)
       connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
 #endif /* EPOLL_SUPPORT */
-    new_cork_state = want_cork ? (buffer_size == (size_t) ret) : false;
-    post_cork_setsockopt (connection, tls_conn, new_cork_state);
-    connection->sk_cork_on = new_cork_state;
   }
+  post_cork_setsockopt (connection, tls_conn,
+                        (want_cork ? true :
+                         ((buffer_size == (size_t) ret) ? false : true)));
 
   return ret;
 }
@@ -488,19 +467,6 @@ MHD_send_on_connection2_ (struct MHD_Connection 
*connection,
                                    header,
                                    header_size,
                                    MHD_SSO_HDR_CORK);
-#if GNUTLS_VERSION_NUMBER >= 0x030109
-    if ( (header_size == (size_t) ret) &&
-         (0 == buffer_size) &&
-         connection->sk_cork_on)
-    {
-      int err;
-
-      err = gnutls_record_uncork (connection->tls_session, 0);
-      if (0 > err)
-        return ret;
-      connection->sk_cork_on = false;
-    }
-#endif /* GNUTLS_VERSION_NUMBER >= 0x030109 */
     return ret;
   }
 #endif
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index dc04cab5..489be718 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -894,53 +894,25 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh,
   case MHD_UPGRADE_ACTION_CORK_ON:
     if (connection->sk_cork_on)
       return MHD_YES;
-#ifdef HTTPS_SUPPORT
-    if (0 != (daemon->options & MHD_USE_TLS) )
+    if (0 !=
+        MHD_socket_cork_ (connection->socket_fd,
+                          true))
     {
-      gnutls_record_cork (connection->tls_session);
       connection->sk_cork_on = true;
       return MHD_YES;
     }
-    else
-#endif
-    {
-      if (0 !=
-          MHD_socket_cork_ (connection->socket_fd,
-                            true))
-      {
-        connection->sk_cork_on = true;
-        return MHD_YES;
-      }
-      return MHD_NO;
-    }
+    return MHD_NO;
   case MHD_UPGRADE_ACTION_CORK_OFF:
     if (! connection->sk_cork_on)
       return MHD_YES;
-#ifdef HTTPS_SUPPORT
-    if (0 != (daemon->options & MHD_USE_TLS) )
+    if (0 !=
+        MHD_socket_cork_ (connection->socket_fd,
+                          false))
     {
-      int err;
-
-      err = gnutls_record_uncork (connection->tls_session, 0);
-      if (0 > err)
-        return MHD_NO;
       connection->sk_cork_on = false;
       return MHD_YES;
     }
-    else
-#endif
-    {
-      if (! connection->sk_cork_on)
-        return MHD_YES;
-      if (0 !=
-          MHD_socket_cork_ (connection->socket_fd,
-                            false))
-      {
-        connection->sk_cork_on = false;
-        return MHD_YES;
-      }
-      return MHD_NO;
-    }
+    return MHD_NO;
   default:
     /* we don't understand this one */
     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]