From 3751f0325d147f8aaf77d386325be7835d187152 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 1 Jun 2005 19:35:13 +0000 Subject: [PATCH] work around syncprov interoperation issues; minor cleanup --- servers/slapd/back-sql/add.c | 2 +- servers/slapd/back-sql/bind.c | 2 +- servers/slapd/back-sql/compare.c | 2 +- servers/slapd/back-sql/delete.c | 4 +- servers/slapd/back-sql/entry-id.c | 8 ++-- servers/slapd/back-sql/init.c | 1 + servers/slapd/back-sql/modify.c | 4 +- servers/slapd/back-sql/modrdn.c | 8 ++-- servers/slapd/back-sql/proto-sql.h | 3 ++ .../rdbms_depend/pgsql/backsql_drop.sql | 1 - .../rdbms_depend/pgsql/testdb_drop.sql | 1 + servers/slapd/back-sql/search.c | 44 +++++++++++++++++-- 12 files changed, 60 insertions(+), 20 deletions(-) diff --git a/servers/slapd/back-sql/add.c b/servers/slapd/back-sql/add.c index d080b75f96..cd2b5a6131 100644 --- a/servers/slapd/back-sql/add.c +++ b/servers/slapd/back-sql/add.c @@ -1494,7 +1494,7 @@ done:; } if ( !BER_BVISNULL( &p.e_nname ) ) { - entry_clean( &p ); + backsql_entry_clean( op, &p ); } Debug( LDAP_DEBUG_TRACE, "<==backsql_add(\"%s\"): %d \"%s\"\n", diff --git a/servers/slapd/back-sql/bind.c b/servers/slapd/back-sql/bind.c index 5817d06af6..0bc12e5a24 100644 --- a/servers/slapd/back-sql/bind.c +++ b/servers/slapd/back-sql/bind.c @@ -106,7 +106,7 @@ error_return:; } if ( !BER_BVISNULL( &e.e_nname ) ) { - entry_clean( &e ); + backsql_entry_clean( op, &e ); } if ( bsi.bsi_attrs != NULL ) { diff --git a/servers/slapd/back-sql/compare.c b/servers/slapd/back-sql/compare.c index 4783714f14..9baf9ff35d 100644 --- a/servers/slapd/back-sql/compare.c +++ b/servers/slapd/back-sql/compare.c @@ -181,7 +181,7 @@ return_results:; } if ( !BER_BVISNULL( &e.e_nname ) ) { - entry_clean( &e ); + backsql_entry_clean( op, &e ); } if ( bsi.bsi_attrs != NULL ) { diff --git a/servers/slapd/back-sql/delete.c b/servers/slapd/back-sql/delete.c index 5659541268..e8bf7142c6 100644 --- a/servers/slapd/back-sql/delete.c +++ b/servers/slapd/back-sql/delete.c @@ -474,11 +474,11 @@ done:; } if ( !BER_BVISNULL( &d.e_nname ) ) { - entry_clean( &d ); + backsql_entry_clean( op, &d ); } if ( !BER_BVISNULL( &p.e_nname ) ) { - entry_clean( &p ); + backsql_entry_clean( op, &p ); } return rs->sr_err; diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index 49d3346c7e..87aba87a7d 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -862,7 +862,7 @@ backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid ) &bsi->bsi_oc->bom_oc->soc_cname, bsi->bsi_op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { - entry_clean( bsi->bsi_e ); + backsql_entry_clean( op, bsi->bsi_e ); return rc; } @@ -966,7 +966,7 @@ next:; "structural_class() failed %d (%s)\n", bsi->bsi_e->e_name.bv_val, rc, text ? text : "" ); - entry_clean( bsi->bsi_e ); + backsql_entry_clean( op, bsi->bsi_e ); return rc; } @@ -977,7 +977,7 @@ next:; "to entry\n", bsi->bsi_e->e_name.bv_val, soc.bv_val, bsi->bsi_oc->bom_oc->soc_cname.bv_val ); - entry_clean( bsi->bsi_e ); + backsql_entry_clean( op, bsi->bsi_e ); return rc; } } @@ -987,7 +987,7 @@ next:; &bsi->bsi_oc->bom_oc->soc_cname, bsi->bsi_op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { - entry_clean( bsi->bsi_e ); + backsql_entry_clean( op, bsi->bsi_e ); return rc; } } diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c index f3e744fe4b..cf0bebf73b 100644 --- a/servers/slapd/back-sql/init.c +++ b/servers/slapd/back-sql/init.c @@ -74,6 +74,7 @@ sql_back_initialize( bi->bi_chk_referrals = 0; bi->bi_operational = backsql_operational; bi->bi_entry_get_rw = backsql_entry_get; + bi->bi_entry_release_rw = backsql_entry_release; bi->bi_connection_init = 0; bi->bi_connection_destroy = backsql_connection_destroy; diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index 6b192631e2..623362a487 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -158,7 +158,7 @@ backsql_modify( Operation *op, SlapReply *rs ) if ( BACKSQL_CHECK_SCHEMA( bi ) ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; - entry_clean( &m ); + backsql_entry_clean( op, &m ); bsi.bsi_e = &m; rs->sr_err = backsql_id2entry( &bsi, &bsi.bsi_base_id ); @@ -212,7 +212,7 @@ done:; } if ( !BER_BVISNULL( &m.e_nname ) ) { - entry_clean( &m ); + backsql_entry_clean( op, &m ); } if ( bsi.bsi_attrs != NULL ) { diff --git a/servers/slapd/back-sql/modrdn.c b/servers/slapd/back-sql/modrdn.c index ade189bae8..ce904498e2 100644 --- a/servers/slapd/back-sql/modrdn.c +++ b/servers/slapd/back-sql/modrdn.c @@ -449,7 +449,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) if ( BACKSQL_CHECK_SCHEMA( bi ) ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; - entry_clean( &r ); + backsql_entry_clean( op, &r ); (void)backsql_free_entryID( op, &e_id, 0 ); bsi.bsi_e = &r; @@ -574,15 +574,15 @@ done:; } if ( !BER_BVISNULL( &r.e_nname ) ) { - entry_clean( &r ); + backsql_entry_clean( op, &r ); } if ( !BER_BVISNULL( &p.e_nname ) ) { - entry_clean( &p ); + backsql_entry_clean( op, &p ); } if ( !BER_BVISNULL( &n.e_nname ) ) { - entry_clean( &n ); + backsql_entry_clean( op, &n ); } Debug( LDAP_DEBUG_TRACE, "<==backsql_modrdn()\n", 0, 0, 0 ); diff --git a/servers/slapd/back-sql/proto-sql.h b/servers/slapd/back-sql/proto-sql.h index 8019284223..4cdc28d202 100644 --- a/servers/slapd/back-sql/proto-sql.h +++ b/servers/slapd/back-sql/proto-sql.h @@ -169,6 +169,8 @@ int backsql_init_search( backsql_srch_info *bsi, Operation *op, SlapReply *rs, AttributeName *attrs, unsigned flags ); +void backsql_entry_clean( Operation *op, Entry *e ); + /* * sql-wrap.h */ @@ -283,6 +285,7 @@ extern BI_op_delete backsql_delete; extern BI_operational backsql_operational; extern BI_entry_get_rw backsql_entry_get; +extern BI_entry_release_rw backsql_entry_release; extern BI_connection_destroy backsql_connection_destroy; diff --git a/servers/slapd/back-sql/rdbms_depend/pgsql/backsql_drop.sql b/servers/slapd/back-sql/rdbms_depend/pgsql/backsql_drop.sql index 49e7e3acd1..eff0a9ef53 100644 --- a/servers/slapd/back-sql/rdbms_depend/pgsql/backsql_drop.sql +++ b/servers/slapd/back-sql/rdbms_depend/pgsql/backsql_drop.sql @@ -1,4 +1,3 @@ -DROP TABLE ldap_referrals; DROP TABLE ldap_entry_objclasses; DROP TABLE ldap_attr_mappings; DROP TABLE ldap_entries; diff --git a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_drop.sql b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_drop.sql index 17b12afd42..908cd44123 100644 --- a/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_drop.sql +++ b/servers/slapd/back-sql/rdbms_depend/pgsql/testdb_drop.sql @@ -3,3 +3,4 @@ DROP TABLE institutes; DROP TABLE documents; DROP TABLE authors_docs; DROP TABLE phones; +DROP TABLE referrals; diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index da3cea0d21..c78920f926 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -2096,7 +2096,7 @@ backsql_search( Operation *op, SlapReply *rs ) } else { rs->sr_err = LDAP_OTHER; } - entry_clean( &user_entry2 ); + backsql_entry_clean( op, &user_entry2 ); } if ( bsi2.bsi_attrs != NULL ) { op->o_tmpfree( bsi2.bsi_attrs, @@ -2218,7 +2218,7 @@ backsql_search( Operation *op, SlapReply *rs ) next_entry:; if ( e == &user_entry ) { - entry_clean( &user_entry ); + backsql_entry_clean( op, &user_entry ); } next_entry2:; @@ -2245,10 +2245,10 @@ send_results:; send_ldap_result( op, rs ); } - entry_clean( &base_entry ); + backsql_entry_clean( op, &base_entry ); /* in case we got here accidentally */ - entry_clean( &user_entry ); + backsql_entry_clean( op, &user_entry ); if ( rs->sr_v2ref ) { ber_bvarray_free( rs->sr_v2ref ); @@ -2390,3 +2390,39 @@ return_results:; return rc; } +void +backsql_entry_clean( + Operation *op, + Entry *e ) +{ + void *ctx; + + ctx = ldap_pvt_thread_pool_context(); + + if ( ctx == NULL || ctx == op->o_tmpmemctx ) { + if ( !BER_BVISNULL( &e->e_name ) ) { + op->o_tmpfree( e->e_name.bv_val, op->o_tmpmemctx ); + BER_BVZERO( &e->e_name ); + } + + if ( !BER_BVISNULL( &e->e_nname ) ) { + op->o_tmpfree( e->e_nname.bv_val, op->o_tmpmemctx ); + BER_BVZERO( &e->e_nname ); + } + } + + entry_clean( e ); +} + +int +backsql_entry_release( + Operation *op, + Entry *e, + int rw ) +{ + backsql_entry_clean( op, e ); + + ch_free( e ); + + return 0; +} -- 2.39.5