commit f2f1d659156666b61c2f4198c88a3ceaf88ce9f5
parent 5cbdec21db40fa53590dff53c2341e825567e67f
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Sun, 1 Oct 2017 21:38:15 +0300
Improved 5ac497e212525a12209a3c1007a129ae85055cf7
Diffstat:
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
@@ -239,6 +239,7 @@ sendfile_adapter (struct MHD_Connection *connection)
off64_t offset;
#endif /* HAVE_SENDFILE64 */
const bool used_thr_p_c = (0 != (connection->daemon->options & MHD_USE_THREAD_PER_CONNECTION));
+ const size_t chunk_size = used_thr_p_c ? 0x200000 : 0x20000;
size_t send_size;
mhd_assert (MHD_resp_sender_sendfile == connection->resp_sender);
@@ -246,10 +247,7 @@ sendfile_adapter (struct MHD_Connection *connection)
left = connection->response->total_size - connection->response_write_position;
/* Do not allow system to stick sending on single fast connection:
* use 128KiB chunks (2MiB for thread-per-connection). */
- if (!used_thr_p_c)
- send_size = (left > 0x20000) ? 0x20000 : (size_t) left;
- else
- send_size = (left > 0x200000) ? 0x200000 : (size_t) left;
+ send_size = (left > chunk_size) ? chunk_size : (size_t) left;
#ifndef HAVE_SENDFILE64
if ((uint64_t)OFF_T_MAX < offsetu64)
{ /* Retry to send with standard 'send()'. */