--- parser3/src/main/pa_sql_driver_manager.C 2003/03/24 17:24:42 1.69.2.17.2.9 +++ parser3/src/main/pa_sql_driver_manager.C 2003/11/20 17:15:12 1.75 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_SQL_DRIVER_MANAGER_C="$Date: 2003/03/24 17:24:42 $"; +static const char * const IDENT_SQL_DRIVER_MANAGER_C="$Date: 2003/11/20 17:15:12 $"; #include "pa_sql_driver_manager.h" #include "ltdl.h" @@ -44,20 +44,19 @@ 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*/, +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++) + for(size_t i=0; itop_index(); i++) expire_connection(*stack->get(i), older_dies); } // SQL_Driver_manager SQL_Driver_manager::SQL_Driver_manager(): - prev_expiration_pass_time(0), is_dlinited(false) { + is_dlinited(false), prev_expiration_pass_time(0) { - cache_managers.put(StringBody("sql"), this); + cache_managers.put(String::Body("sql"), this); } SQL_Driver_manager::~SQL_Driver_manager() { @@ -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