Support runtime watchdog 39/86439/1 accepted/tizen_3.0.m2_mobile accepted/tizen_3.0.m2_tv accepted/tizen_3.0.m2_wearable accepted/tizen_3.0_common accepted/tizen_3.0_ivi accepted/tizen_3.0_mobile accepted/tizen_3.0_tv accepted/tizen_3.0_wearable accepted/tizen_common accepted/tizen_ivi accepted/tizen_mobile accepted/tizen_tv accepted/tizen_wearable tizen_3.0 tizen_3.0.m2 tizen_3.0_tv accepted/tizen/3.0.m2/mobile/20170104.141308 accepted/tizen/3.0.m2/tv/20170104.141956 accepted/tizen/3.0.m2/wearable/20170104.142253 accepted/tizen/3.0/common/20161114.110030 accepted/tizen/3.0/ivi/20161011.053456 accepted/tizen/3.0/mobile/20161015.032216 accepted/tizen/3.0/tv/20161016.003332 accepted/tizen/3.0/wearable/20161015.080358 accepted/tizen/common/20160902.061950 accepted/tizen/ivi/20160905.065451 accepted/tizen/mobile/20160905.065401 accepted/tizen/tv/20160905.065418 accepted/tizen/unified/20170309.033857 accepted/tizen/wearable/20160905.065435 submit/tizen/20160902.013139 submit/tizen_3.0.m2/20170104.093751 submit/tizen_3.0_common/20161104.104000 submit/tizen_3.0_ivi/20161010.000000 submit/tizen_3.0_ivi/20161010.000010 submit/tizen_3.0_mobile/20161015.000000 submit/tizen_3.0_tv/20161015.000000 submit/tizen_3.0_wearable/20161015.000000 submit/tizen_unified/20170308.100409
authorKunhoon Baik <knhoon.baik@samsung.com>
Thu, 1 Sep 2016 07:15:21 +0000 (16:15 +0900)
committerKunhoon Baik <knhoon.baik@samsung.com>
Thu, 1 Sep 2016 07:15:21 +0000 (16:15 +0900)
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

src/argos-smdl.c [moved from src/argos-common.c with 85% similarity]
src/argos-systemd.c

similarity index 85%
rename from src/argos-common.c
rename to src/argos-smdl.c
index cbe79a4..d58b93d 100644 (file)
@@ -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)
 {
index 493f1f7..3afbb97 100644 (file)
 #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)