Commit 8f6fa066 authored by Mike Blumenkrantz's avatar Mike Blumenkrantz Committed by Carsten Haitzler (Rasterman)

ecore: make dbus-using modules fork-safe

reset dbus connections to ensure continued functionality
parent 73280edd
......@@ -249,11 +249,23 @@ _property_change_monitor(const char *name,
}
static void _ecore_system_systemd_shutdown(void);
static Eina_Bool _ecore_system_systemd_init(void);
static unsigned int reseting = 0;
static void
_ecore_system_systemd_reset()
{
reseting = 1;
_ecore_system_systemd_shutdown();
_ecore_system_systemd_init();
reseting = 0;
}
static Eina_Bool
_ecore_system_systemd_init(void)
{
eldbus_init();
if (!reseting)
ecore_fork_reset_callback_add(_ecore_system_systemd_reset, NULL);
_log_dom = eina_log_domain_register("ecore_system_systemd", NULL);
if (_log_dom < 0)
......@@ -296,6 +308,8 @@ _ecore_system_systemd_shutdown(void)
Eldbus_Pending *pend;
DBG("ecore system 'systemd' unloaded");
if (!reseting)
ecore_fork_reset_callback_del(_ecore_system_systemd_reset, NULL);
while (_proxies)
{
......
......@@ -405,12 +405,26 @@ disp_error:
return EINA_FALSE;
}
static Eina_Bool _ecore_system_upower_init(void);
static void _ecore_system_upower_shutdown(void);
static unsigned int reseting;
static void
_ecore_system_upower_reset()
{
reseting = 1;
_ecore_system_upower_shutdown();
_ecore_system_upower_init();
reseting = 0;
}
static Eina_Bool
_ecore_system_upower_init(void)
{
Eldbus_Signal_Handler *s;
eldbus_init();
if (!reseting)
ecore_fork_reset_callback_add(_ecore_system_upower_reset, NULL);
_log_dom = eina_log_domain_register("ecore_system_upower", NULL);
if (_log_dom < 0)
......@@ -466,6 +480,8 @@ _ecore_system_upower_shutdown(void)
Eldbus_Pending *pend;
DBG("ecore system 'upower' unloaded");
if (!reseting)
ecore_fork_reset_callback_del(_ecore_system_upower_reset, NULL);
eldbus_name_owner_changed_callback_del(_conn, "org.freedesktop.UPower",
_upower_name_owner_cb,
......@@ -494,6 +510,11 @@ _ecore_system_upower_shutdown(void)
_obj = NULL;
}
EINA_LIST_FREE(_eldbus_pending, pend)
{
eldbus_pending_cancel(pend);
}
if (_conn)
{
eldbus_connection_unref(_conn);
......@@ -506,11 +527,6 @@ _ecore_system_upower_shutdown(void)
_log_dom = -1;
}
EINA_LIST_FREE(_eldbus_pending, pend)
{
eldbus_pending_cancel(pend);
}
eldbus_shutdown();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment