From 807b4a4f2f12f18ecd7ffe4198e7d3c7053f2c36 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 9 Sep 2011 11:00:20 +0200 Subject: [PATCH] Fix bug #4612: session_shared returns diagnostic 2 The problem was that a session was marked "in use" in cases where there were no network activity on target (caching , research).. MP would update its timestamp of last use when it was not really used.. MP now only marks last use timestamp on network activity. The expire loop now waits session_ttl / 3 seconds - was 30 before - to ensure that configurations with low session ttl's will expire properly. --- src/filter_session_shared.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/filter_session_shared.cpp b/src/filter_session_shared.cpp index 98d4497..4d4606a 100644 --- a/src/filter_session_shared.cpp +++ b/src/filter_session_shared.cpp @@ -104,6 +104,7 @@ namespace metaproxy_1 { time_t m_time_last_use; mp::Package * m_close_package; ~BackendInstance(); + void timestamp(); }; // backends of some class (all with same InitKey) class SessionShared::BackendClass : boost::noncopyable { @@ -331,10 +332,15 @@ yf::SessionShared::BackendClass::get_backend( void yf::SessionShared::BackendClass::use_backend(BackendInstancePtr backend) { backend->m_in_use = true; - time(&backend->m_time_last_use); backend->m_sequence_this = m_sequence_top++; } +void yf::SessionShared::BackendInstance::timestamp() +{ + assert(m_in_use); + time(&m_time_last_use); +} + yf::SessionShared::BackendInstance::~BackendInstance() { delete m_close_package; @@ -687,6 +693,8 @@ restart: else result_set_id = "default"; } + found_backend->timestamp(); + // we must search ... BackendSetPtr new_set(new BackendSet(result_set_id, databases, query)); @@ -881,6 +889,8 @@ void yf::SessionShared::Frontend::present(mp::Package &package, bc->release_backend(found_backend); return; } + + found_backend->timestamp(); Z_APDU *p_apdu = zget_APDU(odr, Z_APDU_presentRequest); Z_PresentRequest *p_req = p_apdu->u.presentRequest; @@ -954,6 +964,7 @@ void yf::SessionShared::Frontend::scan(mp::Package &frontend_package, else { Package scan_package(backend->m_session, frontend_package.origin()); + backend->timestamp(); scan_package.copy_filter(frontend_package); scan_package.request() = apdu_req; scan_package.move(); @@ -1015,7 +1026,7 @@ void yf::SessionShared::Rep::expire() { boost::xtime xt; boost::xtime_get(&xt, boost::TIME_UTC); - xt.sec += 30; + xt.sec += m_session_ttl / 3; boost::thread::sleep(xt); BackendClassMap::const_iterator b_it = m_backend_map.begin(); -- 1.7.10.4