--- parser3/src/main/pa_sql_driver_manager.C 2001/05/17 18:26:22 1.17 +++ parser3/src/main/pa_sql_driver_manager.C 2001/05/17 18:43:06 1.19 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_sql_driver_manager.C,v 1.17 2001/05/17 18:26:22 parser Exp $ + $Id: pa_sql_driver_manager.C,v 1.19 2001/05/17 18:43:06 parser Exp $ */ #include "pa_sql_driver_manager.h" @@ -203,6 +203,8 @@ void SQL_Driver_manager::put_driver_to_c SQL_Connection *SQL_Driver_manager::get_connection_from_cache(const String& url) { SYNCHRONIZED; + maybe_expire_connection_cache(); + if(Stack *connections=static_cast(connection_cache.get(url))) while(connections->top_index()>=0) { // there are cached connections to that 'url' SQL_Connection *result=static_cast(connections->pop()); @@ -217,8 +219,6 @@ void SQL_Driver_manager::put_connection_ SQL_Connection& connection) { SYNCHRONIZED; - maybe_expire_connection_cache(); - Stack *connections=static_cast(connection_cache.get(url)); if(!connections) { // there are no cached connections to that 'url' yet? connections=NEW Stack(pool()); // NOTE: never freed up! @@ -230,11 +230,14 @@ void SQL_Driver_manager::put_connection_ static void expire_connection(Array::Item *value, void *info) { SQL_Connection& connection=*static_cast(value); time_t older_dies=reinterpret_cast(info); + if(connection.expired(older_dies)) connection.disconnect(); } static void expire_connections(const Hash::Key& key, Hash::Val *value, void *info) { - static_cast(value)->for_each(expire_connection, info); + Stack& stack=*static_cast(value); + for(int i=0; i<=stack.top_index(); i++) + expire_connection(stack.get(i), info); } void SQL_Driver_manager::maybe_expire_connection_cache() { time_t now=time(0); @@ -245,4 +248,4 @@ void SQL_Driver_manager::maybe_expire_co prev_expiration_pass_time=now; } -} \ No newline at end of file +}