]> git.sur5r.net Git - openldap/commitdiff
further cleanup of search data upon exit, abandon, cancel
authorJong Hyuk Choi <jongchoi@openldap.org>
Sat, 16 Oct 2004 16:10:00 +0000 (16:10 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Sat, 16 Oct 2004 16:10:00 +0000 (16:10 +0000)
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/search.c

index 7c634390b759b3d18edc5043f7ae8a2665d5f7ec..5d2552532d2fa14460548bd854a6c719a1e353f1 100644 (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 );
index e4f536854e547d0d0833ff59f3a628ee4fdcb75c..ca54be4af5c665b662af9d14bd0636dd207663f5 100644 (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 ) {
+               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;