virtual void start() const;
- virtual void stop() const;
+ virtual void stop(int signo) const;
};
class FilterException : public std::runtime_error {
virtual RoutePos *createpos() const = 0;
virtual void start() = 0;
- virtual void stop() = 0;
+ virtual void stop(int signo) = 0;
};
class RoutePos : boost::noncopyable {
virtual RoutePos *createpos() const;
RouterChain & append(const filter::Base &filter);
void start();
- void stop();
+ void stop(int signo);
private:
boost::scoped_ptr<Rep> m_p;
/// disabled because class is singleton
virtual RoutePos *createpos() const;
void start();
- void stop();
+ void stop(int signo);
private:
boost::scoped_ptr<Rep> m_p;
};
{
}
-void mp::filter::Base::stop() const
+void mp::filter::Base::stop(int signo) const
{
}
#include <yaz/log.h>
#include <yaz/daemon.h>
#include "gduutil.hpp"
+#include <signal.h>
#include <iostream>
double m_duration_max;
double m_duration_min;
double m_duration_total;
- bool m_stop;
+ int m_stop_signo;
public:
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()
{
}
-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()
}
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;
void process(metaproxy_1::Package & package) const;
void configure(const xmlNode * ptr, bool test_only,
const char *path);
- void stop() const;
+ void stop(int signo) const;
public:
/// set ports
void set_ports(std::vector<Port> &ports);
#if HAVE_UNISTD_H
static pid_t process_group = 0;
-static void sig_usr1_handler(int s)
+static void sig_usr1_handler(int signo)
{
yaz_log(YLOG_LOG, "metaproxy received SIGUSR1");
- routerp->stop();
+ if (routerp)
+ routerp->stop(signo);
}
-static void sig_term_handler(int s)
+static void sig_term_handler(int signo)
{
- yaz_log(YLOG_LOG, "metaproxy received SIGTERM");
- yaz_log(YLOG_LOG, "metaproxy stop");
- kill(-process_group, SIGTERM); /* kill all children processes as well */
- _exit(0);
+ if (routerp)
+ {
+ yaz_log(YLOG_LOG, "metaproxy received SIGTERM");
+ routerp->stop(signo);
+ }
}
#endif
mp::Package pack;
pack.router(*routerp).move();
- yaz_log(YLOG_LOG, "metaproxy stop"); /* only for graceful stop */
+ yaz_log(YLOG_LOG, "metaproxy stop");
+ delete routerp;
+ routerp = 0;
#if HAVE_UNISTD_H
kill(-process_group, SIGTERM); /* kill all children processes as well */
#endif
(*it)->start();
}
-void mp::RouterChain::stop()
+void mp::RouterChain::stop(int signo)
{
std::list<const filter::Base *>::const_iterator it;
for (it = m_p->m_filter_list.begin(); it != m_p->m_filter_list.end(); it++)
- (*it)->stop();
+ (*it)->stop(signo);
}
const mp::filter::Base *mp::RouterChain::Pos::move(const char *route)
}
}
-void mp::RouterFleXML::stop()
+void mp::RouterFleXML::stop(int signo)
{
std::map<std::string,RouterFleXML::Route>::iterator route_it;
std::list<boost::shared_ptr<const mp::filter::Base> >::iterator it;
for (it = route.m_list.begin(); it != route.m_list.end(); it++)
- (*it)->stop();
+ (*it)->stop(signo);
route_it++;
}
}
virtual RoutePos *createpos() const;
void start();
- void stop();
+ void stop(int signo);
private:
boost::scoped_ptr<Rep> m_p;
};
m_p->m_flexml->start();
}
-void mp::RouterXML::stop()
+void mp::RouterXML::stop(int signo)
{
- m_p->m_flexml->stop();
+ m_p->m_flexml->stop(signo);
}
/*