[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 03/10: memorypool: re-commit memory on W32
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 03/10: memorypool: re-commit memory on W32 when resetting pool |
Date: |
Mon, 17 Jun 2019 20:35:46 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 3b42621c669b1ef03b95a01c3bf7b4901b6893d6
Author: Evgeny Grin (Karlson2k) <address@hidden>
AuthorDate: Sat Jun 15 22:26:08 2019 +0300
memorypool: re-commit memory on W32 when resetting pool
---
src/microhttpd/memorypool.c | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index 5067e950..55e997f7 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -396,9 +396,39 @@ MHD_pool_reset (struct MemoryPool *pool,
}
/* technically not needed, but safer to zero out */
if (pool->size > copy_bytes)
- memset (&pool->memory[copy_bytes],
- 0,
- pool->size - copy_bytes);
+ {
+ size_t to_zero; /** Size of area to zero-out */
+
+ to_zero = pool->size - copy_bytes;
+#ifdef _WIN32
+ if (pool->is_mmap)
+ {
+ size_t to_recommit; /** Size of decommitted and re-committed area. */
+ uint8_t *recommit_addr;
+ /* Round down to page size */
+ to_recommit = to_zero - to_zero % MHD_sys_page_size_;
+ recommit_addr = pool->memory + pool->size - to_recommit;
+
+ /* De-committing and re-committing again clear memory and make
+ * pages free / available for other needs until accessed. */
+ if (VirtualFree (recommit_addr,
+ to_recommit,
+ MEM_DECOMMIT))
+ {
+ to_zero -= to_recommit;
+
+ if (recommit_addr != VirtualAlloc (recommit_addr,
+ to_recommit,
+ MEM_COMMIT,
+ PAGE_READWRITE))
+ abort(); /* Serious error, must never happen */
+ }
+ }
+#endif /* _WIN32 */
+ memset (&pool->memory[copy_bytes],
+ 0,
+ to_zero);
+ }
pool->pos = ROUND_TO_ALIGN (new_size);
pool->end = pool->size;
return pool->memory;
--
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, 2019/06/17
- [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 <=
- [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