ITS#9907 Plug shutdown related leaks in lloadd

This commit is contained in:
Ondřej Kuzník 2022-08-30 13:25:18 +01:00
parent ad79add5a0
commit 333d61d7eb
7 changed files with 57 additions and 4 deletions

View file

@ -1319,14 +1319,15 @@ config_bindconf( ConfigArgs *c )
}
if ( !BER_BVISNULL( &bindconf.sb_authzId ) ) {
ber_dupbv( &lloadd_identity, &bindconf.sb_authzId );
ber_bvreplace( &lloadd_identity, &bindconf.sb_authzId );
} else if ( !BER_BVISNULL( &bindconf.sb_authcId ) ) {
ber_dupbv( &lloadd_identity, &bindconf.sb_authcId );
ber_bvreplace( &lloadd_identity, &bindconf.sb_authcId );
} else if ( !BER_BVISNULL( &bindconf.sb_binddn ) ) {
char *ptr;
lloadd_identity.bv_len = STRLENOF("dn:") + bindconf.sb_binddn.bv_len;
lloadd_identity.bv_val = ch_malloc( lloadd_identity.bv_len + 1 );
lloadd_identity.bv_val = ch_realloc(
lloadd_identity.bv_val, lloadd_identity.bv_len + 1 );
ptr = lutil_strcopy( lloadd_identity.bv_val, "dn:" );
ptr = lutil_strncopy(
@ -1552,10 +1553,12 @@ config_tier( ConfigArgs *c )
if ( CONFIG_ONLINE_ADD( c ) ) {
assert( tier );
lload_change.target = tier;
ch_free( c->value_string );
return rc;
}
tier_impl = lload_tier_find( c->value_string );
ch_free( c->value_string );
if ( !tier_impl ) {
goto fail;
}

View file

@ -779,6 +779,9 @@ lloadd_daemon_destroy( void )
}
}
event_free( lload_stats_event );
event_free( lload_timeout_event );
event_base_free( daemon_base );
daemon_base = NULL;

View file

@ -211,3 +211,10 @@ lload_exop_init( void )
return LDAP_SUCCESS;
}
void
lload_exop_destroy( void )
{
ldap_avl_free( lload_exop_handlers, NULL );
lload_exop_handlers = NULL;
}

View file

@ -105,6 +105,37 @@ lload_global_init( void )
return 0;
}
int
lload_global_destroy( void )
{
if ( !BER_BVISNULL( &lloadd_identity ) ) {
ch_free( lloadd_identity.bv_val );
BER_BVZERO( &lloadd_identity );
}
lload_exop_destroy();
#ifdef HAVE_TLS
if ( lload_tls_backend_ld ) {
ldap_unbind_ext( lload_tls_backend_ld, NULL, NULL );
}
if ( lload_tls_ld ) {
ldap_unbind_ext( lload_tls_ld, NULL, NULL );
}
#endif
ldap_pvt_thread_mutex_destroy( &lload_wait_mutex );
ldap_pvt_thread_cond_destroy( &lload_wait_cond );
ldap_pvt_thread_cond_destroy( &lload_pause_cond );
ldap_pvt_thread_mutex_destroy( &clients_mutex );
ldap_pvt_thread_mutex_destroy( &lload_pin_mutex );
lload_libevent_destroy();
return 0;
}
int
lload_tls_init( void )
{

View file

@ -870,6 +870,7 @@ destroy:
(void)loglevel_print( stdout );
}
/* remember an error during destroy */
rc |= lload_global_destroy();
rc |= lload_destroy();
stop:

View file

@ -140,6 +140,12 @@ lload_back_close( BackendInfo *bi )
return 0;
}
int
lload_back_destroy( BackendInfo *bi )
{
return lload_global_destroy();
}
int
lload_back_initialize( BackendInfo *bi )
{
@ -149,7 +155,7 @@ lload_back_initialize( BackendInfo *bi )
bi->bi_pause = lload_pause_cb;
bi->bi_unpause = lload_unpause_cb;
bi->bi_close = lload_back_close;
bi->bi_destroy = 0;
bi->bi_destroy = lload_back_destroy;
bi->bi_db_init = 0;
bi->bi_db_config = 0;

View file

@ -143,11 +143,13 @@ LDAP_SLAPD_V (Avlnode *) lload_exop_handlers;
LDAP_SLAPD_F (int) exop_handler_cmp( const void *l, const void *r );
LDAP_SLAPD_F (int) request_extended( LloadConnection *c, LloadOperation *op );
LDAP_SLAPD_F (int) lload_exop_init( void );
LDAP_SLAPD_F (void) lload_exop_destroy( void );
/*
* init.c
*/
LDAP_SLAPD_F (int) lload_global_init( void );
LDAP_SLAPD_F (int) lload_global_destroy( void );
LDAP_SLAPD_F (int) lload_tls_init( void );
LDAP_SLAPD_F (int) lload_init( int mode, const char *name );
LDAP_SLAPD_F (int) lload_destroy( void );