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.
This commit is contained in:
Jean-Philippe Andre 2015-12-29 17:06:53 +09:00
parent bd32015dfc
commit 3059859e28
1 changed files with 20 additions and 2 deletions

View File

@ -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);