mds: install signal handlers after init

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-07-20 08:37:44 -07:00
parent 868b48634b
commit 318f3df718

View File

@ -274,12 +274,6 @@ int main(int argc, const char **argv)
messenger->start();
// set up signal handlers, now that we've daemonized/forked.
init_async_signal_handler();
register_async_signal_handler(SIGHUP, sighup_handler);
register_async_signal_handler_oneshot(SIGINT, handle_mds_signal);
register_async_signal_handler_oneshot(SIGTERM, handle_mds_signal);
// start mds
mds = new MDS(g_conf->name.get_id().c_str(), messenger, &mc);
@ -291,16 +285,23 @@ int main(int argc, const char **argv)
r = mds->init(shadow);
else
r = mds->init();
if (r < 0)
goto shutdown;
// set up signal handlers, now that we've daemonized/forked.
init_async_signal_handler();
register_async_signal_handler(SIGHUP, sighup_handler);
register_async_signal_handler_oneshot(SIGINT, handle_mds_signal);
register_async_signal_handler_oneshot(SIGTERM, handle_mds_signal);
if (r >= 0) {
messenger->wait();
}
unregister_async_signal_handler(SIGHUP, sighup_handler);
unregister_async_signal_handler(SIGINT, handle_mds_signal);
unregister_async_signal_handler(SIGTERM, handle_mds_signal);
shutdown_async_signal_handler();
shutdown:
// yuck: grab the mds lock, so we can be sure that whoever in *mds
// called shutdown finishes what they were doing.
mds->mds_lock.Lock();