/* 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
#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();
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);
}
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)
+ if (m_p->m_stop_signo == SIGTERM)
{
- m_p->m_stop = false;
+ yaz_log(YLOG_LOG, "metaproxy received SIGTERM");
+ break; /* stop right away */
+ }
+ 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;