If the shutdown -r command fails, either by returning an error code immediately,
or by not completing the reboot within one minute, we will call the failfast
reboot mechanism to make sure the node reboots.
---
 src/base/Makefile.am                      | 3 +--
 src/base/osaf_utility.c                   | 6 ++++++
 src/base/tests/osaf_clock_gettime_test.cc | 5 +++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/base/Makefile.am b/src/base/Makefile.am
index d0d67bbf0..956cce6a5 100644
--- a/src/base/Makefile.am
+++ b/src/base/Makefile.am
@@ -223,8 +223,7 @@ bin_core_common_test_CPPFLAGS = \
 
 bin_core_common_test_LDFLAGS = \
        $(AM_LDFLAGS) \
-       src/base/lib_libopensaf_core_la-osaf_time.lo \
-       src/base/lib_libopensaf_core_la-osaf_utility.lo
+       src/base/lib_libopensaf_core_la-osaf_time.lo
 
 bin_core_common_test_SOURCES = \
        src/base/tests/mock_clock_gettime.cc \
diff --git a/src/base/osaf_utility.c b/src/base/osaf_utility.c
index 230cd7e0f..f19871139 100644
--- a/src/base/osaf_utility.c
+++ b/src/base/osaf_utility.c
@@ -24,6 +24,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include "base/ncssysf_def.h"
+#include "base/osaf_time.h"
 #include "osaf/configmake.h"
 
 void osaf_abort(long i_cause)
@@ -52,6 +53,11 @@ void osaf_safe_reboot(void)
                } else {
                        syslog(LOG_CRIT, "Command: %s failed, rc = %d", str,
                               rc);
+                       rc = -1;
                }
        }
+       if (rc != -1) osaf_nanosleep(&kOneMinute);
+       opensaf_reboot(
+               0, NULL,
+               "Shutdown did not complete successfully within one minute");
 }
diff --git a/src/base/tests/osaf_clock_gettime_test.cc 
b/src/base/tests/osaf_clock_gettime_test.cc
index 544715549..014801b3c 100644
--- a/src/base/tests/osaf_clock_gettime_test.cc
+++ b/src/base/tests/osaf_clock_gettime_test.cc
@@ -16,11 +16,16 @@
  */
 
 #include <cerrno>
+#include <cstdlib>
 #include "base/osaf_time.h"
 #include "base/osaf_utility.h"
 #include "base/tests/mock_clock_gettime.h"
 #include "gtest/gtest.h"
 
+void osaf_abort(long) {
+  abort();
+}
+
 TEST(OsafClockGettime, ReadRealtimeClock) {
   time_t sec = 123456789;
   long nsec = 987654321;
-- 
2.13.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to