diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2006-11-23 22:05:14 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2006-11-23 22:05:14 +0000 |
commit | 2a64816b391395d925e0f7ff79d200bbb562fe7e (patch) | |
tree | 372e7f53f484b96e9e2b3f129fb516ee51f2b293 /misc.c | |
parent | c589d2814f7ef51c9150c8b9e329daeaa91a57b7 (diff) | |
download | openvpn-2a64816b391395d925e0f7ff79d200bbb562fe7e.tar.gz openvpn-2a64816b391395d925e0f7ff79d200bbb562fe7e.tar.xz openvpn-2a64816b391395d925e0f7ff79d200bbb562fe7e.zip |
Fixed issue where struct env_set methods that
change the value of an existing name=value pair
would delay the freeing of the memory held by
the previous name=value pair until the underlying
client instance object is closed.
This could cause a server that handles long-term
client connections, resulting in many periodic calls
to verify_callback, to needlessly grow the env_set
memory allocation until the underlying client instance
object is closed.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@1493 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -690,13 +690,13 @@ add_env_item (char *str, const bool do_alloc, struct env_item **list, struct gc_ static bool env_set_del_nolock (struct env_set *es, const char *str) { - return remove_env_item (str, false, &es->list); + return remove_env_item (str, es->gc == NULL, &es->list); } static void env_set_add_nolock (struct env_set *es, const char *str) { - remove_env_item (str, false, &es->list); + remove_env_item (str, es->gc == NULL, &es->list); add_env_item ((char *)str, true, &es->list, es->gc); } @@ -704,7 +704,6 @@ struct env_set * env_set_create (struct gc_arena *gc) { struct env_set *es; - ASSERT (gc); mutex_lock_static (L_ENV_SET); ALLOC_OBJ_CLEAR_GC (es, struct env_set, gc); es->list = NULL; @@ -713,6 +712,25 @@ env_set_create (struct gc_arena *gc) return es; } +void +env_set_destroy (struct env_set *es) +{ + mutex_lock_static (L_ENV_SET); + if (es && es->gc == NULL) + { + struct env_item *e = es->list; + while (e) + { + struct env_item *next = e->next; + free (e->string); + free (e); + e = next; + } + free (es); + } + mutex_unlock_static (L_ENV_SET); +} + bool env_set_del (struct env_set *es, const char *str) { |