Package(metaproxy_1::Session &session,
const metaproxy_1::Origin &origin);
- /// shallow copy constructor which only copies the filter chain info
+ /// copy constructor which copies route pos + logger
Package & copy_filter(const Package &p);
+ /// copy constructor which only copies the filter chain info
+ void copy_route(const Package &p);
+
/// send Package to it's next Filter defined in Router
void move();
Session session() const;
void log(const char *module, int level, const char *fmt, ...);
-
- void reset_log(std::string &res);
+ void log_write(const char *buf, size_t sz);
+ void log_enable(void);
+ void log_reset(std::string &res);
class PackageLogger;
typedef boost::shared_ptr<PackageLogger> PackageLoggerPtr;
mp::Package *p = new mp::Package(m_session, m_origin);
mp::ThreadPoolPackage *tp = new mp::ThreadPoolPackage(p, this);
- p->copy_filter(*m_package);
+ p->copy_route(*m_package);
p->request() = yazpp_1::GDU(z_pdu);
m_thread_pool_observer->put(tp);
}
mp::Package *p = new mp::Package(m_session, m_origin);
mp::ThreadPoolPackage *tp = new mp::ThreadPoolPackage(p, this);
- p->copy_filter(*m_package);
+ p->copy_route(*m_package);
m_thread_pool_observer->put(tp);
}
{
package.origin().set_custom_session(arg->value);
}
-
+ else if (!strcmp(arg->name, "x-log-enable"))
+ {
+ if (*arg->value == '1')
+ package.log_enable();
+ }
assert(sru_pdu_req);
// filter acts as sink for SRU explain requests
std::string l;
- package.reset_log(l);
+ package.log_reset(l);
if (l.length())
{
WRBUF w = wrbuf_alloc();
#include <stdlib.h>
#include <sys/types.h>
#include "filter_zoom.hpp"
-#include <yaz/zoom.h>
-#include <yaz/yaz-version.h>
-#include <yaz/tpath.h>
-#include <yaz/srw.h>
#include <metaproxy/package.hpp>
#include <metaproxy/util.hpp>
#include <metaproxy/xmlutil.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
+
+#include <yaz/yaz-version.h>
+#include <yaz/tpath.h>
+#include <yaz/srw.h>
#include <yaz/ccl_xml.h>
#include <yaz/ccl.h>
#include <yaz/rpn2cql.h>
#include <yaz/querytowrbuf.h>
#include <yaz/sortspec.h>
#include <yaz/tokenizer.h>
+#include <yaz/zoom.h>
namespace mp = metaproxy_1;
namespace yf = mp::filter;
friend class Impl;
friend class Frontend;
std::string zurl;
+ WRBUF m_apdu_wrbuf;
ZOOM_connection m_connection;
ZOOM_resultset m_resultset;
std::string m_frontend_database;
yf::Zoom::Backend::Backend(SearchablePtr ptr) : sptr(ptr)
{
+ m_apdu_wrbuf = wrbuf_alloc();
m_connection = ZOOM_connection_create(0);
+ ZOOM_connection_save_apdu_wrbuf(m_connection, m_apdu_wrbuf);
m_resultset = 0;
xsp = 0;
}
else if (gdu->which == Z_GDU_Z3950)
{
Z_APDU *apdu_req = gdu->u.z3950;
+
+ if (m_backend)
+ wrbuf_rewind(m_backend->m_apdu_wrbuf);
if (apdu_req->which == Z_APDU_initRequest)
{
mp::odr odr;
"zoom filter cannot handle this APDU");
package.session().close();
}
+ if (m_backend)
+ {
+ WRBUF w = m_backend->m_apdu_wrbuf;
+ package.log_write(wrbuf_buf(w), wrbuf_len(w));
+ }
}
else
{
}
mp::Package::Package()
- : m_route_pos(0), p_logger(new PackageLogger)
+ : m_route_pos(0)
{
}
mp::Package::Package(mp::Session &session, const mp::Origin &origin)
: m_session(session), m_origin(origin),
- m_route_pos(0), p_logger(new PackageLogger)
+ m_route_pos(0)
{
}
-
mp::Package & mp::Package::copy_filter(const Package &p)
{
- delete m_route_pos;
- m_route_pos = p.m_route_pos->clone();
p_logger = p.p_logger;
+ copy_route(p);
return *this;
}
+void mp::Package::copy_route(const Package &p)
+{
+ delete m_route_pos;
+ m_route_pos = p.m_route_pos->clone();
+}
void mp::Package::move()
{
va_end(ap);
yaz_log(level, "%s", os.str().c_str());
- p_logger->str += std::string(module) + std::string(buf) + std::string("\n");
+ if (p_logger)
+ p_logger->str += std::string(module) + std::string(buf) + std::string("\n");
}
-void mp::Package::reset_log(std::string &res)
+void mp::Package::log_enable(void)
{
- res = p_logger->str;
- p_logger->str.clear();
+ p_logger.reset(new PackageLogger);
+}
+
+void mp::Package::log_write(const char *buf, size_t sz)
+{
+ if (p_logger)
+ p_logger->str += std::string(buf, sz);
+}
+
+void mp::Package::log_reset(std::string &res)
+{
+ if (p_logger)
+ {
+ res = p_logger->str;
+ // p_logger->str.clear();
+ p_logger.reset();
+ }
}
/*