gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] 73/154: Start reworking into generic setsoc


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 73/154: Start reworking into generic setsockopt wrapper.
Date: Mon, 19 Aug 2019 10:16:25 +0200

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

ng0 pushed a commit to branch master
in repository libmicrohttpd.

commit e072dbba655ff8ee52ecd00631b4732334320c93
Author: ng0 <address@hidden>
AuthorDate: Wed Jul 24 15:49:59 2019 +0000

    Start reworking into generic setsockopt wrapper.
---
 src/microhttpd/mhd_send.c | 35 +++++++++++++++++++++++------------
 src/microhttpd/mhd_send.h |  6 ++++++
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index b235c6ff..47ff09cc 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -63,8 +63,26 @@ MHD_send_socket_state_nodelay_ (struct MHD_Connection 
*connection,
 #endif
 }
 
+void
+MHD_setsockopt_ (struct MHD_Connection *connection,
+                 int optname,
+                 bool value,
+                 bool state_store)
+{
+  const MHD_SCKT_OPT_BOOL_ state_val = value ? 1 : 0;
+
+  if (0 == setsockopt (connection->socket_fd,
+                       IPPROTO_TCP,
+                       optname,
+                       (const void *) &state_val,
+                       sizeof (state_val)))
+    {
+      connection->sk_tcp_nodelay_on = state_store;
+    }
+}
+
 /**
- * Set TCP_NODELAY flag on socket and save the
+ * Set TCP_NOCORK or TCP_NODELAY flag on socket and save the
  * #sk_tcp_nodelay_on state.
  *
  * @param connection the MHD_Connection structure
@@ -241,7 +259,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
 #if TCP_NODELAY
   if ((! using_tls) && (! use_corknopush) && (! have_cork && want_cork))
     {
-      MHD_send_socket_state_nodelay_ (connection, false);
+      MHD_setsockopt_ (connection, TCP_NODELAY, false, false);
     }
 #endif
 
@@ -348,7 +366,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
 #if TCP_NODELAY
   if ((! using_tls) && (! use_corknopush) && (have_cork && ! want_cork))
     {
-      MHD_send_socket_state_nodelay_ (connection, true);
+      MHD_setsockopt_ (connection, TCP_NODELAY, true, true);
     }
 #endif
 
@@ -401,7 +419,7 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
 #if TCP_NODELAY
   if ((! use_corknopush) && (! have_cork && want_cork))
     {
-      MHD_send_socket_state_nodelay_ (connection, false);
+      MHD_setsockopt_(connection, TCP_NODELAY, false, false);
     }
 #endif
 
@@ -429,14 +447,7 @@ MHD_send_on_connection2_ (struct MHD_Connection 
*connection,
     if ((ret == header_len + buffer_len) && have_cork)
       {
         // Response complete, definitely uncork!
-        if (0 == setsockopt (s,
-                             IPPROTO_TCP,
-                             TCP_CORK,
-                             (const void *) &off_val,
-                             sizeof (off_val)))
-          {
-            connection->sk_tcp_nodelay_on = true;
-          }
+        MHD_setsockopt_(connection, TCP_CORK, false, true);
       }
     errno = eno;
   }
diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h
index c01d9357..78edc9de 100644
--- a/src/microhttpd/mhd_send.h
+++ b/src/microhttpd/mhd_send.h
@@ -78,6 +78,12 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection,
 ssize_t
 MHD_sendfile_on_connection_ (struct MHD_Connection *connection);
 
+void
+MHD_setsockopt_ (struct MHD_Connection *connection,
+                 int optname,
+                 bool value,
+                 bool state_store);
+
 void
 MHD_send_socket_state_nopush_ (struct MHD_Connection *connection,
                                bool value,

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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