From: Adam Dickmeiss Date: Tue, 26 Aug 2014 11:28:18 +0000 (+0200) Subject: On SIGTERM shut down connection+listening sockets MP-568 X-Git-Tag: v1.5.10~3 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=2bd2bcb4e610bbc11a279f253201e04978fb5c27;p=metaproxy-moved-to-github.git On SIGTERM shut down connection+listening sockets MP-568 --- diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index c744a66..5f1f8ab 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -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; @@ -545,6 +546,7 @@ yf::FrontendNet::Rep::~Rep() for (i = 0; i < m_ports.size(); i++) delete az[i]; delete [] az; + delete [] pdu; } az = 0; } @@ -602,6 +604,16 @@ void yf::FrontendNet::process(mp::Package &package) const 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 @@ -724,6 +736,7 @@ 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; @@ -737,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()))