[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 135/154: add ways for application to contro
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 135/154: add ways for application to control corking for upgraded sockets |
Date: |
Mon, 19 Aug 2019 10:17:27 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository libmicrohttpd.
commit 26368ac8f1a32f49eaffae77abcfc595c62802bd
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Aug 1 21:40:47 2019 +0200
add ways for application to control corking for upgraded sockets
---
src/include/microhttpd.h | 12 +++++++++++-
src/microhttpd/connection.c | 2 +-
src/microhttpd/response.c | 38 ++++++++++++++++++++++++++++++++++++++
src/microhttpd/test_upgrade.c | 2 ++
4 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index c2fc90a4..00288696 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -3132,7 +3132,17 @@ enum MHD_UpgradeAction
*
* Takes no extra arguments.
*/
- MHD_UPGRADE_ACTION_CLOSE = 0
+ MHD_UPGRADE_ACTION_CLOSE = 0,
+
+ /**
+ * Enable CORKing on the underlying socket.
+ */
+ MHD_UPGRADE_ACTION_CORK_ON = 1,
+
+ /**
+ * Disable CORKing on the underlying socket.
+ */
+ MHD_UPGRADE_ACTION_CORK_OFF = 2
};
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 67ff6017..c2add01a 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3181,7 +3181,7 @@ MHD_connection_handle_write (struct MHD_Connection
*connection)
return;
case MHD_CONNECTION_HEADERS_SENDING:
{
- const size_t wb_ready =connection->write_buffer_append_offset -
+ const size_t wb_ready = connection->write_buffer_append_offset -
connection->write_buffer_send_offset;
/* if the response body is not available, we use
MHD_send_on_connection_() */
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 7b98a45c..65ea7b09 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -825,6 +825,44 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh,
* be moved to cleanup list by MHD_resume_connection(). */
MHD_resume_connection (connection);
return MHD_YES;
+ case MHD_UPGRADE_ACTION_CORK_ON:
+ if (connection->sk_cork_on)
+ return MHD_YES;
+#ifdef HTTPS_SUPPORT
+ if (0 != (daemon->options & MHD_USE_TLS) )
+ {
+ gnutls_record_cork (connection->tls_session);
+ connection->sk_cork_on = true;
+ return MHD_YES;
+ }
+ else
+#else
+ {
+ if (0 ==
+ MHD_socket_cork_ (connection->socket_fd,
+ true))
+ connection->sk_cork_on = true;
+ }
+#endif
+ case MHD_UPGRADE_ACTION_CORK_OFF:
+ if (! connection->sk_cork_on)
+ return MHD_YES;
+#ifdef HTTPS_SUPPORT
+ if (0 != (daemon->options & MHD_USE_TLS) )
+ {
+ gnutls_record_uncork (connection->tls_session, 0);
+ connection->sk_cork_on = false;
+ return MHD_YES;
+ }
+ else
+#else
+ {
+ if (0 ==
+ MHD_socket_cork_ (connection->socket_fd,
+ false))
+ connection->sk_cork_on = false;
+ }
+#endif
default:
/* we don't understand this one */
return MHD_NO;
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index caf12e61..9135187c 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -685,6 +685,8 @@ run_usock (void *cls)
{
struct MHD_UpgradeResponseHandle *urh = cls;
+ MHD_upgrade_action (urh,
+ MHD_UPGRADE_ACTION_CORK_OFF);
send_all (usock,
"Hello");
recv_all (usock,
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [libmicrohttpd] 124/154: mhd_send commented,, (continued)
- [GNUnet-SVN] [libmicrohttpd] 124/154: mhd_send commented,, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 127/154: remove commentblock, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 112/154: configure.ac: define a check for HAVE_SENDMSG, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 121/154: MSG_MORE fix, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 115/154: gitignore build-aux., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 132/154: reduce variable scope, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 131/154: toggle Naggle if and only if corking is not possible by other means, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 126/154: fixes, comments, FIXMEs, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 133/154: properly handle return value from send_on_connection2, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 130/154: always set nodelay, except if we cannot cork, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 135/154: add ways for application to control corking for upgraded sockets,
gnunet <=
- [GNUnet-SVN] [libmicrohttpd] 138/154: mhd_send: fix failure to build, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 136/154: do it in both tests, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 139/154: Rename senfile_adapter to MHD_send_sendfile_ and remove duplicate prototype., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 151/154: mhd_send.c: for now, let EINVAL and EBADF fail hard., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 152/154: connection.c: remove dead code., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 154/154: Revert "connection.c: remove dead code.", gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 114/154: writev check, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 144/154: connection.c: remove dead code, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 153/154: Revert "mhd_send.c: for now, let EINVAL and EBADF fail hard.", gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 146/154: remove code, gnunet, 2019/08/19