gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] 33/154: replace connection->send_cls()


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 33/154: replace connection->send_cls()
Date: Mon, 19 Aug 2019 10:15:45 +0200

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

ng0 pushed a commit to branch master
in repository libmicrohttpd.

commit b854bbba20255f77a681a4020191dc8b42e23049
Author: ng0 <address@hidden>
AuthorDate: Fri Jul 19 20:39:19 2019 +0000

    replace connection->send_cls()
---
 src/microhttpd/connection.c | 58 +++++++++++++++++++++++++--------------------
 src/microhttpd/mhd_send.c   | 53 ++++++++++++++++++-----------------------
 2 files changed, 55 insertions(+), 56 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 877f514b..4d93acee 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -53,7 +53,7 @@
 /* For FreeBSD version identification */
 #include <sys/param.h>
 #endif /* HAVE_SYS_PARAM_H */
-
+#include "mhd_send.h"
 
 /**
  * Message to transmit when http 1.1 request is received
@@ -3303,11 +3303,12 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
     case MHD_CONNECTION_HEADERS_PROCESSED:
       return;
     case MHD_CONNECTION_CONTINUE_SENDING:
-      ret = connection->send_cls (connection,
-                                  &HTTP_100_CONTINUE
-                                  [connection->continue_message_write_offset],
-                                  MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) -
-                                  connection->continue_message_write_offset);
+      ret = MHD_send_on_connection_ (connection,
+                                     &HTTP_100_CONTINUE
+                                     
[connection->continue_message_write_offset],
+                                     MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) -
+                                     connection->continue_message_write_offset,
+                                     MHD_SSO_NO_CORK);
       if (ret < 0)
         {
           if (MHD_ERR_AGAIN_ == ret)
@@ -3337,11 +3338,13 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
       mhd_assert (0);
       return;
     case MHD_CONNECTION_HEADERS_SENDING:
-      ret = connection->send_cls (connection,
-                                  &connection->write_buffer
-                                  [connection->write_buffer_send_offset],
-                                  connection->write_buffer_append_offset -
-                                    connection->write_buffer_send_offset);
+      /* TODO: Maybe use MHD_send_on_connection2_()?  */
+      ret = MHD_send_on_connection_ (connection,
+                                     &connection->write_buffer
+                                     [connection->write_buffer_send_offset],
+                                     connection->write_buffer_append_offset -
+                                     connection->write_buffer_send_offset,
+                                     MHD_SSO_MAY_CORK);
       if (ret < 0)
         {
           if (MHD_ERR_AGAIN_ == ret)
@@ -3389,11 +3392,12 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
                                   - response->data_start;
               if (data_write_offset > (uint64_t)SIZE_MAX)
                 MHD_PANIC (_("Data offset exceeds limit"));
-              ret = connection->send_cls (connection,
-                                          &response->data
-                                          [(size_t)data_write_offset],
-                                          response->data_size -
-                                          (size_t)data_write_offset);
+              ret = MHD_send_on_connection_ (connection,
+                                             &response->data
+                                             [(size_t)data_write_offset],
+                                             response->data_size -
+                                             (size_t)data_write_offset,
+                                             MHD_SSO_NO_CORK);
 #if DEBUG_SEND_DATA
               if (ret > 0)
                 fprintf (stderr,
@@ -3432,11 +3436,12 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
       mhd_assert (0);
       return;
     case MHD_CONNECTION_CHUNKED_BODY_READY:
-      ret = connection->send_cls (connection,
-                                  &connection->write_buffer
-                                  [connection->write_buffer_send_offset],
-                                  connection->write_buffer_append_offset -
-                                    connection->write_buffer_send_offset);
+      ret = MHD_send_on_connection_ (connection,
+                                     &connection->write_buffer
+                                     [connection->write_buffer_send_offset],
+                                     connection->write_buffer_append_offset -
+                                     connection->write_buffer_send_offset,
+                                     MHD_SSO_NO_CORK);
       if (ret < 0)
         {
           if (MHD_ERR_AGAIN_ == ret)
@@ -3460,11 +3465,12 @@ MHD_connection_handle_write (struct MHD_Connection 
*connection)
       mhd_assert (0);
       return;
     case MHD_CONNECTION_FOOTERS_SENDING:
-      ret = connection->send_cls (connection,
-                                  &connection->write_buffer
-                                  [connection->write_buffer_send_offset],
-                                  connection->write_buffer_append_offset -
-                                    connection->write_buffer_send_offset);
+      ret = MHD_send_on_connection_ (connection,
+                                     &connection->write_buffer
+                                     [connection->write_buffer_send_offset],
+                                     connection->write_buffer_append_offset -
+                                     connection->write_buffer_send_offset,
+                                     MHD_SSO_HDR_CORK);
       if (ret < 0)
         {
           if (MHD_ERR_AGAIN_ == ret)
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 18fa617f..36007929 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -24,37 +24,33 @@
  * @author ng0 <address@hidden>
  */
 
-// to be used in: send_param_adapter, MHD_send_
-// and every place where sendfile(), sendfile64(), setsockopt()
-// are used.
-// TODO: sendfile() wrappers.
+/* TODO: sendfile() wrappers. */
 
 #include "mhd_send.h"
 
-// NOTE: TCP_CORK == TCP_NOPUSH in FreeBSD.
-//       TCP_CORK is Linux.
-//       TCP_CORK/TCP_NOPUSH: don't send out partial frames.
-//       TCP_NODELAY: disable Nagle (aggregate data based on
-//       buffer pressur).
-// TODO: It is possible that Solaris/SunOS depending on
-// the linked library needs a different setsockopt usage:
-// 
https://stackoverflow.com/questions/48670299/setsockopt-usage-in-linux-and-solaris-invalid-argument-in-solaris
-
 /*
- * 
https://svnweb.freebsd.org/base/head/sys/netinet/tcp_usrreq.c?view=markup&pathrev=346360
+ * NOTE:
+ * It might be possible that Solaris/SunOS depending on the linked library 
needs a different setsockopt usage:
+ * 
https://stackoverflow.com/questions/48670299/setsockopt-usage-in-linux-and-solaris-invalid-argument-in-solaris
+ *
  * Approximately in 2007 work began to make TCP_NOPUSH in FreeBSD
  * behave like TCP_CORK in Linux. Thus we define them to be one and
  * the same, which again could be platform dependent (NetBSD does
  * (so far) only provide a FreeBSD compatibility here, for example).
  * Since we only deal with IPPROTO_TCP flags in this file and nowhere
  * else, we don't have to move this elsewhere for now.
-*/
-/*
-#if ! defined(TCP_CORK) && defined(TCP_NOPUSH)
-#define TCP_CORK TCP_NOPUSH
-#endif
-*/
-/*
+ * 
https://svnweb.freebsd.org/base/head/sys/netinet/tcp_usrreq.c?view=markup&pathrev=346360
+ *
+ * verbose notes, remove when done:
+ * TCP_CORK == TCP_NOPUSH in FreeBSD.
+ * TCP_CORK is Linux.
+ * TCP_CORK/TCP_NOPUSH: don't send out partial frames.
+ * TCP_NODELAY: disable Nagle (aggregate data based on buffer pressur)
+ *
+ * to be used in: send_param_adapter, MHD_send_
+ * and every place where sendfile(), sendfile64(), setsockopt() are used.
+ *
+ * Fix this up in doxygen style:
  * -- OBJECTIVE:
  * connection: use member 'socket', and remember the
  * current state of the socket-options (cork/nocork/nodelay/whatever)
@@ -152,17 +148,14 @@ MHD_send_on_connection_ (struct MHD_Connection 
*connection,
       {
         connection->sk_tcp_nodelay = true;
       }
-      //setsockopt (cork-on); // or nodelay on // + update 
connection->sk_tcp_nodelay_on
-      // When we have CORK, we can have NODELAY on the same system,
-      // at least since Linux 2.2 and both can be combined since
-      // Linux 2.5.71. See tcp(7). No other system in 2019-06 has TCP_CORK.
+      /* When we have CORK, we can have NODELAY on the same system,
+       * at least since Linux 2.2 and both can be combined since
+       * Linux 2.5.71. See tcp(7). No other system in 2019-06 has TCP_CORK. */
     }
 #elif TCP_NOPUSH
-  /*
- * TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the
- * exception that we know that TCP_NOPUSH will definitely
- * exist and we can disregard TCP_NODELAY unless requested.
- */
+  /* TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the
+   * exception that we know that TCP_NOPUSH will definitely
+   * exist and we can disregard TCP_NODELAY unless requested. */
   if ((use_corknopush) && (have_cork && ! want_cork))
     {
       if (0 == setsockopt (connection->socket_fd,

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



reply via email to

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