aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-06-04 15:22:22 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-06-04 15:22:22 +0300
commit2ccc281a69a056bc4fe72b829604037fa3792bfc (patch)
tree3c9db8ef8933a01d0d855f7c0602519507ebb1e1
parent9ca0b36ab0de26a0e2564f27fa25b6680965c196 (diff)
downloadlibmicrohttpd-2ccc281a69a056bc4fe72b829604037fa3792bfc.tar.gz
libmicrohttpd-2ccc281a69a056bc4fe72b829604037fa3792bfc.zip
connection: handle large read-ahead situation
-rw-r--r--src/microhttpd/connection.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 321952eb..5038b378 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3887,6 +3887,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3887 else 3887 else
3888 { 3888 {
3889 /* can try to keep-alive */ 3889 /* can try to keep-alive */
3890 size_t new_read_buf_size;
3890 3891
3891 connection->version = NULL; 3892 connection->version = NULL;
3892 connection->http_ver = MHD_HTTP_VER_UNKNOWN; 3893 connection->http_ver = MHD_HTTP_VER_UNKNOWN;
@@ -3897,13 +3898,16 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
3897 connection->keepalive = MHD_CONN_KEEPALIVE_UNKOWN; 3898 connection->keepalive = MHD_CONN_KEEPALIVE_UNKOWN;
3898 /* Reset the read buffer to the starting size, 3899 /* Reset the read buffer to the starting size,
3899 preserving the bytes we have already read. */ 3900 preserving the bytes we have already read. */
3901 if (connection->read_buffer_offset > connection->daemon->pool_size / 2)
3902 new_read_buf_size = connection->read_buffer_offset;
3903 else
3904 new_read_buf_size = connection->daemon->pool_size / 2;
3900 connection->read_buffer 3905 connection->read_buffer
3901 = MHD_pool_reset (connection->pool, 3906 = MHD_pool_reset (connection->pool,
3902 connection->read_buffer, 3907 connection->read_buffer,
3903 connection->read_buffer_offset, 3908 connection->read_buffer_offset,
3904 connection->daemon->pool_size / 2); 3909 new_read_buf_size);
3905 connection->read_buffer_size 3910 connection->read_buffer_size = new_read_buf_size;
3906 = connection->daemon->pool_size / 2;
3907 } 3911 }
3908 connection->client_context = NULL; 3912 connection->client_context = NULL;
3909 connection->continue_message_write_offset = 0; 3913 connection->continue_message_write_offset = 0;