summaryrefslogtreecommitdiff
path: root/src/lib/ecore
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2013-03-28 23:28:32 +0900
committerCedric Bail <cedric.bail@free.fr>2013-03-28 23:28:32 +0900
commit7bb467819b304f586e9dda131252f5903fc21a03 (patch)
treeb3b47d07296ee6dcf49885028240ac0c0f57f77f /src/lib/ecore
parentebcd5e22bc328685f71b1b560504fcf346ba2a58 (diff)
ecore: add systemd watchdog support to Ecore main loop.
Diffstat (limited to 'src/lib/ecore')
-rw-r--r--src/lib/ecore/ecore.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index fbc0f7f143..0527db111f 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -19,6 +19,10 @@
19# include <sys/mman.h> 19# include <sys/mman.h>
20#endif 20#endif
21 21
22#ifdef HAVE_SYSTEMD
23# include <systemd/sd-daemon.h>
24#endif
25
22#ifdef HAVE_EVIL 26#ifdef HAVE_EVIL
23# include <Evil.h> 27# include <Evil.h>
24#endif 28#endif
@@ -69,6 +73,10 @@ struct _Ecore_Safe_Call
69 Eina_Bool suspend : 1; 73 Eina_Bool suspend : 1;
70}; 74};
71 75
76#ifdef HAVE_SYSTEMD
77static Eina_Bool _systemd_watchdog_cb(void *data);
78#endif
79
72static void _ecore_main_loop_thread_safe_call(Ecore_Safe_Call *order); 80static void _ecore_main_loop_thread_safe_call(Ecore_Safe_Call *order);
73static void _thread_safe_cleanup(void *data); 81static void _thread_safe_cleanup(void *data);
74static void _thread_callback(void *data, 82static void _thread_callback(void *data,
@@ -90,6 +98,10 @@ static int _thread_id = -1;
90static int _thread_id_max = 0; 98static int _thread_id_max = 0;
91static int _thread_id_update = 0; 99static int _thread_id_update = 0;
92 100
101#ifdef HAVE_SYSTEMD
102static Ecore_Timer *_systemd_watchdog = NULL;
103#endif
104
93Eina_Lock _ecore_main_loop_lock; 105Eina_Lock _ecore_main_loop_lock;
94int _ecore_main_lock_count; 106int _ecore_main_lock_count;
95 107
@@ -195,6 +207,18 @@ ecore_init(void)
195#endif 207#endif
196 _ecore_parent = eo_add(ECORE_PARENT_CLASS, NULL); 208 _ecore_parent = eo_add(ECORE_PARENT_CLASS, NULL);
197 209
210#ifdef HAVE_SYSTEMD
211 if (getenv("WATCHDOG_USEC"))
212 {
213 double sec;
214
215 sec = ((double) atoi(getenv("WATCHDOG_USEC"))) / 1000 / 1000;
216
217 _systemd_watchdog = ecore_timer_add(sec / 2, _systemd_watchdog_cb, NULL);
218 unsetenv("WATCHDOG_USEC");
219 }
220#endif
221
198 eina_log_timing(_ecore_log_dom, 222 eina_log_timing(_ecore_log_dom,
199 EINA_LOG_STATE_STOP, 223 EINA_LOG_STATE_STOP,
200 EINA_LOG_STATE_INIT); 224 EINA_LOG_STATE_INIT);
@@ -246,6 +270,14 @@ ecore_shutdown(void)
246 EINA_LOG_STATE_START, 270 EINA_LOG_STATE_START,
247 EINA_LOG_STATE_SHUTDOWN); 271 EINA_LOG_STATE_SHUTDOWN);
248 272
273#ifdef HAVE_SYSTEMD
274 if (_systemd_watchdog)
275 {
276 ecore_timer_del(_systemd_watchdog);
277 _systemd_watchdog = NULL;
278 }
279#endif
280
249 if (_ecore_fps_debug) _ecore_fps_debug_shutdown(); 281 if (_ecore_fps_debug) _ecore_fps_debug_shutdown();
250 _ecore_coroutine_shutdown(); 282 _ecore_coroutine_shutdown();
251 _ecore_poller_shutdown(); 283 _ecore_poller_shutdown();
@@ -753,6 +785,15 @@ _ecore_fps_debug_runtime_add(double t)
753 } 785 }
754} 786}
755 787
788#ifdef HAVE_SYSTEMD
789static Eina_Bool
790_systemd_watchdog_cb(EINA_UNUSED void *data)
791{
792 sd_notify(0, "WATCHDOG=1");
793 return ECORE_CALLBACK_RENEW;
794}
795#endif
796
756#if HAVE_MALLINFO 797#if HAVE_MALLINFO
757static Eina_Bool 798static Eina_Bool
758_ecore_memory_statistic(EINA_UNUSED void *data) 799_ecore_memory_statistic(EINA_UNUSED void *data)