From: Pierangelo Masarati Date: Thu, 3 Nov 2005 10:52:58 +0000 (+0000) Subject: plug (one time?) leaks X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~128 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4e5eb991eb668e3f296a189dc5316eb48e728650;p=openldap plug (one time?) leaks --- diff --git a/libraries/librewrite/info.c b/libraries/librewrite/info.c index 53f759975d..32b5544ebf 100644 --- a/libraries/librewrite/info.c +++ b/libraries/librewrite/info.c @@ -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 ); diff --git a/libraries/librewrite/session.c b/libraries/librewrite/session.c index bd0685167c..536d3be190 100644 --- a/libraries/librewrite/session.c +++ b/libraries/librewrite/session.c @@ -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