Added bounce filter at end of each filter chain config.xml to prevent infinite hanging of for example HTTP requests when only Z3950 client filter is configured.
<?xml version="1.0"?>
-<!-- $Id: config-bytarget.xml,v 1.2 2006-06-16 14:01:58 mike Exp $ -->
+<!-- $Id: config-bytarget.xml,v 1.3 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<routes>
<target route="group1">z3950.loc.gov:7090/voyager</target>
<target route="group2">indexdata.dk/gils</target>
</filter>
+ <filter type="bounce"/>
</route>
<route id="group1">
<filter type="query_rewrite">
<filter type="z3950_client">
<timeout>30</timeout>
</filter>
+ <filter type="bounce"/>
</route>
<route id="group2">
<!--
<filter type="z3950_client">
<timeout>30</timeout>
</filter>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
</filter>
<filter name="reject"> <!-- reject .. -->
</filter>
+ <filter type="bounce"/>
</route>
<route id="public">
<filter type="z3950-client">
<target>localhost:9999/A</target>
</filter>
+ <filter type="bounce"/>
</route>
<route id="internal">
<filter type="z3950-client">
<target>localhost:9999/B</target>
</filter>
- </route>
+ <filter type="bounce"/>
+ </route>
<route id="internal">
<xml:include href="file://module2.xml#filter45"/>
<xml:include href="file://module4.xml#filter145"/>
+ <filter type="bounce"/>
</route>
<route id="AB">
<filter type="multi">
<package route="B"/>
<merge type="simple"/>
</filter>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config-local.xml,v 1.1 2006-06-08 22:22:49 mike Exp $ -->
+<!-- $Id: config-local.xml,v 1.2 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<routes>
<filter type="z3950_client">
<timeout>30</timeout>
</filter>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config-shared1.xml,v 1.3 2006-06-21 09:16:53 adam Exp $ -->
+<!-- $Id: config-shared1.xml,v 1.4 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<filters>
<category init-options="true" apdu="false"/>
</filter>
<filter refid="backend"/>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<filter type="z3950_client">
<timeout>30</timeout>
</filter>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config-zurg.xml,v 1.8 2006-01-18 15:05:57 mike Exp $ -->
+<!-- $Id: config-zurg.xml,v 1.9 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<filters>
<filter type="z3950_client">
<timeout>30</timeout>
</filter>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config0.xml,v 1.2 2006-01-18 10:10:40 mike Exp $ -->
+<!-- $Id: config0.xml,v 1.3 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<filters>
<filter id="frontend" type="frontend_net">
<port>@:9000</port>
</filter>
- <filter id="backend" type="z3950_client">
- </filter>
</filters>
<routes>
<route id="start">
<filter refid="frontend"/>
<filter type="log"/>
- <filter refid="backend"/>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config1.xml,v 1.10 2006-01-17 13:31:09 adam Exp $ -->
+<!-- $Id: config1.xml,v 1.11 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<filters>
<route id="start">
<filter refid="frontend"/>
<filter type="log">
- <message>B</message>
+ <message>log</message>
</filter>
<filter refid="backend"/>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config2.xml,v 1.7 2006-01-18 15:06:48 mike Exp $ -->
+<!-- $Id: config2.xml,v 1.8 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<filters>
<filter type="z3950_client">
<timeout>30</timeout>
</filter>
+ <filter type="bounce"/>
</route>
<route id="test">
<filter type="log">
<message>T</message>
</filter>
<filter type="backend_test"/>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config3.xml,v 1.7 2006-05-15 13:53:37 adam Exp $ -->
+<!-- $Id: config3.xml,v 1.8 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<routes>
<filter type="z3950_client">
<timeout>30</timeout>
</filter>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config4.xml,v 1.1 2006-01-25 11:28:23 adam Exp $ -->
+<!-- $Id: config4.xml,v 1.2 2006-08-31 13:01:09 marc Exp $ -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
<!-- sample config which illustrates the use of http_file filter.. -->
<prefix>/etc</prefix>
</area>
</filter>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
<?xml version="1.0"?>
-<!-- $Id: config5.xml,v 1.4 2006-06-19 13:27:49 adam Exp $ -->
+<!-- $Id: config5.xml,v 1.5 2006-08-31 13:01:09 marc Exp $ -->
<!-- Uses dummy backend + query rewrite filter.. -->
<yp2 xmlns="http://indexdata.dk/yp2/config/1">
<start route="start"/>
/>
</filter>
<filter type="backend_test"/>
+ <filter type="bounce"/>
</route>
</routes>
</yp2>
-## $Id: Makefile.am,v 1.52 2006-08-30 10:48:52 adam Exp $
+## $Id: Makefile.am,v 1.53 2006-08-31 13:01:09 marc Exp $
MAINTAINERCLEANFILES = Makefile.in config.in config.hpp
filter.hpp filter.cpp \
filter_auth_simple.cpp filter_auth_simple.hpp \
filter_backend_test.cpp filter_backend_test.hpp \
+ filter_bounce.cpp filter_bounce.hpp \
filter_frontend_net.cpp filter_frontend_net.hpp \
filter_http_file.cpp filter_http_file.hpp \
filter_log.cpp filter_log.hpp \
-/* $Id: factory_static.cpp,v 1.10 2006-06-10 14:29:12 adam Exp $
+/* $Id: factory_static.cpp,v 1.11 2006-08-31 13:01:09 marc Exp $
Copyright (c) 2005-2006, Index Data.
See the LICENSE file for details
#include "filter_auth_simple.hpp"
#include "filter_backend_test.hpp"
+#include "filter_bounce.hpp"
#include "filter_frontend_net.hpp"
#include "filter_http_file.hpp"
#include "filter_log.hpp"
struct metaproxy_1_filter_struct *buildins[] = {
&metaproxy_1_filter_auth_simple,
&metaproxy_1_filter_backend_test,
+ &metaproxy_1_filter_bounce,
&metaproxy_1_filter_frontend_net,
&metaproxy_1_filter_http_file,
&metaproxy_1_filter_log,
--- /dev/null
+/* $Id: filter_bounce.cpp,v 1.1 2006-08-31 13:01:09 marc Exp $
+ Copyright (c) 2005-2006, Index Data.
+
+ See the LICENSE file for details
+ */
+
+#include "filter_bounce.hpp"
+#include "package.hpp"
+#include "util.hpp"
+#include "gduutil.hpp"
+
+#include <yaz/zgdu.h>
+
+#include <sstream>
+
+//#include "config.hpp"
+//#include "filter.hpp"
+
+//#include <boost/thread/mutex.hpp>
+
+
+
+
+
+namespace mp = metaproxy_1;
+namespace yf = mp::filter;
+
+namespace metaproxy_1 {
+ namespace filter {
+ class Bounce::Rep {
+ friend class Bounce;
+ bool bounce;
+ };
+ }
+}
+
+yf::Bounce::Bounce() : m_p(new Rep)
+{
+ m_p->bounce = true;
+}
+
+yf::Bounce::~Bounce()
+{ // must have a destructor because of boost::scoped_ptr
+}
+
+void yf::Bounce::process(mp::Package &package) const
+{
+
+ if (! m_p->bounce ){
+ package.move();
+ return;
+ }
+
+
+ package.session().close();
+
+ Z_GDU *zgdu = package.request().get();
+
+ if (!zgdu)
+ return;
+
+ //std::string message("BOUNCE ");
+ std::ostringstream message;
+ message << "BOUNCE " << *zgdu;
+
+ metaproxy_1::odr odr;
+
+ if (zgdu->which == Z_GDU_Z3950){
+ Z_APDU *apdu_res = 0;
+ apdu_res = odr.create_close(zgdu->u.z3950,
+ Z_Close_systemProblem,
+ message.str().c_str());
+ package.response() = apdu_res;
+ }
+ else if (zgdu->which == Z_GDU_HTTP_Request){
+ Z_GDU *zgdu_res = 0;
+ zgdu_res
+ = odr.create_HTTP_Response(package.session(),
+ zgdu->u.HTTP_Request, 400);
+
+ //zgdu_res->u.HTTP_Response->content_len = message.str().size();
+ //zgdu_res->u.HTTP_Response->content_buf
+ // = (char*) odr_malloc(odr, zgdu_res->u.HTTP_Response->content_len);
+
+ //strncpy(zgdu_res->u.HTTP_Response->content_buf,
+ // message.str().c_str(), zgdu_res->u.HTTP_Response->content_len);
+
+ // z_HTTP_header_add(o, &hres->headers,
+ // "Content-Type", content_type.c_str());
+ package.response() = zgdu_res;
+ }
+ else if (zgdu->which == Z_GDU_HTTP_Response){
+ }
+
+
+ return;
+}
+
+static mp::filter::Base* filter_creator()
+{
+ return new mp::filter::Bounce;
+}
+
+extern "C" {
+ struct metaproxy_1_filter_struct metaproxy_1_filter_bounce = {
+ 0,
+ "bounce",
+ filter_creator
+ };
+}
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * c-file-style: "stroustrup"
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
--- /dev/null
+/* $Id: filter_bounce.hpp,v 1.1 2006-08-31 13:01:09 marc Exp $
+ Copyright (c) 2005-2006, Index Data.
+
+ See the LICENSE file for details
+ */
+
+// Filter that bounces all requests packages
+// No packages are ever passed to later filters in the chain
+#ifndef FILTER_BOUNCE_HPP
+#define FILTER_BOUNCE_HPP
+
+#include <boost/scoped_ptr.hpp>
+
+#include "filter.hpp"
+
+namespace metaproxy_1 {
+ namespace filter {
+ class Bounce : public Base {
+ class Rep;
+ boost::scoped_ptr<Rep> m_p;
+ public:
+ Bounce();
+ ~Bounce();
+ void process(metaproxy_1::Package & package) const;
+ };
+ }
+}
+
+extern "C" {
+ extern struct metaproxy_1_filter_struct metaproxy_1_filter_bounce;
+}
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * c-file-style: "stroustrup"
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */