]> git.sur5r.net Git - openldap/commitdiff
plug (one time?) leaks
authorPierangelo Masarati <ando@openldap.org>
Thu, 3 Nov 2005 10:52:58 +0000 (10:52 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 3 Nov 2005 10:52:58 +0000 (10:52 +0000)
libraries/librewrite/info.c
libraries/librewrite/session.c

index 53f759975dfa4bb51d1f5261f24047f4027f4dc7..32b5544ebf08dbc21068374863126f4702e5acc0 100644 (file)
@@ -81,10 +81,13 @@ rewrite_info_init(
 
 #ifdef USE_REWRITE_LDAP_PVT_THREADS
        if ( ldap_pvt_thread_rdwr_init( &info->li_cookies_mutex ) ) {
+               avl_free( info->li_context, rewrite_context_free );
                free( info );
                return NULL;
        }
        if ( ldap_pvt_thread_rdwr_init( &info->li_params_mutex ) ) {
+               ldap_pvt_thread_rdwr_destroy( &info->li_cookies_mutex );
+               avl_free( info->li_context, rewrite_context_free );
                free( info );
                return NULL;
        }
@@ -116,7 +119,7 @@ rewrite_info_delete(
        if ( info->li_maps ) {
                avl_free( info->li_maps, rewrite_builtin_map_free );
        }
-       info->li_context = NULL;
+       info->li_maps = NULL;
 
        rewrite_session_destroy( info );
 
index bd0685167c926dab95868cd30e893df163a7e7d3..536d3be1908a7a9fbda3292e9c9784f65fb8cf4c 100644 (file)
@@ -302,6 +302,25 @@ rewrite_session_var_get(
        return REWRITE_SUCCESS;
 }
 
+static void
+rewrite_session_free( void *v_session )
+{
+       struct rewrite_session  *session = (struct rewrite_session *)v_session;
+
+#ifdef USE_REWRITE_LDAP_PVT_THREADS
+       ldap_pvt_thread_rdwr_wlock( &session->ls_vars_mutex );
+#endif /* USE_REWRITE_LDAP_PVT_THREADS */
+
+       rewrite_var_delete( session->ls_vars );
+
+#ifdef USE_REWRITE_LDAP_PVT_THREADS
+       ldap_pvt_thread_rdwr_wunlock( &session->ls_vars_mutex );
+       ldap_pvt_thread_rdwr_destroy( &session->ls_vars_mutex );
+       ldap_pvt_thread_mutex_unlock( &session->ls_mutex );
+       ldap_pvt_thread_mutex_destroy( &session->ls_mutex );
+#endif /* USE_REWRITE_LDAP_PVT_THREADS */
+}
+
 /*
  * Deletes a session
  */
@@ -329,18 +348,7 @@ rewrite_session_delete(
                return REWRITE_SUCCESS;
        }
 
-#ifdef USE_REWRITE_LDAP_PVT_THREADS
-       ldap_pvt_thread_rdwr_wlock( &session->ls_vars_mutex );
-#endif /* USE_REWRITE_LDAP_PVT_THREADS */
-
-       rewrite_var_delete( session->ls_vars );
-
-#ifdef USE_REWRITE_LDAP_PVT_THREADS
-       ldap_pvt_thread_rdwr_wunlock( &session->ls_vars_mutex );
-       ldap_pvt_thread_rdwr_destroy( &session->ls_vars_mutex );
-       ldap_pvt_thread_mutex_unlock( &session->ls_mutex );
-       ldap_pvt_thread_mutex_destroy( &session->ls_mutex );
-#endif /* USE_REWRITE_LDAP_PVT_THREADS */
+       rewrite_session_free( session );
 
 #ifdef USE_REWRITE_LDAP_PVT_THREADS
        ldap_pvt_thread_rdwr_wlock( &info->li_cookies_mutex );
@@ -382,7 +390,7 @@ rewrite_session_destroy(
         * Should call per-session destruction routine ...
         */
        
-       count = avl_free( info->li_cookies, NULL );
+       count = avl_free( info->li_cookies, rewrite_session_free );
        info->li_cookies = NULL;
 
 #if 0