X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_frontend_net.cpp;h=c744a66511432556bdabca2e70fe6d3eaa50d60b;hb=6ca602c58dd24a3e0088e5ea91c2d4e03ab74918;hp=da9821504c26f0a18874d36127534c39bfd957de;hpb=7bfa7de321ea5aa63e79f8cdd930f2f78fdc3e79;p=metaproxy-moved-to-github.git diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index da98215..c744a66 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 @@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include "gduutil.hpp" +#include #include @@ -47,6 +48,7 @@ namespace metaproxy_1 { friend class FrontendNet; std::string port; std::string route; + std::string cert_fname; int max_recv_bytes; }; class FrontendNet::Rep { @@ -66,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(); @@ -275,6 +277,12 @@ yf::FrontendNet::ZAssocChild::ZAssocChild( const char *peername = PDU_Observable->getpeername(); if (!peername) peername = "unknown"; + else + { + const char *cp = strchr(peername, ':'); + if (cp) + peername = cp + 1; + } m_origin.set_tcpip_address(std::string(peername), m_session.id()); timeout(m_p->m_session_timeout); } @@ -526,7 +534,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() @@ -545,9 +553,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() @@ -591,9 +599,16 @@ void yf::FrontendNet::process(mp::Package &package) const } while (m_p->mySocketManager.processEvent() > 0) { - if (m_p->m_stop) + if (m_p->m_stop_signo == SIGTERM) { - m_p->m_stop = false; + yaz_log(YLOG_LOG, "metaproxy received SIGTERM"); + break; /* stop right away */ + } +#ifndef WIN32 + if (m_p->m_stop_signo == SIGUSR1) + { /* just stop listeners and cont till all sessions are done*/ + yaz_log(YLOG_LOG, "metaproxy received SIGUSR1"); + m_p->m_stop_signo = 0; if (m_p->az) { size_t i; @@ -602,6 +617,7 @@ void yf::FrontendNet::process(mp::Package &package) const yaz_daemon_stop(); } } +#endif int no = m_p->mySocketManager.getNumberOfObservers(); if (no <= 1) break; @@ -627,8 +643,9 @@ void yf::FrontendNet::configure(const xmlNode * ptr, bool test_only, { Port port; - const char *names[4] = {"route", "max_recv_bytes", "port", 0}; - std::string values[3]; + 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]; @@ -640,6 +657,7 @@ void yf::FrontendNet::configure(const xmlNode * ptr, bool test_only, 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")) @@ -709,11 +727,15 @@ void yf::FrontendNet::set_ports(std::vector &ports) // Create yf::FrontendNet::ZAssocServer for each port size_t i; - for (i = 0; im_ports.size(); i++) + for (i = 0; i < m_p->m_ports.size(); i++) + m_p->az[i] = 0; + for (i = 0; i < m_p->m_ports.size(); i++) { // 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());