libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 7f6084e6306b1a35a62a496e8335b41825a6b22d
parent ad8a3e3fde50de45d075dbb6971ed52003200ee2
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 29 Nov 2020 18:18:10 +0300

enum MHD_SendSocketOptions: renamed values for clarity.
The most important is to push the last peace of response data.
Without pushing data, MHD is limited to 5 requests/second
(on typical OS) with stay-alive clients.

Diffstat:
Msrc/microhttpd/connection.c | 10+++++-----
Msrc/microhttpd/mhd_send.c | 4++--
Msrc/microhttpd/mhd_send.h | 13+++++++++----
3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -2884,7 +2884,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) [connection->continue_message_write_offset], MHD_STATICSTR_LEN_ (HTTP_100_CONTINUE) - connection->continue_message_write_offset, - MHD_SSO_NO_CORK); + MHD_SSO_PUSH_DATA); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) @@ -2927,7 +2927,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) &connection->write_buffer [connection->write_buffer_send_offset], wb_ready, - MHD_SSO_MAY_CORK); + MHD_SSO_PREFER_BUFF); } else { @@ -3004,7 +3004,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) [(size_t) data_write_offset], response->data_size - (size_t) data_write_offset, - MHD_SSO_NO_CORK); + MHD_SSO_PUSH_DATA); #if _MHD_DEBUG_SEND_DATA if (ret > 0) fprintf (stderr, @@ -3048,7 +3048,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) [connection->write_buffer_send_offset], connection->write_buffer_append_offset - connection->write_buffer_send_offset, - MHD_SSO_NO_CORK); + MHD_SSO_PUSH_DATA); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) @@ -3078,7 +3078,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection) [connection->write_buffer_send_offset], connection->write_buffer_append_offset - connection->write_buffer_send_offset, - MHD_SSO_NO_CORK); + MHD_SSO_PUSH_DATA); if (ret < 0) { if (MHD_ERR_AGAIN_ == ret) diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c @@ -329,11 +329,11 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, switch (options) { /* No corking */ - case MHD_SSO_NO_CORK: + case MHD_SSO_PUSH_DATA: want_cork = false; break; /* Do corking, consider MSG_MORE instead if available. */ - case MHD_SSO_MAY_CORK: + case MHD_SSO_PREFER_BUFF: want_cork = true; break; /* Cork the header. */ diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h @@ -54,13 +54,18 @@ MHD_send_init_static_vars_ (void); enum MHD_SendSocketOptions { /** - * definitely no corking (use NODELAY, or explicitly disable cork) + * Need to flush buffers after send to push data to the network. + * Used to avoid delay before the last part of data (which is usually + * incomplete IP packet / MSS) is pushed by kernel to the network. */ - MHD_SSO_NO_CORK = 0, + MHD_SSO_PUSH_DATA = 0, /** - * should enable corking (use MSG_MORE, or explicitly enable cork) + * Buffer data if possible. + * If more response data is to be sent than try to buffer data in + * the local buffers so kernel able to send complete packets with + * lower overhead. */ - MHD_SSO_MAY_CORK = 1, + MHD_SSO_PREFER_BUFF = 1, /** * consider tcpi_snd_mss and consider not corking for the header * part if the size of the header is close to the MSS.