discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=edd0d75e030693dad12c79866a3c6c7a8c4ba6a5

commit edd0d75e030693dad12c79866a3c6c7a8c4ba6a5
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Fri Feb 2 16:59:56 2018 -0500

    ecore: make dbus-using modules fork-safe
    
    reset dbus connections to ensure continued functionality
---
 .../ecore/system/systemd/ecore_system_systemd.c    | 14 ++++++++++++
 .../ecore/system/upower/ecore_system_upower.c      | 26 +++++++++++++++++-----
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/src/modules/ecore/system/systemd/ecore_system_systemd.c 
b/src/modules/ecore/system/systemd/ecore_system_systemd.c
index edc86a6642..78e3185287 100644
--- a/src/modules/ecore/system/systemd/ecore_system_systemd.c
+++ b/src/modules/ecore/system/systemd/ecore_system_systemd.c
@@ -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)
      {
diff --git a/src/modules/ecore/system/upower/ecore_system_upower.c 
b/src/modules/ecore/system/upower/ecore_system_upower.c
index 8a73ac44ac..17ef5170c8 100644
--- a/src/modules/ecore/system/upower/ecore_system_upower.c
+++ b/src/modules/ecore/system/upower/ecore_system_upower.c
@@ -408,12 +408,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)
@@ -469,6 +483,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,
@@ -497,6 +513,11 @@ _ecore_system_upower_shutdown(void)
         _obj = NULL;
      }
 
+   EINA_LIST_FREE(_eldbus_pending, pend)
+     {
+        eldbus_pending_cancel(pend);
+     }
+
    if (_conn)
      {
         eldbus_connection_unref(_conn);
@@ -509,11 +530,6 @@ _ecore_system_upower_shutdown(void)
         _log_dom = -1;
      }
 
-   EINA_LIST_FREE(_eldbus_pending, pend)
-     {
-        eldbus_pending_cancel(pend);
-     }
-
    eldbus_shutdown();
 }
 

-- 


Reply via email to