#include "schema-map.h"
#include "util.h"
+#define BACKSQL_DUPLICATE (-1)
+
/*
* Uses the pointer to the ObjectClass structure
*/
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 )
{
*/
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 );
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 );