projects
/
metaproxy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove the test for "config-zurg.xml" as that file will be omitted
[metaproxy-moved-to-github.git]
/
src
/
filter_session_shared.cpp
diff --git
a/src/filter_session_shared.cpp
b/src/filter_session_shared.cpp
index
ee06d30
..
91ed879
100644
(file)
--- a/
src/filter_session_shared.cpp
+++ b/
src/filter_session_shared.cpp
@@
-1,5
+1,5
@@
-/* $Id: filter_session_shared.cpp,v 1.1 2005-11-14 23:35:22 adam Exp $
- Copyright (c) 2005, Index Data.
+/* $Id: filter_session_shared.cpp,v 1.7 2006-03-16 10:40:59 adam Exp $
+ Copyright (c) 2005-2006, Index Data.
%LICENSE%
*/
%LICENSE%
*/
@@
-7,7
+7,6
@@
#include "config.hpp"
#include "filter.hpp"
#include "config.hpp"
#include "filter.hpp"
-#include "router.hpp"
#include "package.hpp"
#include <boost/thread/mutex.hpp>
#include "package.hpp"
#include <boost/thread/mutex.hpp>
@@
-24,36
+23,37
@@
#include <map>
#include <iostream>
#include <map>
#include <iostream>
-namespace yf = yp2::filter;
+namespace mp = metaproxy_1;
+namespace yf = mp::filter;
-namespace yp2 {
+namespace metaproxy_1 {
namespace filter {
namespace filter {
- class Session_shared::Rep {
- friend class Session_shared;
+ class SessionShared::Rep {
+ friend class SessionShared;
void handle_init(Z_InitRequest *req, Package &package);
void handle_init(Z_InitRequest *req, Package &package);
- void handle_search(Z_SearchRequest *req, Package &package);
+ void handle_search(Z_APDU *req, Package &package);
public:
public:
- typedef boost::shared_ptr<Session_shared::List> SharedList;
+ typedef boost::shared_ptr<SessionShared::List> SharedList;
- typedef std::map<Session_shared::InitKey,SharedList> InitListMap;
+ typedef std::map<SessionShared::InitKey,SharedList> InitListMap;
InitListMap m_init_list_map;
typedef std::map<Session,SharedList> SessionListMap;
SessionListMap m_session_list_map;
};
InitListMap m_init_list_map;
typedef std::map<Session,SharedList> SessionListMap;
SessionListMap m_session_list_map;
};
- class Session_shared::InitKey {
- friend class Session_shared;
- friend class Session_shared::Rep;
+ class SessionShared::InitKey {
+ friend class SessionShared;
+ friend class SessionShared::Rep;
std::string m_vhost;
std::string m_open;
std::string m_user;
std::string m_group;
std::string m_password;
public:
std::string m_vhost;
std::string m_open;
std::string m_user;
std::string m_group;
std::string m_password;
public:
- bool operator < (const Session_shared::InitKey &k) const;
+ bool operator < (const SessionShared::InitKey &k) const;
};
};
- class Session_shared::List {
+ class SessionShared::List {
public:
yazpp_1::GDU m_init_response; // init response for backend
Session m_session; // session for backend
public:
yazpp_1::GDU m_init_response; // init response for backend
Session m_session; // session for backend
@@
-62,10
+62,11
@@
namespace yp2 {
}
}
+using namespace mp;
-using namespace yp2;
-
-bool yf::Session_shared::InitKey::operator < (const Session_shared::InitKey &k) const {
+bool yf::SessionShared::InitKey::operator < (const SessionShared::InitKey
+ &k) const
+{
if (m_vhost < k.m_vhost)
return true;
else if (m_vhost < k.m_vhost)
if (m_vhost < k.m_vhost)
return true;
else if (m_vhost < k.m_vhost)
@@
-93,26
+94,29
@@
bool yf::Session_shared::InitKey::operator < (const Session_shared::InitKey &k)
return false;
}
return false;
}
-yf::Session_shared::Session_shared() : m_p(new Rep)
+yf::SessionShared::SessionShared() : m_p(new Rep)
{
}
{
}
-yf::Session_shared::~Session_shared()
+yf::SessionShared::~SessionShared()
{
}
{
}
-void yf::Session_shared::Rep::handle_search(Z_SearchRequest *req,
- Package &package)
+void yf::SessionShared::Rep::handle_search(Z_APDU *apdu_req,
+ Package &package)
{
yaz_log(YLOG_LOG, "Got search");
{
yaz_log(YLOG_LOG, "Got search");
+ // Z_SearchRequest *req = apdu_req->u.searchRequest;
+
SessionListMap::iterator it = m_session_list_map.find(package.session());
if (it == m_session_list_map.end())
{
SessionListMap::iterator it = m_session_list_map.find(package.session());
if (it == m_session_list_map.end())
{
- yp2::odr odr;
- package.response() = odr.create_close(
- Z_Close_protocolError,
- "no session for search request in session_shared");
+ mp::odr odr;
+ package.response() =
+ odr.create_close(apdu_req,
+ Z_Close_protocolError,
+ "no session for search request in session_shared");
package.session().close();
return;
package.session().close();
return;
@@
-127,11
+131,11
@@
void yf::Session_shared::Rep::handle_search(Z_SearchRequest *req,
package.response() = search_package.response();
}
package.response() = search_package.response();
}
-void yf::Session_shared::Rep::handle_init(Z_InitRequest *req, Package &package)
+void yf::SessionShared::Rep::handle_init(Z_InitRequest *req, Package &package)
{
yaz_log(YLOG_LOG, "Got init");
{
yaz_log(YLOG_LOG, "Got init");
- Session_shared::InitKey key;
+ SessionShared::InitKey key;
const char *vhost =
yaz_oi_get_string_oidval(&req->otherInfo, VAL_PROXY, 1, 0);
if (vhost)
const char *vhost =
yaz_oi_get_string_oidval(&req->otherInfo, VAL_PROXY, 1, 0);
if (vhost)
@@
-174,7
+178,7
@@
void yf::Session_shared::Rep::handle_init(Z_InitRequest *req, Package &package)
yaz_log(YLOG_LOG, "New KEY");
// building new package with original init and new session
yaz_log(YLOG_LOG, "New KEY");
// building new package with original init and new session
- SharedList l(new Session_shared::List); // new session for backend
+ SharedList l(new SessionShared::List); // new session for backend
Package init_package(l->m_session, package.origin());
init_package.copy_filter(package);
Package init_package(l->m_session, package.origin());
init_package.copy_filter(package);
@@
-208,7
+212,7
@@
void yf::Session_shared::Rep::handle_init(Z_InitRequest *req, Package &package)
}
}
}
}
-void yf::Session_shared::process(Package &package) const
+void yf::SessionShared::process(Package &package) const
{
// don't tell the backend if the "fronent" filter closes..
// we want to keep them alive
{
// don't tell the backend if the "fronent" filter closes..
// we want to keep them alive
@@
-230,13
+234,13
@@
void yf::Session_shared::process(Package &package) const
m_p->handle_init(apdu->u.initRequest, package);
break;
case Z_APDU_searchRequest:
m_p->handle_init(apdu->u.initRequest, package);
break;
case Z_APDU_searchRequest:
- m_p->handle_search(apdu->u.searchRequest, package);
+ m_p->handle_search(apdu, package);
break;
default:
break;
default:
- yp2::odr odr;
- package.response() = odr.create_close(
- Z_Close_protocolError,
- "cannot handle a package of this type");
+ mp::odr odr;
+ package.response() =
+ odr.create_close(apdu, Z_Close_protocolError,
+ "cannot handle a package of this type");
package.session().close();
break;
package.session().close();
break;
@@
-249,6
+253,20
@@
void yf::Session_shared::process(Package &package) const
package.move(); // Not Z39.50 or not Init
}
package.move(); // Not Z39.50 or not Init
}
+static mp::filter::Base* filter_creator()
+{
+ return new mp::filter::SessionShared;
+}
+
+extern "C" {
+ struct metaproxy_1_filter_struct metaproxy_1_filter_session_shared = {
+ 0,
+ "session_shared",
+ filter_creator
+ };
+}
+
+
/*
* Local variables:
/*
* Local variables: