X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ffilter_frontend_net.cpp;h=5f1f8ab35ac75077abb2294746c081a640d1d07c;hb=ca9b9ad18a3ee9002e08cfb22e7af00359869072;hp=ec0e78e92bc65439f191ae54c158038959091960;hpb=9838c2eadf06b6bfe3d6eb264c1b485b51ba1a06;p=metaproxy-moved-to-github.git diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index ec0e78e..5f1f8ab 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-2013 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 @@ -63,6 +63,7 @@ namespace metaproxy_1 { std::string m_stat_req; yazpp_1::SocketManager mySocketManager; ZAssocServer **az; + yazpp_1::PDU_Assoc **pdu; int m_duration_freq[22]; double m_duration_lim[22]; double m_duration_max; @@ -277,6 +278,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); } @@ -539,6 +546,7 @@ yf::FrontendNet::Rep::~Rep() for (i = 0; i < m_ports.size(); i++) delete az[i]; delete [] az; + delete [] pdu; } az = 0; } @@ -594,9 +602,24 @@ void yf::FrontendNet::process(mp::Package &package) const while (m_p->mySocketManager.processEvent() > 0) { if (m_p->m_stop_signo == SIGTERM) + { + yaz_log(YLOG_LOG, "metaproxy received SIGTERM"); + if (m_p->az) + { + size_t i; + for (i = 0; i < m_p->m_ports.size(); i++) + { + m_p->pdu[i]->shutdown(); + m_p->az[i]->server(""); + } + yaz_daemon_stop(); + } 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) { @@ -606,6 +629,7 @@ void yf::FrontendNet::process(mp::Package &package) const yaz_daemon_stop(); } } +#endif int no = m_p->mySocketManager.getNumberOfObservers(); if (no <= 1) break; @@ -712,10 +736,13 @@ void yf::FrontendNet::set_ports(std::vector &ports) m_p->m_ports = ports; m_p->az = new yf::FrontendNet::ZAssocServer *[m_p->m_ports.size()]; + m_p->pdu = new yazpp_1::PDU_Assoc *[m_p->m_ports.size()]; // 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); @@ -723,6 +750,7 @@ void yf::FrontendNet::set_ports(std::vector &ports) 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->pdu[i] = as; m_p->az[i] = new yf::FrontendNet::ZAssocServer( as, m_p->m_ports[i].route, m_p.get()); if (m_p->az[i]->server(m_p->m_ports[i].port.c_str()))