[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 09/10: try_ready_chunked_body(): remove use
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 09/10: try_ready_chunked_body(): remove useless loop, use know free memory size instead of guessing |
Date: |
Mon, 17 Jun 2019 20:35:52 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit a275ae63537380c41cfe145ec4e00dd796e0992c
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Sun Jun 16 21:55:53 2019 +0300
try_ready_chunked_body(): remove useless loop, use know free memory
size instead of guessing
---
src/microhttpd/connection.c | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 525e6a8c..a97844c2 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1342,9 +1342,7 @@ static int
try_ready_chunked_body (struct MHD_Connection *connection)
{
ssize_t ret;
- char *buf;
struct MHD_Response *response;
- size_t size;
char cbuf[10]; /* 10: max strlen of "%x\r\n" */
int cblen;
@@ -1353,28 +1351,26 @@ try_ready_chunked_body (struct MHD_Connection
*connection)
return MHD_YES;
if (0 == connection->write_buffer_size)
{
- size = MHD_MIN (connection->daemon->pool_size,
- 2 * (0xFFFFFF + sizeof(cbuf) + 2));
- do
+ size_t size;
+
+ size = MHD_pool_get_free (connection->pool);
+ if (size < 128)
{
- size /= 2;
- if (size < 128)
- {
#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
- MHD_mutex_unlock_chk_ (&response->mutex);
+ MHD_mutex_unlock_chk_ (&response->mutex);
#endif
- /* not enough memory */
- CONNECTION_CLOSE_ERROR (connection,
- _("Closing connection (out of
memory)\n"));
- return MHD_NO;
- }
- buf = MHD_pool_allocate (connection->pool,
- size,
- false);
+ /* not enough memory */
+ CONNECTION_CLOSE_ERROR (connection,
+ _("Closing connection (out of memory)\n"));
+ return MHD_NO;
}
- while (NULL == buf);
+ if ( (2 * (0xFFFFFF + sizeof(cbuf) + 2)) < size)
+ size = 2 * (0xFFFFFF + sizeof(cbuf) + 2);
+ connection->write_buffer = MHD_pool_allocate (connection->pool,
+ size,
+ false);
+ mhd_assert (NULL != connection->write_buffer);
connection->write_buffer_size = size;
- connection->write_buffer = buf;
}
if (0 == response->total_size)
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [libmicrohttpd] branch master updated (d12ed49f -> 55dc42e6), gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 04/10: memorypool: comments minor improvements, gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 05/10: MHD_pool_reallocate(): never allocate additional buffer when shrinking, gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 07/10: transmit_error_response(): discard read buffer to free space for error response, gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 09/10: try_ready_chunked_body(): remove useless loop, use know free memory size instead of guessing,
gnunet <=
- [GNUnet-SVN] [libmicrohttpd] 01/10: memorypool: fixed MHD_pool_reset(), gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 03/10: memorypool: re-commit memory on W32 when resetting pool, gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 06/10: test_long_header: use power of two for size to properly test allocations, test various buffer sizes, gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 02/10: memorypool: round mmap allocation for page size, gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 10/10: Optimised read buffer allocation, gnunet, 2019/06/17
- [GNUnet-SVN] [libmicrohttpd] 08/10: process_request_body(): do not move data if nothing was processed, gnunet, 2019/06/17