]> git.sur5r.net Git - openldap/commitdiff
cleanup avl duplicate handling
authorPierangelo Masarati <ando@openldap.org>
Sat, 10 Jan 2004 11:12:53 +0000 (11:12 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 10 Jan 2004 11:12:53 +0000 (11:12 +0000)
servers/slapd/back-sql/schema-map.c
servers/slapd/back-sql/sql-wrap.c

index 1d9c85c5e3c6bdd7283bcbc0074e0bbeaa53005d..f73114b3ed3005492486655de18bd383ab153c2e 100644 (file)
@@ -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 );
index f44ffe8dda496f9831fdc42821f61f11f02e2b82..414aeafc54e47ea95c1abfc6593afd196c8ed46a 100644 (file)
@@ -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 );