]> git.sur5r.net Git - openldap/commitdiff
more cleanup
authorPierangelo Masarati <ando@openldap.org>
Sun, 7 Aug 2005 22:22:27 +0000 (22:22 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sun, 7 Aug 2005 22:22:27 +0000 (22:22 +0000)
servers/slapd/back-sql/init.c
servers/slapd/back-sql/proto-sql.h
servers/slapd/back-sql/sql-wrap.c

index 7db87c5d7520b2194c0da8a0bfa14dd351ca0f65..1c9913febd044387ef747812dbc8dddf1134451b 100644 (file)
@@ -567,8 +567,14 @@ int
 backsql_db_close(
        BackendDB       *bd )
 {
+       backsql_info    *bi = (backsql_info*)bd->be_private;
+
        Debug( LDAP_DEBUG_TRACE, "==>backsql_db_close()\n", 0, 0, 0 );
+
+       backsql_conn_destroy( bi );
+
        Debug( LDAP_DEBUG_TRACE, "<==backsql_db_close()\n", 0, 0, 0 );
+
        return 0;
 }
 
index 7112812b8645e8a54c812353065767ee97235523..16a7ec66833b89b82deba75f0a6470fdd1e64ac4 100644 (file)
@@ -213,6 +213,8 @@ RETCODE backsql_FreeRow( BACKSQL_ROW_NTS *row );
 
 void backsql_PrintErrors( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT sth, int rc );
 
+int backsql_conn_destroy( backsql_info *bi );
+
 int backsql_init_db_env( backsql_info *si );
 
 int backsql_free_db_env( backsql_info *si );
index 9bc7d3d7fc926ed424252a42668bb224d00cf9cc..aaa0a1ac640b2feef89f8442f2e4b9f72454b89b 100644 (file)
@@ -253,10 +253,13 @@ backsql_cmp_connid( const void *v_c1, const void *v_c2 )
        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
@@ -270,9 +273,17 @@ backsql_close_db_conn( backsql_db_conn *conn )
        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
@@ -326,13 +337,15 @@ backsql_open_db_conn( backsql_info *bi, unsigned long ldap_cid, backsql_db_conn
        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;
@@ -343,9 +356,9 @@ backsql_open_db_conn( backsql_info *bi, unsigned long ldap_cid, backsql_db_conn
                        (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 );
@@ -372,28 +385,28 @@ backsql_open_db_conn( backsql_info *bi, unsigned long ldap_cid, backsql_db_conn
        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;
 
@@ -421,7 +434,7 @@ backsql_free_db_conn( Operation *op )
                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 );