[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated: daemon: fixed pool leak if connec
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated: daemon: fixed pool leak if connection isn't added because of error |
Date: |
Thu, 22 Oct 2020 20:09:30 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
The following commit(s) were added to refs/heads/master by this push:
new 5a334081 daemon: fixed pool leak if connection isn't added because of
error
5a334081 is described below
commit 5a3340810fede2282e59850062fdf4cd0290c1cc
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Oct 22 21:02:07 2020 +0300
daemon: fixed pool leak if connection isn't added because of error
---
src/microhttpd/daemon.c | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index fde43df7..10072078 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2457,24 +2457,6 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
return MHD_NO;
}
connection->sk_cork_on = true; /* default is usually ON */
- connection->pool = MHD_pool_create (daemon->pool_size);
- if (NULL == connection->pool)
- {
-#ifdef HAVE_MESSAGES
- MHD_DLOG (daemon,
- _ ("Error allocating memory: %s\n"),
- MHD_strerror_ (errno));
-#endif
- MHD_socket_close_chk_ (client_socket);
- MHD_ip_limit_del (daemon,
- addr,
- addrlen);
- free (connection);
-#if ENOMEM
- errno = ENOMEM;
-#endif
- return MHD_NO;
- }
connection->connection_timeout = daemon->connection_timeout;
if (NULL == (connection->addr = malloc (addrlen)))
@@ -2489,7 +2471,6 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
MHD_ip_limit_del (daemon,
addr,
addrlen);
- MHD_pool_destroy (connection->pool);
free (connection);
errno = eno;
return MHD_NO;
@@ -2654,6 +2635,29 @@ new_connection_insert_ (struct MHD_Daemon *daemon,
{
int eno = 0;
+ /* Allocate memory pool in the processing thread so
+ * intensively used memory area is allocated in "good"
+ * (for the thread) memory region. It is important with
+ * NUMA and/or complex cache hierarchy. */
+ connection->pool = MHD_pool_create (daemon->pool_size);
+ if (NULL == connection->pool)
+ {
+#ifdef HAVE_MESSAGES
+ MHD_DLOG (daemon,
+ _ ("Error allocating memory: %s\n"),
+ MHD_strerror_ (errno));
+#endif
+ MHD_socket_close_chk_ (client_socket);
+ MHD_ip_limit_del (daemon,
+ addr,
+ addrlen);
+ free (connection);
+#if ENOMEM
+ errno = ENOMEM;
+#endif
+ return MHD_NO;
+ }
+
#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
#endif
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libmicrohttpd] branch master updated: daemon: fixed pool leak if connection isn't added because of error,
gnunet <=