diff options
author | Kunhoon Baik <knhoon.baik@samsung.com> | 2016-09-01 16:15:21 +0900 |
---|---|---|
committer | Kunhoon Baik <knhoon.baik@samsung.com> | 2016-09-01 16:15:21 +0900 |
commit | d5114e76188e1bbb4c30fbe8cb8894819eeb2e7f (patch) | |
tree | b7272b22445a3678f853d5d92a372cbdf6234f81 | |
parent | b4987d09e5dd5178c83876b2d06d8bdf1d67d086 (diff) | |
download | argos_watchdog-d5114e76188e1bbb4c30fbe8cb8894819eeb2e7f.tar.gz argos_watchdog-d5114e76188e1bbb4c30fbe8cb8894819eeb2e7f.tar.bz2 argos_watchdog-d5114e76188e1bbb4c30fbe8cb8894819eeb2e7f.zip |
Support runtime watchdogsubmit/tizen_unified/20170308.100409submit/tizen_3.0_wearable/20161015.000000submit/tizen_3.0_tv/20161015.000000submit/tizen_3.0_mobile/20161015.000000submit/tizen_3.0_ivi/20161010.000010submit/tizen_3.0_ivi/20161010.000000submit/tizen_3.0_common/20161104.104000submit/tizen_3.0.m2/20170104.093751submit/tizen/20160902.013139accepted/tizen/wearable/20160905.065435accepted/tizen/unified/20170309.033857accepted/tizen/tv/20160905.065418accepted/tizen/mobile/20160905.065401accepted/tizen/ivi/20160905.065451accepted/tizen/common/20160902.061950accepted/tizen/3.0/wearable/20161015.080358accepted/tizen/3.0/tv/20161016.003332accepted/tizen/3.0/mobile/20161015.032216accepted/tizen/3.0/ivi/20161011.053456accepted/tizen/3.0/common/20161114.110030accepted/tizen/3.0.m2/wearable/20170104.142253accepted/tizen/3.0.m2/tv/20170104.141956accepted/tizen/3.0.m2/mobile/20170104.141308tizen_3.0_tvtizen_3.0.m2tizen_3.0accepted/tizen_wearableaccepted/tizen_tvaccepted/tizen_mobileaccepted/tizen_iviaccepted/tizen_commonaccepted/tizen_3.0_wearableaccepted/tizen_3.0_tvaccepted/tizen_3.0_mobileaccepted/tizen_3.0_iviaccepted/tizen_3.0_commonaccepted/tizen_3.0.m2_wearableaccepted/tizen_3.0.m2_tvaccepted/tizen_3.0.m2_mobile
Previously, systemd did not support to change runtime watchdog.
However, recent systemd supports such functionality - https://github.com/systemd/systemd/commit/2787d83c2.
Thus, argos watchdog supports the feature.
Thanks to Mr.Sung(JungHak) (Original Idea from him)
Change-Id: I8ef1741c16867e46329c529365726821dd5d44d1
-rw-r--r-- | src/argos-smdl.c (renamed from src/argos-common.c) | 4 | ||||
-rw-r--r-- | src/argos-systemd.c | 56 |
2 files changed, 49 insertions, 11 deletions
diff --git a/src/argos-common.c b/src/argos-smdl.c index cbe79a4..d58b93d 100644 --- a/src/argos-common.c +++ b/src/argos-smdl.c @@ -14,9 +14,7 @@ * limitations under the License. */ -/* Under development - * In the future, tizen will support new watchdog system - * based on resourced for enhanced heartbeat monitor */ +// This file will be used for smart deadlock watchdog backend int _aw_register(unsigned int timeout) { diff --git a/src/argos-systemd.c b/src/argos-systemd.c index 493f1f7..3afbb97 100644 --- a/src/argos-systemd.c +++ b/src/argos-systemd.c @@ -18,22 +18,62 @@ #include <systemd/sd-daemon.h> #include <stdlib.h> -/* In case of watchdog based on systemd sd_notify, - * runtime registration does not support. - * Thus, just check whether the watchdog is enabled or not*/ +#define SEC_TO_USEC (1000*1000) + +static unsigned int saved_timeout=0; + +/* Now, systemd support to enable/disable runtime watchdog */ +/* https://github.com/systemd/systemd/commit/2787d83c2 */ +int systemd_change_watchdog_timeout(unsigned int timeout) +{ + return sd_notifyf(0, "WATCHDOG_USEC=%llu", (unsigned long long) timeout*SEC_TO_USEC); +} + int _aw_register(unsigned int timeout) { + int ret; - if ( sd_watchdog_enabled(0, NULL) ) - return 0; - else + ret = systemd_change_watchdog_timeout(timeout); + if(ret <=0) return -1; + + saved_timeout = timeout; + return 0; } -/* NOT Support for systemd backend */ int _aw_control(aw_op_e op, void *data) { - return -ENOTSUP; + int ret=-1; + unsigned int* timeout; + + switch(op){ + case AW_OP_DISABLE: + ret = systemd_change_watchdog_timeout(0); + break; + + case AW_OP_ENABLE: + ret = systemd_change_watchdog_timeout(saved_timeout); + break; + + case AW_OP_CHANGE_TIMEOUT: + timeout = (unsigned int*)(data); + if(timeout == NULL){ + ret = -1; + break; + } + ret = systemd_change_watchdog_timeout(*timeout); + if(ret > 0) + saved_timeout = *timeout; + break; + default: + ret = -1; + break; + } + + if(ret > 0) + return 0; + + return -1; } int _aw_notify(void) |