ecore: add systemd watchdog support to Ecore main loop.

This commit is contained in:
Cedric Bail 2013-03-28 23:28:32 +09:00
parent ebcd5e22bc
commit 7bb467819b
3 changed files with 48 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2013-03-28 Cedric Bail
* Ecore: automatically turn on Systemd watchdog in Ecore main loop.
2013-03-28 Carsten Haitzler (The Rasterman)
* Change evas_textblock_cursor_word_start() and

4
NEWS
View File

@ -81,7 +81,9 @@ Additions:
* Ecore_x: Add manual render code before deiconify
* Eeze: Add a dummy libmount replacement for when libmount is not there.
* Ecore_Con: Add systemd socket activation support (ECORE_CON_SOCKET_ACTIVATE).
* Ecore: notify systemd that we are ready as soon as the main loop is running.
* Ecore:
- notify systemd that we are ready as soon as the main loop is running.
- automatically support Watchdog.
* ecore_imf: Add ecore_imf_context_input_panel_layout_variation_set/get API
* Add edje_object_part_text_input_panel_layout_variation_set/get API

View File

@ -19,6 +19,10 @@
# include <sys/mman.h>
#endif
#ifdef HAVE_SYSTEMD
# include <systemd/sd-daemon.h>
#endif
#ifdef HAVE_EVIL
# include <Evil.h>
#endif
@ -69,6 +73,10 @@ struct _Ecore_Safe_Call
Eina_Bool suspend : 1;
};
#ifdef HAVE_SYSTEMD
static Eina_Bool _systemd_watchdog_cb(void *data);
#endif
static void _ecore_main_loop_thread_safe_call(Ecore_Safe_Call *order);
static void _thread_safe_cleanup(void *data);
static void _thread_callback(void *data,
@ -90,6 +98,10 @@ static int _thread_id = -1;
static int _thread_id_max = 0;
static int _thread_id_update = 0;
#ifdef HAVE_SYSTEMD
static Ecore_Timer *_systemd_watchdog = NULL;
#endif
Eina_Lock _ecore_main_loop_lock;
int _ecore_main_lock_count;
@ -195,6 +207,18 @@ ecore_init(void)
#endif
_ecore_parent = eo_add(ECORE_PARENT_CLASS, NULL);
#ifdef HAVE_SYSTEMD
if (getenv("WATCHDOG_USEC"))
{
double sec;
sec = ((double) atoi(getenv("WATCHDOG_USEC"))) / 1000 / 1000;
_systemd_watchdog = ecore_timer_add(sec / 2, _systemd_watchdog_cb, NULL);
unsetenv("WATCHDOG_USEC");
}
#endif
eina_log_timing(_ecore_log_dom,
EINA_LOG_STATE_STOP,
EINA_LOG_STATE_INIT);
@ -246,6 +270,14 @@ ecore_shutdown(void)
EINA_LOG_STATE_START,
EINA_LOG_STATE_SHUTDOWN);
#ifdef HAVE_SYSTEMD
if (_systemd_watchdog)
{
ecore_timer_del(_systemd_watchdog);
_systemd_watchdog = NULL;
}
#endif
if (_ecore_fps_debug) _ecore_fps_debug_shutdown();
_ecore_coroutine_shutdown();
_ecore_poller_shutdown();
@ -753,6 +785,15 @@ _ecore_fps_debug_runtime_add(double t)
}
}
#ifdef HAVE_SYSTEMD
static Eina_Bool
_systemd_watchdog_cb(EINA_UNUSED void *data)
{
sd_notify(0, "WATCHDOG=1");
return ECORE_CALLBACK_RENEW;
}
#endif
#if HAVE_MALLINFO
static Eina_Bool
_ecore_memory_statistic(EINA_UNUSED void *data)