summaryrefslogtreecommitdiff
path: root/src/mds
diff options
context:
space:
mode:
authorSage Weil <sage.weil@dreamhost.com>2012-02-11 16:33:51 -0800
committerSage Weil <sage.weil@dreamhost.com>2012-02-14 21:03:53 -0800
commitbe704fe1d9b2729e384f5dfd3653f8d9819b58c1 (patch)
treed40d7d7fdb2428190a20a2e88edd365311276ca6 /src/mds
parentafa1f9e392575a845c474c8dec96fba7fc72a633 (diff)
downloadceph-be704fe1d9b2729e384f5dfd3653f8d9819b58c1.tar.gz
mds: install async signal handlers for SIG{HUP,INT,TERM}
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
Diffstat (limited to 'src/mds')
-rw-r--r--src/mds/MDS.cc12
-rw-r--r--src/mds/MDS.h3
2 files changed, 13 insertions, 2 deletions
diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc
index 86890d3beee..cc5609aa60b 100644
--- a/src/mds/MDS.cc
+++ b/src/mds/MDS.cc
@@ -12,7 +12,7 @@
*
*/
-
+#include "global/signal_handler.h"
#include "include/types.h"
#include "common/entity_name.h"
@@ -20,6 +20,7 @@
#include "common/signal.h"
#include "common/ceph_argparse.h"
+
#include "msg/Messenger.h"
#include "mon/MonClient.h"
@@ -1511,7 +1512,14 @@ void MDS::stopping_done()
request_state(MDSMap::STATE_STOPPED);
}
-
+void MDS::handle_signal(int signum)
+{
+ assert(signum == SIGINT || signum == SIGTERM);
+ derr << "*** got signal " << sys_siglist[signum] << " ***" << dendl;
+ mds_lock.Lock();
+ suicide();
+ mds_lock.Unlock();
+}
void MDS::suicide()
{
diff --git a/src/mds/MDS.h b/src/mds/MDS.h
index 0ca2ea08b86..67a51028d9c 100644
--- a/src/mds/MDS.h
+++ b/src/mds/MDS.h
@@ -323,6 +323,9 @@ class MDS : public Dispatcher {
MDS(const std::string &n, Messenger *m, MonClient *mc);
~MDS();
+ // handle a signal (e.g., SIGTERM)
+ void handle_signal(int signum);
+
// who am i etc
int get_nodeid() { return whoami; }
MDSMap *get_mds_map() { return mdsmap; }