From d79d9be8401a414a3eedc99d7dd64750c7f9de76 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sun, 7 Aug 2005 21:53:38 +0000 Subject: [PATCH] free Env --- servers/slapd/back-sql/init.c | 14 ++++++++++---- servers/slapd/back-sql/sql-wrap.c | 10 ++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c index 1fd226586a..7db87c5d75 100644 --- a/servers/slapd/back-sql/init.c +++ b/servers/slapd/back-sql/init.c @@ -97,17 +97,23 @@ backsql_db_init( 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 diff --git a/servers/slapd/back-sql/sql-wrap.c b/servers/slapd/back-sql/sql-wrap.c index 5b3cf662d8..9bc7d3d7fc 100644 --- a/servers/slapd/back-sql/sql-wrap.c +++ b/servers/slapd/back-sql/sql-wrap.c @@ -282,6 +282,7 @@ backsql_init_db_env( backsql_info *bi ) 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", @@ -290,7 +291,9 @@ backsql_init_db_env( backsql_info *bi ) SQL_NULL_HENV, rc ); ret = SQL_ERROR; } + Debug( LDAP_DEBUG_TRACE, "<==backsql_init_db_env()=%d\n", ret, 0, 0 ); + return ret; } @@ -299,10 +302,8 @@ backsql_free_db_env( backsql_info *bi ) { 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 @@ -310,6 +311,7 @@ backsql_free_db_env( backsql_info *bi ) * everything is already deleted... */ Debug( LDAP_DEBUG_TRACE, "<==backsql_free_db_env()\n", 0, 0, 0 ); + return SQL_SUCCESS; } -- 2.39.5