-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Gadbois wrote:

> Using OpenVPN 2.0.5 and 2.0.9, I notice that an somewhat idle connection
> increases the RSS of the server process linearly with time.
> 

Here is my patch to fix this issue. It does create (according to
valgrind) a memory leak, but it does not increase with time. Feel free
to fix it better...

I short, environments values were allocated using gc*(), and every key
change the environement list changes, but the allocated values stayed in
the context's gc.

I modified the environement values to always allocate using malloc() and
always free() values when the env list changes.


- --
==============         +---------------------------------------------+
Martin Gadbois         |    You are            -- J. Steakley,       |
Sr. SW Designer        |    What you do             Armor, 1984      |
Colubris Networks Inc. |    When it counts.                          |
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIPtCmMPkSU9icdA0RAiXTAJ4g3qzaubnyRTOCsCEF9Iz3BU+2AQCeMzzE
/7mbJluQBOfzjy4jph4T4RI=
=fksj
-----END PGP SIGNATURE-----
diff -ur openvpn-2.0.5-org/misc.c openvpn-2.0.5/misc.c
--- openvpn-2.0.5-org/misc.c    2005-11-01 06:06:11.000000000 -0500
+++ openvpn-2.0.5/misc.c        2008-05-29 11:37:05.000000000 -0400
@@ -651,7 +652,7 @@
            prev->next = current->next;
          else
            *list = current->next;
-         if (do_free)
+//       if (do_free)
            {
              memset (current->string, 0, strlen (current->string));
              free (current->string);
@@ -671,9 +672,10 @@

   ASSERT (str);
   ASSERT (list);
-
-  ALLOC_OBJ_GC (item, struct env_item, gc);
-  item->string = do_alloc ? string_alloc (str, gc): str;
+       dmsg(M_WARN,"ENV: Adding %s %s",str,do_alloc?"Alloc":"");
+  ALLOC_OBJ (item, struct env_item);
+//  item->string = do_alloc ? string_alloc (str, gc): str;
+  item->string = strdup(str);
   item->next = *list;
   *list = item;
 }

Reply via email to