[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 12/154: Add mhd_send to Makefile, more fixe
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 12/154: Add mhd_send to Makefile, more fixes in mhd_send. |
Date: |
Mon, 19 Aug 2019 10:15:24 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository libmicrohttpd.
commit 56676ae76dad5d8cb4f600b420f227d5efe0cce8
Author: ng0 <address@hidden>
AuthorDate: Sun Jun 23 14:54:52 2019 +0000
Add mhd_send to Makefile, more fixes in mhd_send.
---
src/microhttpd/Makefile.am | 1 +
src/microhttpd/mhd_send.c | 76 +++++++++++++++++++++++++++-------------------
2 files changed, 45 insertions(+), 32 deletions(-)
diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am
index 3fb65fe1..452e8971 100644
--- a/src/microhttpd/Makefile.am
+++ b/src/microhttpd/Makefile.am
@@ -62,6 +62,7 @@ libmicrohttpd_la_SOURCES = \
mhd_limits.h mhd_byteorder.h \
sysfdsetsize.c sysfdsetsize.h \
mhd_str.c mhd_str.h \
+ mhd_send.c \
mhd_assert.h \
mhd_sockets.c mhd_sockets.h \
mhd_itc.c mhd_itc.h mhd_itc_types.h \
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 6c080ccb..923fcae4 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -30,6 +30,13 @@
// TODO: sendfile() wrappers.
#include "platform.h"
+#include "internal.h"
+
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#endif
+#include <errno.h>
+
// NOTE: TCP_CORK == TCP_NOPUSH in FreeBSD.
// TCP_CORK is Linux.
@@ -98,6 +105,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
bool want_cork, have_cork, have_more;
/* The socket. */
MHD_socket s = connection->socket_fd;
+ int eno, ret, optval;
// new code...
/* Get socket options, change/set options if necessary. */
@@ -128,29 +136,29 @@ MHD_send_on_connection_ (struct MHD_Connection
*connection,
bool use_corknopush;
-#if HAVE_NODELAY
+#if TCP_NODELAY
use_corknopush = false;
-#elif HAVE_CORK
+#elif TCP_CORK
use_corknopush = true;
-#elif HAVE_NOPUSH
+#elif TCP_NOPUSH
use_corknopush = true;
#endif
-#if HAVE_CORK
+#if TCP_CORK
if (use_corknopush)
{
if (have_cork && ! want_cork)
{
- setsockopt (s, IPPROTO_TCP, TCP_CORK, 1, sizeof (int)) ||
- (setsockopt (s, IPPROTO_TCP, TCP_NODELAY, 1, sizeof (int)) &&connection
- ->sk_tcp_nodelay = true);
+ optval = 1;
+ setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &optval,
sizeof (&optval)) ||
+ (setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, &optval,
sizeof (&optval)) && (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.
}
}
-#elif HAVE_NOPUSH
+#elif TCP_NOPUSH
/*
* TCP_NOPUSH on FreeBSD is equal to cork on Linux, with the
* exception that we know that TCP_NOPUSH will definitely
@@ -160,40 +168,42 @@ MHD_send_on_connection_ (struct MHD_Connection
*connection,
{
if (have_cork && ! want_cork)
{
- setsockopt (s, IPPROTO_TCP, TCP_NOPUSH, 1, sizeof (int));
+ optval = 1;
+ setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NOPUSH, &optval,
sizeof (&optval));
// TODO: set corknopush to true here?
// connection->sk_tcp_cork_nopush_on = true;
}
}
#endif
-#if HAVE_NODELAY
+#if TCP_NODELAY
if (! use_corknopush)
{
if (! have_cork && want_cork)
{
+ optval = 0;
// setsockopt (nodelay-off);
- setsockopt (s, IPPROTO_TCP, TCP_NODELAY, 0, sizeof (int));
- connection->sk_tcp_nodelay = false;
+ setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, &optval,
sizeof (&optval));
+ connection->sk_tcp_nodelay_on = false;
}
// ...
}
#endif
- ret = send (s, buffer, buffer_size, want_cork ? MSG_MORE : 0);
+ ret = send (connection->socket_fd, buffer, buffer_size, want_cork ? MSG_MORE
: 0);
eno = errno;
-#if HAVE_CORK
+#if TCP_CORK
if (use_corknopush)
{
if (! have_cork && want_cork && ! have_more)
{
+ optval = 0;
//setsockopt (cork-off); // or nodelay off // + update
connection->sk_tcp_nodelay_on
- setsockopt (s, IPPROTO_TCP, TCP_CORK, 0, sizeof (int)) ||
- (setsockopt (s, IPPROTO_TCP, TCP_NODELAY, 0, sizeof (int)) &&connection
- ->sk_tcp_nodelay_on = false);
+ setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &optval,
sizeof (&optval)) ||
+ (setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, &optval,
sizeof (&optval)) && (connection->sk_tcp_nodelay_on = false));
}
}
-#elif HAVE_NOPUSH
+#elif TCP_NOPUSH
// We don't have MSG_MORE.
if (use_corknopush)
{
@@ -201,17 +211,18 @@ MHD_send_on_connection_ (struct MHD_Connection
*connection,
}
#endif
-#if HAVE_NODELAY
+#if TCP_NODELAY
if (! use_corknopush)
{
if (have_cork && ! want_cork)
{
+ optval = 1;
// setsockopt (nodelay - on);
- setsockopt (s,
+ setsockopt (connection->socket_fd,
IPPROTO_TCP,
TCP_NODELAY,
- 1,
- sizeof (int)) &&connection->sk_tcp_nodelay_on = true;
+ &optval,
+ sizeof (&optval)) && (connection->sk_tcp_nodelay_on = true);
}
// ...
}
@@ -239,26 +250,26 @@ MHD_send_on_connection2_ (struct MHD_Connection
*connection,
#if HAVE_WRITEV
MHD_socket s = connection->socket_fd;
bool have_cork, have_more;
- int iovcnt;
+ int iovcnt, optval;
struct iovec vector[2];
have_cork = ! connection->sk_tcp_nodelay_on;
-#if HAVE_NODELAY
+#if TCP_NODELAY
use_corknopush = false;
-#elif HAVE_CORK
+#elif TCP_CORK
use_corknopush = true;
-#elif HAVE_NOPUSH
+#elif TCP_NOPUSH
use_corknopush = true;
#endif
-#if HAVE_NODELAY
+#if TCP_NODELAY
if (! use_corknopush)
{
if (! have_cork && want_cork)
{
+ optval = 0;
// setsockopt (nodelay-off);
- setsockopt (s, IPPROTO_TCP, TCP_NODELAY, 0, sizeof (int));
- connection->sk_tcp_nodelay = false;
+ setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_NODELAY, &optval,
sizeof (&optval)) && (connection->sk_tcp_nodelay = false);
}
// ...
}
@@ -269,17 +280,18 @@ MHD_send_on_connection2_ (struct MHD_Connection
*connection,
vector[1].iov_base = buffer;
vector[1].iov_len = strlen (buffer);
iovcnt = sizeof (vector) / sizeof (struct iovec);
- ret = writev (s, vector, iovcnt);
-#if HAVE_CORK
+ ret = writev (connection->socket_fd, vector, iovcnt);
+#if TCP_CORK
{
int eno;
eno = errno;
if ((ret == header_len + buffer_len) && have_cork)
{
+ optval = 0;
// response complete, definitely uncork!
// setsockopt (cork-off);
- setsockopt (s, IPPROTO_TCP, TCP_CORK, 0, sizeof (int));
+ setsockopt (connection->socket_fd, IPPROTO_TCP, TCP_CORK, &optval,
sizeof (&optval));
// connection->sk_tcp_cork_nopush_on = true;
}
errno = eno;
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [libmicrohttpd] 04/154: mhd_send: minor typo, (continued)
- [GNUnet-SVN] [libmicrohttpd] 04/154: mhd_send: minor typo, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 02/154: mhd_send, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 03/154: mhd_send: fix switch., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 05/154: mhd_send: remove unnecessary comments., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 08/154: fix syntax, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 06/154: mhd_send: Move return_bytes related code into the right place., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 07/154: provide example for use of getsockopt to get MSS, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 09/154: startingpoint, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 14/154: mhd_send.c: Try to guess the right branch to close., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 17/154: mhd_send: start adding logic from send_param_adapter., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 12/154: Add mhd_send to Makefile, more fixes in mhd_send.,
gnunet <=
- [GNUnet-SVN] [libmicrohttpd] 20/154: mhd_send.c: variable declarations (style)., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 19/154: adjust, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 11/154: restructure a bit to reuse existing send function, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 23/154: mhd_send: change send_tls_adapter() to non-static and export its prototype, use it in mhd_send.c, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 22/154: mhd_send.c: call send_tls_adapter() when TLS is used., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 24/154: move TLS branch to right position, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 37/154: flatten if statements, add initial TCP_NOPUSH to MHD_send_on_connection2_, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 39/154: indent, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 33/154: replace connection->send_cls(), gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 13/154: mhd_send.c: fix compiler error about MSG_MORE when MSG_MORE is undefined., gnunet, 2019/08/19