]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: skip mark-me-down message if osd is not up
authorSage Weil <sage@inktank.com>
Wed, 22 May 2013 22:03:50 +0000 (15:03 -0700)
committerSage Weil <sage@inktank.com>
Tue, 11 Jun 2013 15:54:29 +0000 (08:54 -0700)
Fixes crash when the OSD has not successfully booted and gets a
SIGINT or SIGTERM.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit c2e262fc9493b4bb22c2b7b4990aa1ee7846940e)

src/osd/OSD.cc

index cba3f6c0b16c3c37f86b5157bfbe266b2ab4ecb5..91c214da276ac5f1e700b649dd09a1ede66375d5 100644 (file)
@@ -4077,21 +4077,20 @@ bool OSDService::prepare_to_stop() {
   if (state != NOT_STOPPING)
     return false;
 
-  state = PREPARING_TO_STOP;
-  monc->send_mon_message(
-    new MOSDMarkMeDown(
-      monc->get_fsid(),
-      get_osdmap()->get_inst(whoami),
-      get_osdmap()->get_epoch(),
-      false
-      ));
-  utime_t now = ceph_clock_now(g_ceph_context);
-  utime_t timeout;
-  timeout.set_from_double(
-    now + g_conf->osd_mon_shutdown_timeout);
-  while ((ceph_clock_now(g_ceph_context) < timeout) &&
-        (state != STOPPING)) {
-    is_stopping_cond.WaitUntil(is_stopping_lock, timeout);
+  if (get_osdmap()->is_up(whoami)) {
+    state = PREPARING_TO_STOP;
+    monc->send_mon_message(new MOSDMarkMeDown(monc->get_fsid(),
+                                             get_osdmap()->get_inst(whoami),
+                                             get_osdmap()->get_epoch(),
+                                             false
+                                             ));
+    utime_t now = ceph_clock_now(g_ceph_context);
+    utime_t timeout;
+    timeout.set_from_double(now + g_conf->osd_mon_shutdown_timeout);
+    while ((ceph_clock_now(g_ceph_context) < timeout) &&
+          (state != STOPPING)) {
+      is_stopping_cond.WaitUntil(is_stopping_lock, timeout);
+    }
   }
   state = STOPPING;
   return true;