From: Pierangelo Masarati Date: Sat, 10 Jan 2004 11:12:53 +0000 (+0000) Subject: cleanup avl duplicate handling X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~44 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=93725181afc1cadccc749a9f0596d5ec9f1054a4;p=openldap cleanup avl duplicate handling --- diff --git a/servers/slapd/back-sql/schema-map.c b/servers/slapd/back-sql/schema-map.c index 1d9c85c5e3..f73114b3ed 100644 --- a/servers/slapd/back-sql/schema-map.c +++ b/servers/slapd/back-sql/schema-map.c @@ -33,6 +33,8 @@ #include "schema-map.h" #include "util.h" +#define BACKSQL_DUPLICATE (-1) + /* * Uses the pointer to the ObjectClass structure */ @@ -63,16 +65,6 @@ backsql_cmp_attr( const void *v_m1, const void *v_m2 ) return SLAP_PTRCMP( m1->bam_ad, m2->bam_ad ); } -/* - * Dummy duplicate handling function (required by avl_insert) - */ -#define BACKSQL_DUPLICATE (-1) -static int -backsql_dup_dummy(void *p1, void *p2) -{ - return BACKSQL_DUPLICATE; -} - int backsql_dup_attr( void *v_m1, void *v_m2 ) { @@ -324,13 +316,13 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh ) */ oc_map->bom_attrs = NULL; - if ( avl_insert( &si->oc_by_oc, oc_map, backsql_cmp_oc, backsql_dup_dummy ) == BACKSQL_DUPLICATE ) { + if ( avl_insert( &si->oc_by_oc, oc_map, backsql_cmp_oc, avl_dup_error ) == -1 ) { Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): " "duplicate objectClass \"%s\" in objectClass map\n", oc_map->bom_oc->soc_cname.bv_val, 0, 0 ); return LDAP_OTHER; } - if ( avl_insert( &si->oc_by_id, oc_map, backsql_cmp_oc_id, backsql_dup_dummy ) == BACKSQL_DUPLICATE ) { + if ( avl_insert( &si->oc_by_id, oc_map, backsql_cmp_oc_id, avl_dup_error ) == -1 ) { Debug( LDAP_DEBUG_TRACE, "backsql_load_schema_map(): " "duplicate objectClass \"%s\" in objectClass by ID map\n", oc_map->bom_oc->soc_cname.bv_val, 0, 0 ); diff --git a/servers/slapd/back-sql/sql-wrap.c b/servers/slapd/back-sql/sql-wrap.c index f44ffe8dda..414aeafc54 100644 --- a/servers/slapd/back-sql/sql-wrap.c +++ b/servers/slapd/back-sql/sql-wrap.c @@ -396,13 +396,18 @@ backsql_open_db_conn( backsql_info *si, int ldap_cid, backsql_db_conn **pdbc ) Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " "SQLGetInfo() failed:\n", 0, 0, 0 ); backsql_PrintErrors( si->db_env, dbc->dbh, SQL_NULL_HENV, rc ); + return rc; } /* end TimesTen */ Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(): " "connected, adding to tree\n", 0, 0, 0 ); ldap_pvt_thread_mutex_lock( &si->dbconn_mutex ); - avl_insert( &si->db_conns, dbc, backsql_cmp_connid, NULL ); + if ( avl_insert( &si->db_conns, dbc, backsql_cmp_connid, avl_dup_error ) ) { + Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: " + "duplicate connection ID\n", 0, 0, 0 ); + return LDAP_OTHER; + } ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex ); Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn()\n", 0, 0, 0 );