From 805894be1d6c56e7da425fa77112631ca97de631 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 11 Apr 2003 23:23:03 +0000 Subject: [PATCH] fix context memory and more cleanup --- servers/slapd/back-sql/bind.c | 4 ++-- servers/slapd/back-sql/entry-id.c | 12 ++++++++---- servers/slapd/back-sql/modify.c | 8 ++++---- servers/slapd/back-sql/other.c | 9 +++++---- servers/slapd/back-sql/search.c | 13 +++---------- servers/slapd/back-sql/util.c | 5 +++-- servers/slapd/back-sql/util.h | 9 +++------ 7 files changed, 28 insertions(+), 32 deletions(-) diff --git a/servers/slapd/back-sql/bind.c b/servers/slapd/back-sql/bind.c index 10f871be40..fd3515d1f7 100644 --- a/servers/slapd/back-sql/bind.c +++ b/servers/slapd/back-sql/bind.c @@ -74,8 +74,8 @@ backsql_bind( Operation *op, SlapReply *rs ) return 1; } - backsql_init_search( &bsi, bi, &op->o_req_ndn, LDAP_SCOPE_BASE, - -1, -1, -1, NULL, dbh, op->o_bd, op->o_conn, op, NULL ); + backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, + -1, -1, -1, NULL, dbh, op, NULL ); e = backsql_id2entry( &bsi, &user_entry, &user_id ); if ( e == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_bind(): " diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index b87a012fd3..2d449312c1 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -325,7 +325,8 @@ backsql_get_attr_vals( void *v_at, void *v_bsi ) bv.bv_len = strlen( row.cols[ i ] ); #endif backsql_entry_addattr( bsi->e, - &row.col_names[ i ], &bv ); + &row.col_names[ i ], &bv, + bsi->op->o_tmpmemctx ); #ifdef BACKSQL_TRACE Debug( LDAP_DEBUG_TRACE, "prec=%d\n", @@ -356,7 +357,8 @@ backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *eid ) Debug( LDAP_DEBUG_TRACE, "==>backsql_id2entry()\n", 0, 0, 0 ); - rc = dnPrettyNormal( NULL, &eid->dn, &e->e_name, &e->e_nname ); + rc = dnPrettyNormal( NULL, &eid->dn, &e->e_name, &e->e_nname, + bsi->op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { return NULL; } @@ -409,7 +411,8 @@ backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *eid ) bsi, 0, AVL_INORDER ); } - if ( attr_mergeit_one( bsi->e, ad_oc, &bsi->oc->oc->soc_cname ) ) { + if ( attr_merge_normalize_one( bsi->e, ad_oc, &bsi->oc->oc->soc_cname, + bsi->op->o_tmpmemctx ) ) { entry_free( e ); return NULL; } @@ -436,7 +439,8 @@ backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *eid ) if ( bsi->bsi_flags | BSQL_SF_ALL_OPER || an_find( bsi->attrs, &AllOper ) ) { - if ( attr_mergeit_one( bsi->e, ad_soc, &soc ) ) { + if ( attr_merge_normalize_one( bsi->e, ad_soc, &soc, + bsi->op->o_tmpmemctx ) ) { entry_free( e ); return NULL; } diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index 8b1a376673..de3d63aa92 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -679,13 +679,13 @@ backsql_modrdn( Operation *op, SlapReply *rs ) goto modrdn_return; } - build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn ); - if ( dnNormalize2( NULL, &new_dn, &new_ndn ) != LDAP_SUCCESS ) { + build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn ); + rs->sr_err = dnNormalize2( NULL, &new_dn, &new_ndn, op->o_tmpmemctx ); + if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): " "new dn is invalid ('%s') - aborting\n", new_dn.bv_val, 0, 0 ); - rs->sr_err = LDAP_INVALID_DN_SYNTAX; - rs->sr_text = "new DN is invalid"; + rs->sr_text = "unable to build new DN"; send_ldap_result( op, rs ); goto modrdn_return; } diff --git a/servers/slapd/back-sql/other.c b/servers/slapd/back-sql/other.c index c5a9d10132..8cd14269d8 100644 --- a/servers/slapd/back-sql/other.c +++ b/servers/slapd/back-sql/other.c @@ -56,9 +56,8 @@ backsql_compare( Operation *op, SlapReply *rs ) anlist[0].an_name = op->oq_compare.rs_ava->aa_desc->ad_cname; anlist[0].an_desc = op->oq_compare.rs_ava->aa_desc; anlist[1].an_name.bv_val = NULL; - backsql_init_search( &bsi, bi, &op->o_req_ndn, LDAP_SCOPE_BASE, - -1, -1, -1, NULL, dbh, op->o_bd, op->o_conn, op, - anlist); + backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, + -1, -1, -1, NULL, dbh, op, anlist); e = backsql_id2entry( &bsi, &user_entry, &user_id ); if ( e == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_compare(): " @@ -85,7 +84,9 @@ backsql_compare( Operation *op, SlapReply *rs ) if ( value_find_ex( op->oq_compare.rs_ava->aa_desc, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - a->a_nvals, &op->oq_compare.rs_ava->aa_value ) == 0 ) + a->a_nvals, + &op->oq_compare.rs_ava->aa_value, + op->o_tmpmemctx ) == 0 ) { rs->sr_err = LDAP_COMPARE_TRUE; break; diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index eee527913f..6a14ba7b0a 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -84,7 +84,6 @@ backsql_attrlist_add( backsql_srch_info *bsi, AttributeDescription *ad ) void backsql_init_search( backsql_srch_info *bsi, - backsql_info *bi, struct berval *nbase, int scope, int slimit, @@ -92,8 +91,6 @@ backsql_init_search( time_t stoptime, Filter *filter, SQLHDBC dbh, - BackendDB *be, - Connection *conn, Operation *op, AttributeName *attrs ) { @@ -105,8 +102,6 @@ backsql_init_search( bsi->tlimit = tlimit; bsi->filter = filter; bsi->dbh = dbh; - bsi->be = be; - bsi->conn = conn; bsi->op = op; bsi->bsi_flags = 0; @@ -142,7 +137,6 @@ backsql_init_search( bsi->id_list = NULL; bsi->n_candidates = 0; bsi->stoptime = stoptime; - bsi->bi = bi; bsi->sel.bv_val = NULL; bsi->sel.bv_len = 0; bsi->sel_len = 0; @@ -635,7 +629,7 @@ impossible: static int backsql_srch_query( backsql_srch_info *bsi, struct berval *query ) { - backsql_info *bi = (backsql_info *)bsi->be->be_private; + backsql_info *bi = (backsql_info *)bsi->op->o_bd->be_private; ber_len_t q_len = 0; int rc; @@ -1122,12 +1116,11 @@ backsql_search( Operation *op, SlapReply *rs ) /* compute it anyway; root does not use it */ stoptime = op->o_time + op->oq_search.rs_tlimit; - backsql_init_search( &srch_info, bi, &op->o_req_dn, + backsql_init_search( &srch_info, &op->o_req_dn, op->oq_search.rs_scope, op->oq_search.rs_slimit, op->oq_search.rs_tlimit, stoptime, op->oq_search.rs_filter, - dbh, op->o_bd, op->o_conn, op, - op->oq_search.rs_attrs ); + dbh, op, op->oq_search.rs_attrs ); /* * for each objectclass we try to construct query which gets IDs diff --git a/servers/slapd/back-sql/util.c b/servers/slapd/back-sql/util.c index 488a15a419..126ca93b68 100644 --- a/servers/slapd/back-sql/util.c +++ b/servers/slapd/back-sql/util.c @@ -234,7 +234,8 @@ int backsql_entry_addattr( Entry *e, struct berval *at_name, - struct berval *at_val ) + struct berval *at_val, + void *memctx ) { AttributeDescription *ad; int rc; @@ -255,7 +256,7 @@ backsql_entry_addattr( return 0; } - rc = attr_mergeit_one( e, ad, at_val ); + rc = attr_merge_normalize_one( e, ad, at_val, memctx ); if ( rc != 0 ) { Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(): " diff --git a/servers/slapd/back-sql/util.h b/servers/slapd/back-sql/util.h index 06e38d5824..37e94aa6f7 100644 --- a/servers/slapd/back-sql/util.h +++ b/servers/slapd/back-sql/util.h @@ -21,7 +21,7 @@ struct berval * backsql_strfcat( struct berval *dest, ber_len_t *buflen, const char *fmt, ... ); int backsql_entry_addattr( Entry *e, struct berval *at_name, - struct berval *at_val ); + struct berval *at_val, void *memctx ); typedef struct backsql_srch_info { struct berval *base_dn; @@ -38,8 +38,6 @@ typedef struct backsql_srch_info { ber_len_t sel_len, from_len, jwhere_len, fwhere_len; SQLHDBC dbh; int status; - Backend *be; - Connection *conn; Operation *op; AttributeName *attrs; int bsi_flags; @@ -50,11 +48,10 @@ typedef struct backsql_srch_info { int use_reverse_dn; } backsql_srch_info; -void backsql_init_search( backsql_srch_info *bsi, backsql_info *bi, +void backsql_init_search( backsql_srch_info *bsi, struct berval *nbase, int scope, int slimit, int tlimit, time_t stoptime, Filter *filter, SQLHDBC dbh, - BackendDB *be, Connection *conn, Operation *op, - AttributeName *attrs ); + Operation *op, AttributeName *attrs ); Entry *backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *id ); -- 2.39.5