return 0;
}
-static int
-backsql_close_db_conn( backsql_db_conn *conn )
+static void
+backsql_close_db_conn( void *v_conn )
{
- Debug( LDAP_DEBUG_TRACE, "==>backsql_close_db_conn()\n", 0, 0, 0 );
+ backsql_db_conn *conn = (backsql_db_conn *)v_conn;
+
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_close_db_conn(%lu)\n",
+ conn->ldap_cid, 0, 0 );
/*
* Default transact is SQL_ROLLBACK; commit is required only
SQLFreeConnect( conn->dbh );
ch_free( conn );
- Debug( LDAP_DEBUG_TRACE, "<==backsql_close_db_conn()\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "<==backsql_close_db_conn(%lu)\n",
+ conn->ldap_cid, 0, 0 );
+}
+
+int
+backsql_conn_destroy(
+ backsql_info *bi )
+{
+ avl_free( bi->sql_db_conns, backsql_close_db_conn );
- return 1;
+ return 0;
}
int
assert( pdbc != NULL );
*pdbc = NULL;
- Debug( LDAP_DEBUG_TRACE, "==>backsql_open_db_conn()\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "==>backsql_open_db_conn(%lu)\n",
+ ldap_cid, 0, 0 );
+
dbc = (backsql_db_conn *)ch_calloc( 1, sizeof( backsql_db_conn ) );
dbc->ldap_cid = ldap_cid;
rc = SQLAllocConnect( bi->sql_db_env, &dbc->dbh );
if ( !BACKSQL_SUCCESS( rc ) ) {
- Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: "
- "SQLAllocConnect() failed:\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): "
+ "SQLAllocConnect() failed:\n", ldap_cid, 0, 0 );
backsql_PrintErrors( bi->sql_db_env, SQL_NULL_HDBC,
SQL_NULL_HENV, rc );
return LDAP_UNAVAILABLE;
(SQLCHAR*)bi->sql_dbuser, SQL_NTS,
(SQLCHAR*)bi->sql_dbpasswd, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
- Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: "
- "SQLConnect() to database \"%s\" as user \"%s\" "
- "%s:\n", bi->sql_dbname, bi->sql_dbuser,
+ Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): "
+ "SQLConnect() to database \"%s\" %s.\n",
+ ldap_cid, bi->sql_dbname,
rc == SQL_SUCCESS_WITH_INFO ?
"succeeded with info" : "failed" );
backsql_PrintErrors( bi->sql_db_env, dbc->dbh, SQL_NULL_HENV, rc );
if ( rc == SQL_SUCCESS ) {
if ( strcmp( DBMSName, "TimesTen" ) == 0 ||
strcmp( DBMSName, "Front-Tier" ) == 0 ) {
- Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: "
- "TimesTen database!\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): "
+ "TimesTen database!\n", ldap_cid, 0, 0 );
bi->sql_flags |= BSQLF_USE_REVERSE_DN;
}
} else {
- Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: "
- "SQLGetInfo() failed:\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): "
+ "SQLGetInfo() failed.\n", ldap_cid, 0, 0 );
backsql_PrintErrors( bi->sql_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 );
+ Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): "
+ "connected, adding to tree.\n", ldap_cid, 0, 0 );
ldap_pvt_thread_mutex_lock( &bi->sql_dbconn_mutex );
if ( avl_insert( &bi->sql_db_conns, dbc, backsql_cmp_connid, avl_dup_error ) ) {
- Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn: "
- "duplicate connection ID\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(%lu): "
+ "duplicate connection ID.\n", ldap_cid, 0, 0 );
return LDAP_OTHER;
}
ldap_pvt_thread_mutex_unlock( &bi->sql_dbconn_mutex );
- Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn()\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn(%lu)\n", ldap_cid, 0, 0 );
*pdbc = dbc;
Debug( LDAP_DEBUG_TRACE, "backsql_free_db_conn(): "
"closing db connection %lu (%p)\n",
op->o_connid, conn, 0 );
- backsql_close_db_conn( conn );
+ backsql_close_db_conn( (void *)conn );
}
Debug( LDAP_DEBUG_TRACE, "<==backsql_free_db_conn()\n", 0, 0, 0 );