X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_session_shared.cpp;h=9c353fa4af081cffa358f7c5f1419d196a29f55d;hb=4851938e09d4a6dd97fedbd077f11fb9b4d58f48;hp=00b05c911414c00bfd16c3ec86868512f76c5c7f;hpb=9f2dd20cc26c23a736b42e0eb929782f4e76b9e2;p=metaproxy-moved-to-github.git diff --git a/src/filter_session_shared.cpp b/src/filter_session_shared.cpp index 00b05c9..9c353fa 100644 --- a/src/filter_session_shared.cpp +++ b/src/filter_session_shared.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2013 Index Data + Copyright (C) Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -193,6 +193,7 @@ namespace metaproxy_1 { void release_frontend(Package &package); Rep(); public: + ~Rep(); void expire(); private: void expire_classes(); @@ -202,6 +203,7 @@ namespace metaproxy_1 { void start(); boost::mutex m_mutex; boost::condition m_cond_session_ready; + boost::condition m_cond_expire_ready; std::map m_clients; BackendClassMap m_backend_map; @@ -215,6 +217,7 @@ namespace metaproxy_1 { int m_session_max; Odr_int m_preferredMessageSize; Odr_int m_maximumRecordSize; + bool close_down; }; } } @@ -1128,8 +1131,7 @@ void yf::SessionShared::Frontend::present(mp::Package &package, found_set->m_record_cache.add( odr, b_resp->records->u.databaseOrSurDiagnostics, - *req->resultSetStartPoint, - *f_resp->numberOfRecordsReturned); + *req->resultSetStartPoint, p_req->recordComposition); } bc->release_backend(found_backend); } @@ -1240,15 +1242,19 @@ void yf::SessionShared::Rep::expire() { boost::xtime xt; boost::xtime_get(&xt, -#if BOOST_VERSION >= 105000 +#if BOOST_VERSION >= 105000 boost::TIME_UTC_ #else boost::TIME_UTC #endif ); xt.sec += m_session_ttl / 3; - boost::thread::sleep(xt); - + { + boost::mutex::scoped_lock lock(m_mutex); + m_cond_expire_ready.timed_wait(lock, xt); + if (close_down) + break; + } stat(); expire_classes(); } @@ -1264,6 +1270,17 @@ yf::SessionShared::Rep::Rep() m_session_max = 100; m_preferredMessageSize = 0; m_maximumRecordSize = 0; + close_down = false; +} + +yf::SessionShared::Rep::~Rep() +{ + { + boost::mutex::scoped_lock lock(m_mutex); + close_down = true; + m_cond_expire_ready.notify_all(); + } + m_thrds.join_all(); } void yf::SessionShared::Rep::start()