summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
491b957)
When metaproxy daemon receives SIGTERM the stop method of each filter
is called. The stop method existed before, but did not take any
arguements (void).. The frontend_net filter can now distinguish
between SIGUSR1 (stop bind, but keep sessions running) and SIGTERM
(stop immediately). Note that this changes the API+ABI of Metaproxy
filters.
12 files changed:
virtual void start() const;
virtual void start() const;
- virtual void stop() const;
+ virtual void stop(int signo) const;
};
class FilterException : public std::runtime_error {
};
class FilterException : public std::runtime_error {
virtual RoutePos *createpos() const = 0;
virtual void start() = 0;
virtual RoutePos *createpos() const = 0;
virtual void start() = 0;
- virtual void stop() = 0;
+ virtual void stop(int signo) = 0;
};
class RoutePos : boost::noncopyable {
};
class RoutePos : boost::noncopyable {
virtual RoutePos *createpos() const;
RouterChain & append(const filter::Base &filter);
void start();
virtual RoutePos *createpos() const;
RouterChain & append(const filter::Base &filter);
void start();
private:
boost::scoped_ptr<Rep> m_p;
/// disabled because class is singleton
private:
boost::scoped_ptr<Rep> m_p;
/// disabled because class is singleton
virtual RoutePos *createpos() const;
void start();
virtual RoutePos *createpos() const;
void start();
private:
boost::scoped_ptr<Rep> m_p;
};
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 <yaz/log.h>
#include <yaz/daemon.h>
#include "gduutil.hpp"
double m_duration_max;
double m_duration_min;
double m_duration_total;
double m_duration_max;
double m_duration_min;
double m_duration_total;
m_duration_max = 0.0;
m_duration_min = 0.0;
m_duration_total = 0.0;
m_duration_max = 0.0;
m_duration_min = 0.0;
m_duration_total = 0.0;
}
yf::FrontendNet::Rep::~Rep()
}
yf::FrontendNet::Rep::~Rep()
-void yf::FrontendNet::stop() const
+void yf::FrontendNet::stop(int signo) const
+ m_p->m_stop_signo = signo;
}
bool yf::FrontendNet::My_Timer_Thread::timeout()
}
bool yf::FrontendNet::My_Timer_Thread::timeout()
}
while (m_p->mySocketManager.processEvent() > 0)
{
}
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;
void process(metaproxy_1::Package & package) const;
void configure(const xmlNode * ptr, bool test_only,
const char *path);
void process(metaproxy_1::Package & package) const;
void configure(const xmlNode * ptr, bool test_only,
const char *path);
+ void stop(int signo) const;
public:
/// set ports
void set_ports(std::vector<Port> &ports);
public:
/// set ports
void set_ports(std::vector<Port> &ports);
#if HAVE_UNISTD_H
static pid_t process_group = 0;
#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");
{
yaz_log(YLOG_LOG, "metaproxy received SIGUSR1");
+ 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);
+ }
mp::Package pack;
pack.router(*routerp).move();
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
#if HAVE_UNISTD_H
kill(-process_group, SIGTERM); /* kill all children processes as well */
#endif
-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++)
{
std::list<const filter::Base *>::const_iterator it;
for (it = m_p->m_filter_list.begin(); it != m_p->m_filter_list.end(); it++)
}
const mp::filter::Base *mp::RouterChain::Pos::move(const char *route)
}
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::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++)
std::list<boost::shared_ptr<const mp::filter::Base> >::iterator it;
for (it = route.m_list.begin(); it != route.m_list.end(); it++)
virtual RoutePos *createpos() const;
void start();
virtual RoutePos *createpos() const;
void start();
private:
boost::scoped_ptr<Rep> m_p;
};
private:
boost::scoped_ptr<Rep> m_p;
};
m_p->m_flexml->start();
}
m_p->m_flexml->start();
}
-void mp::RouterXML::stop()
+void mp::RouterXML::stop(int signo)
+ m_p->m_flexml->stop(signo);