diff options
author | Gert Doering <gert@greenie.muc.de> | 2013-10-23 17:54:05 +0200 |
---|---|---|
committer | Gert Doering <gert@greenie.muc.de> | 2013-11-17 13:58:27 +0100 |
commit | ad49fb5a74b2ac16298ee8383d514a950ece1097 (patch) | |
tree | 37425b1d616751f6f85cb0969eadb21d5767a4c7 /src/openvpn/buffer.c | |
parent | 3bdc5d7c6478abe8ef35b5ccfce48194719067f8 (diff) | |
download | openvpn-ad49fb5a74b2ac16298ee8383d514a950ece1097.tar.gz openvpn-ad49fb5a74b2ac16298ee8383d514a950ece1097.tar.xz openvpn-ad49fb5a74b2ac16298ee8383d514a950ece1097.zip |
Fix slow memory drain on each client renegotiation.
This reverts commit bee92b479414d12035b0422f81ac5fcfe14fa645 and parts
of commit dc7be6d078ba106f9b0de12f3e879c3561c3c537, as these introduced a
subtle memory drain on client renegotiations (es->gc got initialized,
which led to "unused" gc_entry records accumulating while a client is
connected).
Setting es->gc=NULL causes env_set_add_nolock() / remove_env_item() to
free() allocated and no longer used strings in the es, while an active
gc would leave them for cleanup with gc_free() at client disconnect time.
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Conflicts:
src/openvpn/buffer.c
Acked-by: David Sommerseth <dazo@users.sourceforge.net>
Message-Id: <20131023162618.GP161@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/7939
(cherry picked from commit 4368147972d61b598bbcd5d2904d891130d5e517)
Diffstat (limited to 'src/openvpn/buffer.c')
-rw-r--r-- | src/openvpn/buffer.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 56d14b1..fb3b52d 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -327,19 +327,28 @@ gc_malloc (size_t size, bool clear, struct gc_arena *a) #endif { void *ret; - struct gc_entry *e; - ASSERT (NULL != a); - + if (a) + { + struct gc_entry *e; #ifdef DMALLOC - e = (struct gc_entry *) openvpn_dmalloc (file, line, size + sizeof (struct gc_entry)); + e = (struct gc_entry *) openvpn_dmalloc (file, line, size + sizeof (struct gc_entry)); #else - e = (struct gc_entry *) malloc (size + sizeof (struct gc_entry)); + e = (struct gc_entry *) malloc (size + sizeof (struct gc_entry)); #endif - check_malloc_return (e); - ret = (char *) e + sizeof (struct gc_entry); - e->next = a->list; - a->list = e; - + check_malloc_return (e); + ret = (char *) e + sizeof (struct gc_entry); + e->next = a->list; + a->list = e; + } + else + { +#ifdef DMALLOC + ret = openvpn_dmalloc (file, line, size); +#else + ret = malloc (size); +#endif + check_malloc_return (ret); + } #ifndef ZERO_BUFFER_ON_ALLOC if (clear) #endif |