summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKunhoon Baik <knhoon.baik@samsung.com>2016-09-01 16:15:21 +0900
committerKunhoon Baik <knhoon.baik@samsung.com>2016-09-01 16:15:21 +0900
commitd5114e76188e1bbb4c30fbe8cb8894819eeb2e7f (patch)
treeb7272b22445a3678f853d5d92a372cbdf6234f81 /src
parentb4987d09e5dd5178c83876b2d06d8bdf1d67d086 (diff)
downloadargos_watchdog-accepted/tizen/ivi/20160905.065451.tar.gz
argos_watchdog-accepted/tizen/ivi/20160905.065451.tar.bz2
argos_watchdog-accepted/tizen/ivi/20160905.065451.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/argos-smdl.c (renamed from src/argos-common.c)4
-rw-r--r--src/argos-systemd.c56
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)