X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_frontend_net.cpp;h=0fef9e6689126f6a2ae6f81361b944b936b7a24f;hb=15e63ff49000e082d8387c243941485ccacff13b;hp=d4867ad14a557bd3583eae6a35f09d0204d24836;hpb=73f37c91c144b070020df2f27472c09b62367acf;p=metaproxy-moved-to-github.git diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index d4867ad..0fef9e6 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -1,5 +1,5 @@ /* This file is part of Metaproxy. - Copyright (C) 2005-2012 Index Data + Copyright (C) Index Data Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -32,7 +32,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include "gduutil.hpp" +#include #include @@ -46,6 +48,8 @@ namespace metaproxy_1 { friend class FrontendNet; std::string port; std::string route; + std::string cert_fname; + int max_recv_bytes; }; class FrontendNet::Rep { friend class FrontendNet; @@ -64,7 +68,7 @@ namespace metaproxy_1 { double m_duration_max; double m_duration_min; double m_duration_total; - bool m_stop; + int m_stop_signo; public: Rep(); ~Rep(); @@ -441,7 +445,7 @@ void yf::FrontendNet::ZAssocServer::set_package(const mp::Package *package) } void yf::FrontendNet::ZAssocServer::set_thread_pool( - ThreadPoolSocketObserver *observer) + mp::ThreadPoolSocketObserver *observer) { m_thread_pool_observer = observer; } @@ -524,7 +528,7 @@ yf::FrontendNet::Rep::Rep() m_duration_max = 0.0; m_duration_min = 0.0; m_duration_total = 0.0; - m_stop = false; + m_stop_signo = 0; } yf::FrontendNet::Rep::~Rep() @@ -543,9 +547,9 @@ yf::FrontendNet::~FrontendNet() { } -void yf::FrontendNet::stop() const +void yf::FrontendNet::stop(int signo) const { - m_p->m_stop = true; + m_p->m_stop_signo = signo; } bool yf::FrontendNet::My_Timer_Thread::timeout() @@ -569,7 +573,7 @@ void yf::FrontendNet::My_Timer_Thread::socketNotify(int event) m_obs->deleteObserver(this); } -void yf::FrontendNet::process(Package &package) const +void yf::FrontendNet::process(mp::Package &package) const { if (m_p->az == 0) return; @@ -589,14 +593,17 @@ void yf::FrontendNet::process(Package &package) const } while (m_p->mySocketManager.processEvent() > 0) { - if (m_p->m_stop) - { - m_p->m_stop = false; + if (m_p->m_stop_signo == SIGTERM) + break; /* stop right away */ + if (m_p->m_stop_signo == SIGUSR1) + { /* just stop listeners and cont till all sessions are done*/ + m_p->m_stop_signo = 0; if (m_p->az) { size_t i; for (i = 0; i < m_p->m_ports.size(); i++) m_p->az[i]->server(""); + yaz_daemon_stop(); } } int no = m_p->mySocketManager.getNumberOfObservers(); @@ -623,15 +630,23 @@ void yf::FrontendNet::configure(const xmlNode * ptr, bool test_only, if (!strcmp((const char *) ptr->name, "port")) { Port port; - const struct _xmlAttr *attr; - for (attr = ptr->properties; attr; attr = attr->next) - { - if (!strcmp((const char *) attr->name, "route")) - port.route = mp::xml::get_text(attr); - } - port.port = mp::xml::get_text(ptr); - ports.push_back(port); + const char *names[5] = {"route", "max_recv_bytes", "port", + "cert_fname", 0}; + std::string values[4]; + + mp::xml::parse_attr(ptr, names, values); + port.route = values[0]; + if (values[1].length() > 0) + port.max_recv_bytes = atoi(values[1].c_str()); + else + port.max_recv_bytes = 0; + if (values[2].length() > 0) + port.port = values[2]; + else + port.port = mp::xml::get_text(ptr); + port.cert_fname = values[3]; + ports.push_back(port); } else if (!strcmp((const char *) ptr->name, "threads")) { @@ -705,6 +720,8 @@ void yf::FrontendNet::set_ports(std::vector &ports) // create a PDU assoc object (one per yf::FrontendNet::ZAssocServer) yazpp_1::PDU_Assoc *as = new yazpp_1::PDU_Assoc(&m_p->mySocketManager); + if (m_p->m_ports[i].cert_fname.length()) + as->set_cert_fname(m_p->m_ports[i].cert_fname.c_str()); // create ZAssoc with PDU Assoc m_p->az[i] = new yf::FrontendNet::ZAssocServer( as, m_p->m_ports[i].route, m_p.get()); @@ -713,6 +730,11 @@ void yf::FrontendNet::set_ports(std::vector &ports) throw yf::FilterException("Unable to bind to address " + std::string(m_p->m_ports[i].port)); } + COMSTACK cs = as->get_comstack(); + + if (cs && m_p->m_ports[i].max_recv_bytes) + cs_set_max_recv_bytes(cs, m_p->m_ports[i].max_recv_bytes); + } }