BackendDB *bd )
{
backsql_info *bi;
+ int rc = 0;
Debug( LDAP_DEBUG_TRACE, "==>backsql_db_init()\n", 0, 0, 0 );
- bi = (backsql_info *)ch_malloc( sizeof( backsql_info ) );
- memset( bi, '\0', sizeof( backsql_info ) );
+
+ bi = (backsql_info *)ch_calloc( 1, sizeof( backsql_info ) );
ldap_pvt_thread_mutex_init( &bi->sql_dbconn_mutex );
ldap_pvt_thread_mutex_init( &bi->sql_schema_mutex );
- backsql_init_db_env( bi );
+
+ if ( backsql_init_db_env( bi ) != SQL_SUCCESS ) {
+ rc = -1;
+ }
bd->be_private = bi;
+
Debug( LDAP_DEBUG_TRACE, "<==backsql_db_init()\n", 0, 0, 0 );
- return 0;
+
+ return rc;
}
int
int ret = SQL_SUCCESS;
Debug( LDAP_DEBUG_TRACE, "==>backsql_init_db_env()\n", 0, 0, 0 );
+
rc = SQLAllocEnv( &bi->sql_db_env );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "init_db_env: SQLAllocEnv failed:\n",
SQL_NULL_HENV, rc );
ret = SQL_ERROR;
}
+
Debug( LDAP_DEBUG_TRACE, "<==backsql_init_db_env()=%d\n", ret, 0, 0 );
+
return ret;
}
{
Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_env()\n", 0, 0, 0 );
-#ifdef BACKSQL_TRACE
- Debug( LDAP_DEBUG_TRACE, "free_db_env(): delete AVL tree here!!!\n",
- 0, 0, 0 );
-#endif /* BACKSQL_TRACE */
+ (void)SQLFreeEnv( bi->sql_db_env );
+ bi->sql_db_env = SQL_NULL_HENV;
/*
* stop, if frontend waits for all threads to shutdown
* everything is already deleted...
*/
Debug( LDAP_DEBUG_TRACE, "<==backsql_free_db_env()\n", 0, 0, 0 );
+
return SQL_SUCCESS;
}