summaryrefslogtreecommitdiff
path: root/src/modules/ecore/system/systemd/ecore_system_systemd.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-04-12 14:11:32 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-04-12 14:11:32 +0900
commit53c66c98c2ae13a8c96b4ae1f9d735cda179e89d (patch)
treedb16f21850bf182ddbeb2949a923456414161997 /src/modules/ecore/system/systemd/ecore_system_systemd.c
parentf54a2eb5703381f9e80604cdca84f91b72ae0090 (diff)
ecore - system modules - fix eldbus interdependency and complaints
so ecore uses ecore system modules ... that use eldbus. eldbus inits ecore. this is a vicious cycle. eldbus shouldnt init ecore. it's a dependency but should be provided outside of initting eldbus. this all led to hack-arounds on initting eldbus in these ecore modules that just break things like shutting down eldbus when still in use. this ensures any pending messages are canceled on ecore module shutdown. this ensures every ecore module fully inits and shuts down eldbus as they should so refcounting the inits works. this stops eldbus from inittign ecore to avoid the circuluar dependency. this stops lots of CRI/ERR complaints eg if you run elua with no cmdline options. this is just better. @fix
Diffstat (limited to 'src/modules/ecore/system/systemd/ecore_system_systemd.c')
-rw-r--r--src/modules/ecore/system/systemd/ecore_system_systemd.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/modules/ecore/system/systemd/ecore_system_systemd.c b/src/modules/ecore/system/systemd/ecore_system_systemd.c
index 26b08677c3..edc86a6642 100644
--- a/src/modules/ecore/system/systemd/ecore_system_systemd.c
+++ b/src/modules/ecore/system/systemd/ecore_system_systemd.c
@@ -11,7 +11,7 @@ static Eldbus_Connection *_conn = NULL;
11 11
12static Eina_List *_objs = NULL; 12static Eina_List *_objs = NULL;
13static Eina_List *_proxies = NULL; 13static Eina_List *_proxies = NULL;
14static Eina_Bool _eldbus_initialized = EINA_FALSE; 14static Eina_List *_eldbus_pending = NULL;
15 15
16#ifdef CRI 16#ifdef CRI
17#undef CRI 17#undef CRI
@@ -122,11 +122,12 @@ static void _locale_envs_unset(void)
122} 122}
123 123
124static void _locale_get(void *data EINA_UNUSED, const Eldbus_Message *msg, 124static void _locale_get(void *data EINA_UNUSED, const Eldbus_Message *msg,
125 Eldbus_Pending *pending EINA_UNUSED) 125 Eldbus_Pending *pending)
126{ 126{
127 Eldbus_Message_Iter *variant, *array; 127 Eldbus_Message_Iter *variant, *array;
128 const char *errname, *errmsg, *val; 128 const char *errname, *errmsg, *val;
129 129
130 _eldbus_pending = eina_list_remove(_eldbus_pending, pending);
130 if (eldbus_message_error_get(msg, &errname, &errmsg)) 131 if (eldbus_message_error_get(msg, &errname, &errmsg))
131 { 132 {
132 ERR("Message error %s - %s", errname, errmsg); 133 ERR("Message error %s - %s", errname, errmsg);
@@ -174,6 +175,7 @@ _props_changed_locale(void *data, const Eldbus_Message *msg)
174 Eldbus_Proxy *proxy = data; 175 Eldbus_Proxy *proxy = data;
175 Eldbus_Message_Iter *changed, *entry, *invalidated; 176 Eldbus_Message_Iter *changed, *entry, *invalidated;
176 const char *iface, *prop; 177 const char *iface, *prop;
178 Eldbus_Pending *pend;
177 179
178 if (!eldbus_message_arguments_get(msg, "sa{sv}as", 180 if (!eldbus_message_arguments_get(msg, "sa{sv}as",
179 &iface, &changed, &invalidated)) 181 &iface, &changed, &invalidated))
@@ -201,7 +203,8 @@ _props_changed_locale(void *data, const Eldbus_Message *msg)
201 return; 203 return;
202 204
203 changed_locale: 205 changed_locale:
204 eldbus_proxy_property_get(proxy, "Locale", _locale_get, NULL); 206 pend = eldbus_proxy_property_get(proxy, "Locale", _locale_get, NULL);
207 _eldbus_pending = eina_list_append(_eldbus_pending, pend);
205} 208}
206 209
207static Eina_Bool 210static Eina_Bool
@@ -250,22 +253,7 @@ static void _ecore_system_systemd_shutdown(void);
250static Eina_Bool 253static Eina_Bool
251_ecore_system_systemd_init(void) 254_ecore_system_systemd_init(void)
252{ 255{
253 int ref; 256 eldbus_init();
254
255 ref = eldbus_init();
256 if (!ref) return EINA_FALSE;
257 if (ref > 1)
258 {
259 // remove extra ref here, otherwise we have a loop like this:
260 // eldbus -> ecore -> (this module) -> eldbus
261 // and neither eldbus nor ecore can't be shutdown
262 _eldbus_initialized = EINA_FALSE;
263 eldbus_shutdown();
264 }
265 else
266 {
267 _eldbus_initialized = EINA_TRUE;
268 }
269 257
270 _log_dom = eina_log_domain_register("ecore_system_systemd", NULL); 258 _log_dom = eina_log_domain_register("ecore_system_systemd", NULL);
271 if (_log_dom < 0) 259 if (_log_dom < 0)
@@ -305,6 +293,8 @@ _ecore_system_systemd_init(void)
305static void 293static void
306_ecore_system_systemd_shutdown(void) 294_ecore_system_systemd_shutdown(void)
307{ 295{
296 Eldbus_Pending *pend;
297
308 DBG("ecore system 'systemd' unloaded"); 298 DBG("ecore system 'systemd' unloaded");
309 299
310 while (_proxies) 300 while (_proxies)
@@ -331,9 +321,12 @@ _ecore_system_systemd_shutdown(void)
331 _log_dom = -1; 321 _log_dom = -1;
332 } 322 }
333 323
334 if (_eldbus_initialized) 324 EINA_LIST_FREE(_eldbus_pending, pend)
335 eldbus_shutdown(); 325 {
336 _eldbus_initialized = EINA_FALSE; 326 eldbus_pending_cancel(pend);
327 }
328
329 eldbus_shutdown();
337} 330}
338 331
339EINA_MODULE_INIT(_ecore_system_systemd_init); 332EINA_MODULE_INIT(_ecore_system_systemd_init);