[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] libsvn_ra_dav/neon shutdown

From: Martin Hauner <hauner_at_web.de>
Date: 2004-04-18 17:20:52 CEST

Hi,

I found a memory leak in subversion/neon when neon is build
with ssl support:

subversion: (session.c.patch, against the svn 1.0.x branch)

this patch adds the missing ne_sock_exit() call to svn_ra_dav__open.

neon: (the patch is against neon 0.24.5)

this fixes ne_sock_exit() to cleanup ssl stuff when build with ssl support.

-- 
Martin

Added misssing ssl cleanup in case neon is build with ssl support.

*** ne_socket.c_org Fri Mar 26 13:07:50 2004
--- ne_socket.c Sun Apr 18 15:10:58 2004
***************
*** 258,267 ****
--- 258,278 ----
  #endif /* EGD_PATH */
  
      NE_DEBUG(NE_DBG_SOCKET, "No entropy source found; could not seed PRNG.\n");
      return -1;
  }
+
+ static void exit_ssl()
+ {
+ /* clean up (memory) allocations by SSL_library_init(),
+ an SSL_library_exit() wouldn't be bad... */
+ EVP_cleanup();
+
+ /* clean up (memory) allocations by SSL_load_error_strings */
+ ERR_free_strings();
+ }
+
  #endif /* NEON_SSL */
  
  #ifdef USE_CHECK_IPV6
  static int ipv6_disabled = 0;
  
***************
*** 327,336 ****
--- 338,351 ----
      return 0;
  }
  
  void ne_sock_exit(void)
  {
+ #ifdef NEON_SSL
+ exit_ssl();
+ #endif
+
  #ifdef WIN32
      WSACleanup();
  #endif
      init_result = 0;
  }

Added missing shutdown call for the neon library.

* subversion/libsvn_ra_dav/session.c
  (cleanup_neon): new method.
  (svn_ra_dav__open): added apr_pool_cleanup_register of
  cleanup_neon().

Index: subversion/libsvn_ra_dav/session.c
===================================================================
--- subversion/libsvn_ra_dav/session.c (revision 9415)
+++ subversion/libsvn_ra_dav/session.c (working copy)
@@ -38,6 +38,13 @@
 #include "ra_dav.h"
 
 
+/* a cleanup routine attached to the pool that uninitializes neon. */
+static apr_status_t cleanup_neon(void *v)
+{
+ ne_sock_exit();
+ return APR_SUCCESS;
+}
+
 /* a cleanup routine attached to the pool that contains the RA session
    baton. */
 static apr_status_t cleanup_session(void *sess)
@@ -559,6 +566,10 @@
                               "Network socket initialization failed");
     }
 
+ /* make sure we will cleanup neon. */
+ apr_pool_cleanup_register(pool, 0, cleanup_neon,
+ apr_pool_cleanup_null);
+
   /* we want to know if the repository is actually somewhere else */
   /* ### not yet: http_redirect_register(sess, ... ); */
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Apr 18 17:13:22 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.