X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Ffilter_session_shared.cpp;h=a787c44866f155a4fe7bce9cb675f0fada518cc1;hb=36c91e43abe9f4792bf1f7993552997fe9d157ce;hp=48aabee8149195b24d7d99a91b7a49758610406d;hpb=b80f4b3d531f36265ea46d337cb7e1000604cafb;p=metaproxy-moved-to-github.git diff --git a/src/filter_session_shared.cpp b/src/filter_session_shared.cpp index 48aabee..a787c44 100644 --- a/src/filter_session_shared.cpp +++ b/src/filter_session_shared.cpp @@ -1,7 +1,7 @@ -/* $Id: filter_session_shared.cpp,v 1.8 2006-05-15 10:34:40 adam Exp $ +/* $Id: filter_session_shared.cpp,v 1.11 2006-06-10 14:29:12 adam Exp $ Copyright (c) 2005-2006, Index Data. -%LICENSE% + See the LICENSE file for details */ #include "config.hpp" @@ -25,12 +25,11 @@ #include namespace mp = metaproxy_1; -namespace yf = mp::filter; +namespace yf = metaproxy_1::filter; namespace metaproxy_1 { namespace filter { - int memcmp2(const void *buf1, int len1, const void *buf2, int len2); class SessionShared::InitKey { public: @@ -76,25 +75,6 @@ namespace metaproxy_1 { } } -int yf::memcmp2(const void *buf1, int len1, - const void *buf2, int len2) -{ - int d = len1 - len2; - - // compare buffer (common length) - int c = memcmp(buf1, buf2, d > 0 ? len2 : len1); - if (c > 0) - return 1; - else if (c < 0) - return -1; - - // compare (remaining bytes) - if (d > 0) - return 1; - else if (d < 0) - return -1; - return 0; -} yf::SessionShared::InitKey::InitKey(Z_InitRequest *req) { @@ -113,15 +93,16 @@ bool yf::SessionShared::InitKey::operator < (const SessionShared::InitKey &k) const { int c; - c = memcmp2((void*) m_idAuthentication_buf, m_idAuthentication_size, - (void*) k.m_idAuthentication_buf, k.m_idAuthentication_size); + c = mp::util::memcmp2( + (void*) m_idAuthentication_buf, m_idAuthentication_size, + (void*) k.m_idAuthentication_buf, k.m_idAuthentication_size); if (c < 0) return true; else if (c > 0) return false; - c = memcmp2((void*) m_otherInfo_buf, m_otherInfo_size, - (void*) k.m_otherInfo_buf, k.m_otherInfo_size); + c = mp::util::memcmp2((void*) m_otherInfo_buf, m_otherInfo_size, + (void*) k.m_otherInfo_buf, k.m_otherInfo_size); if (c < 0) return true; else if (c > 0) @@ -129,7 +110,7 @@ bool yf::SessionShared::InitKey::operator < (const SessionShared::InitKey &k) return false; } -void yf::SessionShared::Frontend::init(Package &package, Z_GDU *gdu) +void yf::SessionShared::Frontend::init(mp::Package &package, Z_GDU *gdu) { Z_InitRequest *req = gdu->u.z3950->u.initRequest; @@ -137,12 +118,14 @@ void yf::SessionShared::Frontend::init(Package &package, Z_GDU *gdu) mp::util::get_vhost_otherinfo(&req->otherInfo, false, targets); + // std::cout << "SessionShared::Frontend::init\n"; if (targets.size() < 1) { + // no targets given, just relay this one and don't deal with it package.move(); return; } - + InitKey k(req); } yf::SessionShared::SessionShared() : m_p(new SessionShared::Rep) @@ -157,7 +140,7 @@ yf::SessionShared::Frontend::Frontend(Rep *rep) : m_is_virtual(false), m_p(rep) { } -void yf::SessionShared::Frontend::close(Package &package) +void yf::SessionShared::Frontend::close(mp::Package &package) { #if 0 std::list::const_iterator b_it; @@ -178,7 +161,7 @@ yf::SessionShared::Frontend::~Frontend() { } -yf::SessionShared::FrontendPtr yf::SessionShared::Rep::get_frontend(Package &package) +yf::SessionShared::FrontendPtr yf::SessionShared::Rep::get_frontend(mp::Package &package) { boost::mutex::scoped_lock lock(m_mutex); @@ -203,7 +186,7 @@ yf::SessionShared::FrontendPtr yf::SessionShared::Rep::get_frontend(Package &pac return f; } -void yf::SessionShared::Rep::release_frontend(Package &package) +void yf::SessionShared::Rep::release_frontend(mp::Package &package) { boost::mutex::scoped_lock lock(m_mutex); std::map::iterator it; @@ -225,7 +208,7 @@ void yf::SessionShared::Rep::release_frontend(Package &package) } -void yf::SessionShared::process(Package &package) const +void yf::SessionShared::process(mp::Package &package) const { FrontendPtr f = m_p->get_frontend(package);