[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 96/154: simplify
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 96/154: simplify |
Date: |
Mon, 19 Aug 2019 10:16:48 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository libmicrohttpd.
commit 68721add43db814d1bc69e6901684177c549dbbd
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Jul 25 20:23:57 2019 +0200
simplify
---
src/microhttpd/internal.h | 14 ++++----------
src/microhttpd/mhd_send.c | 38 +++++++++++++++++++++++---------------
2 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 1f5aeaf3..ac43d819 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -871,19 +871,13 @@ struct MHD_Connection
/**
* true if #socket_fd is non-blocking, false otherwise.
*/
- bool sk_nonblck;
+ bool sk_nonblck; // FIXME: hopefully dead?
/**
- * Indicate whether connection socket has TCP_NODELAY turned on / Nagle’s
algorithm turned off.
- * TCP_NODELAY should not be turned on when TCP_CORK/TCP_NOPUSH is turned
off.
+ * Indicate whether connection socket has TCP_CORK / Nagle’s algorithm
turned on/off
+ * on this socket.
*/
- bool sk_tcp_nodelay_on;
-
- /**
- * Indicate whether connection socket has TCP_CORK/TCP_NOPUSH turned on.
- * TCP_CORK/TCP_NOPUSH should not be turned on when TCP_NODELAY is turned
off.
- */
- bool sk_tcp_cork_nopush_on;
+ bool sk_cork_on;
/**
* Has this socket been closed for reading (i.e. other side closed
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 111fdcfe..656a4b5c 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -47,7 +47,19 @@ post_cork_setsockopt (struct MHD_Connection *connection,
const MHD_SCKT_OPT_BOOL_ off_val = 0;
const MHD_SCKT_OPT_BOOL_ on_val = 1;
+ if (connection->sk_cork_on == want_cork)
+ {
+ /* nothing to do, success! */
+ return 0;
+ }
+ ret = -1;
#if TCP_CORK
+ if (! want_cork)
+ ret = setsockopt (connection->socket_fd,
+ IPPROTO_TCP,
+ TCP_CORK,
+ &off_val,
+ sizeof (off_val));
#elif TCP_NODELAY
ret = setsockopt (connection->socket_fd,
IPPROTO_TCP,
@@ -60,12 +72,10 @@ post_cork_setsockopt (struct MHD_Connection *connection,
TCP_NOPUSH,
(const void *) &on_val,
sizeof (on_val));
-#else
- ret = -1;
#endif
if (0 == ret)
{
- connection->sk_tcp_nodelay_on = false;
+ connection->sk_cork_on = want_cork;
}
return ret;
}
@@ -80,18 +90,20 @@ pre_cork_setsockopt (struct MHD_Connection *connection,
const MHD_SCKT_OPT_BOOL_ on_val = 1;
// if sk_tcp_nodelay_on is already what we pass in, return.
- if (connection->sk_tcp_nodelay_on == want_cork)
+ if (connection->sk_cork_on == want_cork)
{
- return 0; // return type error
+ /* nothing to do, success! */
+ return 0;
}
ret = -1;
#if TCP_CORK
- ret = setsockopt (connection->socket_fd,
- IPPROTO_TCP,
- TCP_CORK,
- (const void *) want_cork ? &on_val : &off_val,
- sizeof (on_val));
+ if (want_cork)
+ ret = setsockopt (connection->socket_fd,
+ IPPROTO_TCP,
+ TCP_CORK,
+ (const void *) &on_val,
+ sizeof (on_val));
#elif TCP_NODELAY
ret = setsockopt (connection->socket_fd,
IPPROTO_TCP,
@@ -108,11 +120,7 @@ pre_cork_setsockopt (struct MHD_Connection *connection,
if (0 == ret)
{
-#if TCP_CORK || TCP_NODELAY
- connection->sk_tcp_nodelay_on = true;
-#elif TCP_NOPUSH
- connection->sk_tcp_nodelay_on = false;
-#endif
+ connection->sk_cork_on = want_cork;
}
return ret;
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [libmicrohttpd] 76/154: indent, (continued)
- [GNUnet-SVN] [libmicrohttpd] 76/154: indent, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 101/154: don't cast, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 87/154: remove code, add prototype to mhd_send.h, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 117/154: ., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 125/154: Merge remote-tracking branch 'origin/master' into dev/ng0/gsoc2019, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 129/154: swap _NODELAY and _NOPUSH, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 118/154: Add MSG_MORE detection., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 123/154: fix behavior on NetBSD, use the right sizeof., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 106/154: switch post/pre function definition to a logical appearance in the file (pre before post), purely for orientation., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 110/154: check before post_ function if we need to set want_cork to false, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 96/154: simplify,
gnunet <=
- [GNUnet-SVN] [libmicrohttpd] 113/154: _len -> _size, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 147/154: Merge remote-tracking branch 'origin/master' into dev/ng0/gsoc2019, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 149/154: connection.c: remove 2 more calls of dead code., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 122/154: partial fix to sendmsg code, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 134/154: handle TLS case in send_on_connectin2, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 128/154: TCP_NOPUSH, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 141/154: Document MHD_UPGRADE_ACTION_CORK_ON and HD_UPGRADE_ACTION_CORK_OFF., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 145/154: remove more code., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 143/154: fix a couple of fixmes: add log messages., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 137/154: remove obsolete OLD_SOCK if'd blocks., gnunet, 2019/08/19