--- parser3/src/main/pa_sql_driver_manager.C 2003/03/24 17:12:34 1.69.2.17.2.8 +++ parser3/src/main/pa_sql_driver_manager.C 2003/07/24 11:31:24 1.71 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_SQL_DRIVER_MANAGER_C="$Date: 2003/03/24 17:12:34 $"; +static const char* IDENT_SQL_DRIVER_MANAGER_C="$Date: 2003/07/24 11:31:24 $"; #include "pa_sql_driver_manager.h" #include "ltdl.h" @@ -44,11 +44,10 @@ static void expire_connection(SQL_Connec if(connection.connected() && connection.expired(older_dies)) connection.disconnect(); } -static void expire_connections( - SQL_Driver_manager::connection_cache_type::key_type /*key*/, - SQL_Driver_manager::connection_cache_type::value_type stack, - time_t older_dies) { - for(int i=0; i<=stack->top_index(); i++) +static void expire_connections(SQL_Driver_manager::connection_cache_type::key_type /*key*/, + SQL_Driver_manager::connection_cache_type::value_type stack, + time_t older_dies) { + for(size_t i=0; itop(); i++) expire_connection(*stack->get(i), older_dies); } @@ -90,11 +89,13 @@ SQL_Connection* SQL_Driver_manager::get_ if(connection) url_cstr=0; // calm, compiler else { // no cached connection or it were unpingabe: connect/reconnect - if(aurl.pos("://")==STRING_NOT_FOUND) + url_cstr=aurl.cstrm(); + if(!strstr(url_cstr, "://")) throw Exception("parser.runtime", aurl.length()?&aurl:0, "connection string must start with protocol://"); + char *protocol_cstr=lsplit(&url_cstr, ':'); // skip "//" after ':' while(*url_cstr=='/') @@ -107,7 +108,8 @@ SQL_Connection* SQL_Driver_manager::get_ // no cached const String* library=0; const String* dlopen_file_spec=0; - if(protocol2driver_and_client->locate(0, protocol)) { + Table::Action_options options; + if(protocol2driver_and_client->locate(0, protocol, options)) { if(!(library=protocol2driver_and_client->item(1)) || library->length()==0) throw Exception("parser.runtime", 0, @@ -182,7 +184,7 @@ SQL_Connection* SQL_Driver_manager::get_ } void SQL_Driver_manager::close_connection(connection_cache_type::key_type url, - SQL_Connection* connection) { + SQL_Connection* connection) { put_connection_to_cache(url, connection); } @@ -205,12 +207,11 @@ void SQL_Driver_manager::put_driver_to_c // connection cache /// @todo get rid of memory spending Stack [zeros deep inside got accumulated] -SQL_Connection* SQL_Driver_manager::get_connection_from_cache( - connection_cache_type::key_type url) { +SQL_Connection* SQL_Driver_manager::get_connection_from_cache(connection_cache_type::key_type url) { SYNCHRONIZED; if(connection_cache_type::value_type connections=connection_cache.get(url)) - while(connections->top_index()>=0) { // there are cached connections to that 'url' + while(!connections->is_empty()) { // there are cached connections to that 'url' SQL_Connection* result=connections->pop(); if(result->connected()) // not expired? return result; @@ -247,7 +248,6 @@ static void add_connection_to_status_cac Table& table=*static_cast(info); if(connection.connected()) { - =table.pool(); Array& row=*new Array(); // url