File pacemaker-libcrmcommon-refactor-sbd_timeout.patch of Package pacemaker.8397
commit 2f214a6a6959069a1588552bff5358e195bad7ee
Author: Klaus Wenninger <klaus.wenninger@aon.at>
Date: Wed Aug 24 15:54:05 2016 +0200
Refactor: libcrmcommon: move sbd_timeout-stuff to watchdog.c
diff --git a/include/crm_internal.h b/include/crm_internal.h
index 1391cc8..b41dfdc 100644
--- a/include/crm_internal.h
+++ b/include/crm_internal.h
@@ -129,6 +129,7 @@ gboolean check_number(const char *value);
gboolean check_quorum(const char *value);
gboolean check_script(const char *value);
gboolean check_utilization(const char *value);
+long crm_get_sbd_timeout(void);
gboolean check_sbd_timeout(const char *value);
/* Shared PE/crmd functionality */
diff --git a/lib/common/utils.c b/lib/common/utils.c
index 78c6195..83072c5 100644
--- a/lib/common/utils.c
+++ b/lib/common/utils.c
@@ -130,34 +130,6 @@ check_timer(const char *value)
}
gboolean
-check_sbd_timeout(const char *value)
-{
- const char *env_value = getenv("SBD_WATCHDOG_TIMEOUT");
-
- long sbd_timeout = crm_get_msec(env_value);
- long st_timeout = crm_get_msec(value);
-
- if(value == NULL || st_timeout <= 0) {
- crm_notice("Watchdog may be enabled but stonith-watchdog-timeout is disabled: %s", value);
-
- } else if(pcmk_locate_sbd() == 0) {
- do_crm_log_always(LOG_EMERG, "Shutting down: stonith-watchdog-timeout is configured (%ldms) but SBD is not active", st_timeout);
- crm_exit(DAEMON_RESPAWN_STOP);
- return FALSE;
-
- } else if(st_timeout < sbd_timeout) {
- do_crm_log_always(LOG_EMERG, "Shutting down: stonith-watchdog-timeout (%ldms) is too short (must be greater than %ldms)",
- st_timeout, sbd_timeout);
- crm_exit(DAEMON_RESPAWN_STOP);
- return FALSE;
- }
-
- crm_info("Watchdog functionality is consistent: %s delay exceeds timeout of %s", value, env_value);
- return TRUE;
-}
-
-
-gboolean
check_boolean(const char *value)
{
int tmp = FALSE;
diff --git a/lib/common/watchdog.c b/lib/common/watchdog.c
index 70c22c6..4384d4a 100644
--- a/lib/common/watchdog.c
+++ b/lib/common/watchdog.c
@@ -252,3 +252,37 @@ pcmk_locate_sbd(void)
return sbd_pid;
}
+
+long
+crm_get_sbd_timeout(void)
+{
+ const char *env_value = getenv("SBD_WATCHDOG_TIMEOUT");
+ long sbd_timeout = crm_get_msec(env_value);
+
+ return sbd_timeout;
+}
+
+gboolean
+check_sbd_timeout(const char *value)
+{
+ long sbd_timeout = crm_get_sbd_timeout();
+ long st_timeout = crm_get_msec(value);
+
+ if(value == NULL || st_timeout <= 0) {
+ crm_notice("Watchdog may be enabled but stonith-watchdog-timeout is disabled: %s", value);
+
+ } else if(pcmk_locate_sbd() == 0) {
+ do_crm_log_always(LOG_EMERG, "Shutting down: stonith-watchdog-timeout is configured (%ldms) but SBD is not active", st_timeout);
+ crm_exit(DAEMON_RESPAWN_STOP);
+ return FALSE;
+
+ } else if(st_timeout < sbd_timeout) {
+ do_crm_log_always(LOG_EMERG, "Shutting down: stonith-watchdog-timeout (%ldms) is too short (must be greater than %ldms)",
+ st_timeout, sbd_timeout);
+ crm_exit(DAEMON_RESPAWN_STOP);
+ return FALSE;
+ }
+
+ crm_info("Watchdog functionality is consistent: %s delay exceeds timeout of %ldms", value, sbd_timeout);
+ return TRUE;
+}