From 3059859e28d27919e7a51fa1301f59bd983465c4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 29 Dec 2015 17:06:53 +0900 Subject: [PATCH] Ecore Eldbus: Work around circular dependencies eldbus initializes ecore that may then init eldbus again, since one of the systemd modules is for eldbus. eldbus_shutdown() is then no longer functional, as there are two refs on eldbus. This patch solves this problem by removing the extra ref on eldbus from the module if it was already initialized. This patch now introduces really bad issues since there are now EO classes that fail to work after module load-unload-reload. --- .../system/systemd/ecore_system_systemd.c | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/modules/ecore/system/systemd/ecore_system_systemd.c b/src/modules/ecore/system/systemd/ecore_system_systemd.c index 57562224d1..26b08677c3 100644 --- a/src/modules/ecore/system/systemd/ecore_system_systemd.c +++ b/src/modules/ecore/system/systemd/ecore_system_systemd.c @@ -11,6 +11,7 @@ static Eldbus_Connection *_conn = NULL; static Eina_List *_objs = NULL; static Eina_List *_proxies = NULL; +static Eina_Bool _eldbus_initialized = EINA_FALSE; #ifdef CRI #undef CRI @@ -249,7 +250,22 @@ static void _ecore_system_systemd_shutdown(void); static Eina_Bool _ecore_system_systemd_init(void) { - eldbus_init(); + int ref; + + ref = eldbus_init(); + if (!ref) return EINA_FALSE; + if (ref > 1) + { + // remove extra ref here, otherwise we have a loop like this: + // eldbus -> ecore -> (this module) -> eldbus + // and neither eldbus nor ecore can't be shutdown + _eldbus_initialized = EINA_FALSE; + eldbus_shutdown(); + } + else + { + _eldbus_initialized = EINA_TRUE; + } _log_dom = eina_log_domain_register("ecore_system_systemd", NULL); if (_log_dom < 0) @@ -315,7 +331,9 @@ _ecore_system_systemd_shutdown(void) _log_dom = -1; } - eldbus_shutdown(); + if (_eldbus_initialized) + eldbus_shutdown(); + _eldbus_initialized = EINA_FALSE; } EINA_MODULE_INIT(_ecore_system_systemd_init);