From 6db389efd9436272003fd986eb021540f81c6bbf Mon Sep 17 00:00:00 2001 From: Jong Hyuk Choi Date: Sat, 16 Oct 2004 16:10:00 +0000 Subject: [PATCH] further cleanup of search data upon exit, abandon, cancel --- servers/slapd/back-bdb/init.c | 51 ++++++++++++++++++++++++++++++--- servers/slapd/back-bdb/search.c | 51 ++++++++++++++++++++++++++++++--- 2 files changed, 94 insertions(+), 8 deletions(-) diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 7c634390b7..5d2552532d 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -429,6 +429,7 @@ bdb_db_destroy( BackendDB *be ) struct bdb_info *bdb = (struct bdb_info *) be->be_private; Operation *ps = NULL; Operation *psn = NULL; + void *saved_tmpmemctx = NULL; /* close db environment */ if( bdb->bi_dbenv ) { @@ -467,17 +468,59 @@ bdb_db_destroy( BackendDB *be ) if ( ps ) { psn = LDAP_LIST_NEXT( ps, o_ps_link ); + + saved_tmpmemctx = ps->o_tmpmemctx; + + if (!BER_BVISNULL(&ps->o_req_dn)) { + slap_sl_free( ps->o_req_dn.bv_val, ps->o_tmpmemctx ); + } + if (!BER_BVISNULL(&ps->o_req_ndn)) { + slap_sl_free( ps->o_req_ndn.bv_val, ps->o_tmpmemctx ); + } + if (!BER_BVISNULL(&ps->ors_filterstr)) { + slap_sl_free(ps->ors_filterstr.bv_val, ps->o_tmpmemctx); + } + if (ps->ors_filter != NULL) { + filter_free_x(ps, ps->ors_filter); + } + if ( ps->ors_attrs != NULL) { + ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx); + } + slap_op_free( ps ); - if ( ps->o_tmpmemctx ) - slap_sl_mem_destroy( NULL, ps->o_tmpmemctx ); + + if ( saved_tmpmemctx ) { + slap_sl_mem_destroy( NULL, saved_tmpmemctx ); + } } while ( psn ) { ps = psn; psn = LDAP_LIST_NEXT( ps, o_ps_link ); + + saved_tmpmemctx = ps->o_tmpmemctx; + + if (!BER_BVISNULL(&ps->o_req_dn)) { + slap_sl_free( ps->o_req_dn.bv_val, ps->o_tmpmemctx ); + } + if (!BER_BVISNULL(&ps->o_req_ndn)) { + slap_sl_free( ps->o_req_ndn.bv_val, ps->o_tmpmemctx ); + } + if (!BER_BVISNULL(&ps->ors_filterstr)) { + slap_sl_free(ps->ors_filterstr.bv_val, ps->o_tmpmemctx); + } + if (ps->ors_filter != NULL) { + filter_free_x(ps, ps->ors_filter); + } + if ( ps->ors_attrs != NULL) { + ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx); + } + slap_op_free( ps ); - if ( ps->o_tmpmemctx ) - slap_sl_mem_destroy( NULL, ps->o_tmpmemctx ); + + if ( saved_tmpmemctx ) { + slap_sl_mem_destroy( NULL, saved_tmpmemctx ); + } } ch_free( bdb ); diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index e4f536854e..ca54be4af5 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -341,13 +341,34 @@ int bdb_abandon( Operation *op, SlapReply *rs ) { Operation *ps; + void *saved_tmpmemctx; ps = bdb_drop_psearch( op, op->oq_abandon.rs_msgid ); if ( ps ) { + saved_tmpmemctx = ps->o_tmpmemctx; + + if (!BER_BVISNULL(&ps->o_req_dn)) { + slap_sl_free(ps->o_req_dn.bv_val, ps->o_tmpmemctx ); + } + if (!BER_BVISNULL(&ps->o_req_ndn)) { + slap_sl_free(ps->o_req_ndn.bv_val, ps->o_tmpmemctx ); + } + if (!BER_BVISNULL(&ps->ors_filterstr)) { + ps->o_tmpfree(ps->ors_filterstr.bv_val, ps->o_tmpmemctx); + } + if (ps->ors_filter != NULL) { + filter_free_x(ps, ps->ors_filter); + } + if (ps->ors_attrs != NULL) { + ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx); + } + slap_op_free ( ps ); - if ( ps->o_tmpmemctx ) { - slap_sl_mem_destroy( NULL, ps->o_tmpmemctx ); + + if ( saved_tmpmemctx ) { + slap_sl_mem_destroy( NULL, saved_tmpmemctx ); } + return LDAP_SUCCESS; } return LDAP_UNAVAILABLE; @@ -357,15 +378,37 @@ int bdb_cancel( Operation *op, SlapReply *rs ) { Operation *ps; + void *saved_tmpmemctx; ps = bdb_drop_psearch( op, op->oq_cancel.rs_msgid ); if ( ps ) { + saved_tmpmemctx = ps->o_tmpmemctx; + rs->sr_err = LDAP_CANCELLED; send_ldap_result( ps, rs ); + + if (!BER_BVISNULL(&ps->o_req_dn)) { + slap_sl_free(ps->o_req_dn.bv_val, ps->o_tmpmemctx ); + } + if (!BER_BVISNULL(&ps->o_req_ndn)) { + slap_sl_free(ps->o_req_ndn.bv_val, ps->o_tmpmemctx ); + } + if (!BER_BVISNULL(&ps->ors_filterstr)) { + ps->o_tmpfree(ps->ors_filterstr.bv_val, ps->o_tmpmemctx); + } + if (ps->ors_filter != NULL) { + filter_free_x(ps, ps->ors_filter); + } + if (ps->ors_attrs != NULL) { + ps->o_tmpfree(ps->ors_attrs, ps->o_tmpmemctx); + } + slap_op_free ( ps ); - if ( ps->o_tmpmemctx ) { - slap_sl_mem_destroy( NULL, ps->o_tmpmemctx ); + + if ( saved_tmpmemctx ) { + slap_sl_mem_destroy( NULL, saved_tmpmemctx ); } + return LDAP_SUCCESS; } return LDAP_UNAVAILABLE; -- 2.39.5