libmicrohttpd

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

commit 2ccc281a69a056bc4fe72b829604037fa3792bfc
parent 9ca0b36ab0de26a0e2564f27fa25b6680965c196
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri,  4 Jun 2021 15:22:22 +0300

connection: handle large read-ahead situation

Diffstat:
Msrc/microhttpd/connection.c | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -3887,6 +3887,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) else { /* can try to keep-alive */ + size_t new_read_buf_size; connection->version = NULL; connection->http_ver = MHD_HTTP_VER_UNKNOWN; @@ -3897,13 +3898,16 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) connection->keepalive = MHD_CONN_KEEPALIVE_UNKOWN; /* Reset the read buffer to the starting size, preserving the bytes we have already read. */ + if (connection->read_buffer_offset > connection->daemon->pool_size / 2) + new_read_buf_size = connection->read_buffer_offset; + else + new_read_buf_size = connection->daemon->pool_size / 2; connection->read_buffer = MHD_pool_reset (connection->pool, connection->read_buffer, connection->read_buffer_offset, - connection->daemon->pool_size / 2); - connection->read_buffer_size - = connection->daemon->pool_size / 2; + new_read_buf_size); + connection->read_buffer_size = new_read_buf_size; } connection->client_context = NULL; connection->continue_message_write_offset = 0;