From 3df83d7089dafffcb08baa35120cf6071935eddf Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 20 Jul 2005 14:59:56 +0000 Subject: [PATCH] destroy cache on exit --- servers/slapd/back-monitor/cache.c | 37 +++++++++++++++++++ servers/slapd/back-monitor/init.c | 8 ++++ .../slapd/back-monitor/proto-back-monitor.h | 4 ++ 3 files changed, 49 insertions(+) diff --git a/servers/slapd/back-monitor/cache.c b/servers/slapd/back-monitor/cache.c index 086a833713..4f5ca062a2 100644 --- a/servers/slapd/back-monitor/cache.c +++ b/servers/slapd/back-monitor/cache.c @@ -267,3 +267,40 @@ monitor_cache_release( return( 0 ); } +static void +monitor_entry_destroy( void *v_mc ) +{ + monitor_cache_t *mc = (monitor_cache_t *)v_mc; + + if ( mc->mc_e != NULL ) { + monitor_entry_t *mp; + + assert( mc->mc_e->e_private != NULL ); + + mp = ( monitor_entry_t * )mc->mc_e->e_private; + + if ( mp->mp_cb ) { + /* TODO */ + } + + ldap_pvt_thread_mutex_destroy( &mp->mp_mutex ); + + ch_free( mp ); + mc->mc_e->e_private = NULL; + entry_free( mc->mc_e ); + } + + ch_free( mc ); +} + +int +monitor_cache_destroy( + monitor_info_t *mi ) +{ + if ( mi->mi_cache ) { + avl_free( mi->mi_cache, monitor_entry_destroy ); + } + + return 0; +} + diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index e3cac86c00..0213b9349e 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -1706,7 +1706,9 @@ monitor_back_db_config( int argc, char **argv ) { +#if 0 monitor_info_t *mi = ( monitor_info_t * )be->be_private; +#endif /* * eventually, will hold database specific configuration parameters @@ -1725,6 +1727,12 @@ monitor_back_db_destroy( */ /* NOTE: mi points to static storage; don't free it */ + (void)monitor_cache_destroy( mi ); + + if ( monitor_subsys ) { + ch_free( monitor_subsys ); + } + return 0; } diff --git a/servers/slapd/back-monitor/proto-back-monitor.h b/servers/slapd/back-monitor/proto-back-monitor.h index d73bf61d6b..6de478a1cc 100644 --- a/servers/slapd/back-monitor/proto-back-monitor.h +++ b/servers/slapd/back-monitor/proto-back-monitor.h @@ -68,6 +68,10 @@ monitor_cache_release LDAP_P(( monitor_info_t *mi, Entry *e )); +extern int +monitor_cache_destroy LDAP_P(( + monitor_info_t *mi )); + /* * connections */ -- 2.39.5