<?xml version="1.0"?>
-<!-- $Id: config3.xml,v 1.6 2006-02-02 11:32:22 adam Exp $ -->
+<!-- $Id: config3.xml,v 1.7 2006-05-15 13:53:37 adam Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<routes>
</virtual>
<virtual>
<database>db2</database>
- <target>localhost:9998/Slow</target>
+ <target>localhost:9999/Default</target>
+ </virtual>
+ <virtual>
+ <database>db3</database>
+ <target>bagel.indexdata.dk:80</target>
</virtual>
<virtual>
<database>gils</database>
<message>M</message>
</filter>
<filter type="multi">
+ <hideunavailable/>
</filter>
<filter type="log">
<message>B</message>
-/* $Id: filter_multi.cpp,v 1.17 2006-05-15 13:22:02 adam Exp $
+/* $Id: filter_multi.cpp,v 1.18 2006-05-15 13:53:37 adam Exp $
Copyright (c) 2005-2006, Index Data.
%LICENSE%
friend class Multi;
friend struct Frontend;
+ Rep();
FrontendPtr get_frontend(Package &package);
void release_frontend(Package &package);
private:
boost::mutex m_mutex;
boost::condition m_cond_session_ready;
std::map<mp::Session, FrontendPtr> m_clients;
+ bool m_hide_unavailable;
};
}
}
+yf::Multi::Rep::Rep()
+{
+ m_hide_unavailable = false;
+}
+
bool yf::Multi::BackendSet::operator < (const BackendSet &k) const
{
return m_count < k.m_count;
m_is_multi = true;
// create init request
- std::list<BackendPtr>::const_iterator bit;
+ std::list<BackendPtr>::iterator bit;
for (bit = m_backend_list.begin(); bit != m_backend_list.end(); bit++)
{
mp::odr odr;
ODR_MASK_SET(f_resp->protocolVersion, Z_ProtocolVersion_2);
ODR_MASK_SET(f_resp->protocolVersion, Z_ProtocolVersion_3);
- for (bit = m_backend_list.begin(); bit != m_backend_list.end(); bit++)
+ int no_failed = 0;
+ int no_succeeded = 0;
+ for (bit = m_backend_list.begin(); bit != m_backend_list.end(); )
{
PackagePtr p = (*bit)->m_package;
if (p->session().is_closed()) // if any backend closes, close frontend
- package.session().close();
+ {
+ no_failed++;
+ bit = m_backend_list.erase(bit);
+ continue;
+ }
+ no_succeeded++;
+
Z_GDU *gdu = p->response().get();
if (gdu && gdu->which == Z_GDU_Z3950 && gdu->u.z3950->which ==
Z_APDU_initResponse)
package.response() = p->response();
return;
}
+ bit++;
+ }
+ if (m_p->m_hide_unavailable)
+ {
+ if (no_succeeded == 0)
+ package.session().close();
+ }
+ else
+ {
+ if (no_failed)
+ package.session().close();
}
package.response() = f_apdu;
}
std::cout << "route=" << route << " target=" << target << "\n";
m_p->m_target_route[target] = route;
}
+ else if (!strcmp((const char *) ptr->name, "hideunavailable"))
+ {
+ m_p->m_hide_unavailable = true;
+ }
else
{
throw mp::filter::FilterException