further cleanup of search data upon exit, abandon, cancel

This commit is contained in:
Jong Hyuk Choi 2004-10-16 16:10:00 +00:00
parent ca0bf91bba
commit 6db389efd9
2 changed files with 96 additions and 10 deletions

View File

@ -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 );

View File

@ -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 ) {
slap_op_free ( ps );
if ( ps->o_tmpmemctx ) {
slap_sl_mem_destroy( NULL, ps->o_tmpmemctx );
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 ( 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 );
slap_op_free ( ps );
if ( ps->o_tmpmemctx ) {
slap_sl_mem_destroy( NULL, 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 ( saved_tmpmemctx ) {
slap_sl_mem_destroy( NULL, saved_tmpmemctx );
}
return LDAP_SUCCESS;
}
return LDAP_UNAVAILABLE;