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

[PATCH] Don't leak SASL contexts

From: Vlad Georgescu <vgeorgescu_at_gmail.com>
Date: 2006-08-19 13:30:11 CEST

[[[
Make sure sasl contexts are always destroyed.

* subversion/libsvn_ra_svn/sasl_auth.c
  (sasl_dispose_cb): New pool cleanup function.
  (new_sasl_ctx): Install the cleanup.
  (svn_ra_svn__do_auth): Don't call sasl_dispose.
]]]

===================================================================
--- subversion/libsvn_ra_svn/sasl_auth.c (revision 21115)
+++ subversion/libsvn_ra_svn/sasl_auth.c (working copy)
@@ -162,6 +162,13 @@
   return SVN_NO_ERROR;
 }

+static apr_status_t sasl_dispose_cb(void *data)
+{
+ sasl_conn_t *sasl_ctx = (sasl_conn_t*) data;
+ sasl_dispose(&sasl_ctx);
+ return APR_SUCCESS;
+}
+
 /* Create a new SASL context. */
 static svn_error_t *new_sasl_ctx(sasl_conn_t **sasl_ctx,
                                  svn_boolean_t is_tunneled,
@@ -180,6 +187,8 @@
     return svn_error_create(SVN_ERR_RA_NOT_AUTHORIZED, NULL,
                             sasl_errstring(result, NULL, NULL));

+ apr_pool_cleanup_register(pool, *sasl_ctx, sasl_dispose_cb,
+ apr_pool_cleanup_null);

   if (is_tunneled)
     {
@@ -483,9 +492,6 @@
                        compat,
                        subpool));

- /* Dispose of this SASL context before creating a new one. */
- sasl_dispose(&sasl_ctx);
-
       if (!success && need_creds)
         SVN_ERR(svn_auth_next_credentials((void**) &creds, iterstate, pool));
     }

-- 
Vlad
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Aug 19 13:30:40 2006

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.