summaryrefslogtreecommitdiff
path: root/src/modules/ecore/system
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
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')
-rw-r--r--src/modules/ecore/system/systemd/ecore_system_systemd.c37
-rw-r--r--src/modules/ecore/system/upower/ecore_system_upower.c49
2 files changed, 52 insertions, 34 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);
diff --git a/src/modules/ecore/system/upower/ecore_system_upower.c b/src/modules/ecore/system/upower/ecore_system_upower.c
index e07694c5d8..abc621ff7a 100644
--- a/src/modules/ecore/system/upower/ecore_system_upower.c
+++ b/src/modules/ecore/system/upower/ecore_system_upower.c
@@ -45,6 +45,8 @@ static Eina_Bool _ecore_on_battery = EINA_FALSE;
45static Eina_Bool _ecore_low_battery = EINA_FALSE; 45static Eina_Bool _ecore_low_battery = EINA_FALSE;
46static int _ecore_battery_level = -1; 46static int _ecore_battery_level = -1;
47 47
48static Eina_List *_eldbus_pending = NULL;
49
48static Eina_Bool _ecore_system_upower_display_device_init(void); 50static Eina_Bool _ecore_system_upower_display_device_init(void);
49static void _ecore_system_upower_shutdown(void); 51static void _ecore_system_upower_shutdown(void);
50 52
@@ -89,11 +91,12 @@ _warning_level_from_variant(Eldbus_Message_Iter *variant)
89static void 91static void
90_warning_level_get_cb(void *data EINA_UNUSED, 92_warning_level_get_cb(void *data EINA_UNUSED,
91 const Eldbus_Message *msg, 93 const Eldbus_Message *msg,
92 Eldbus_Pending *pending EINA_UNUSED) 94 Eldbus_Pending *pending)
93{ 95{
94 Eldbus_Message_Iter *variant; 96 Eldbus_Message_Iter *variant;
95 const char *errname, *errmsg; 97 const char *errname, *errmsg;
96 98
99 _eldbus_pending = eina_list_remove(_eldbus_pending, pending);
97 if (eldbus_message_error_get(msg, &errname, &errmsg)) 100 if (eldbus_message_error_get(msg, &errname, &errmsg))
98 { 101 {
99// don't print errors because this results in complaints about upower not 102// don't print errors because this results in complaints about upower not
@@ -113,8 +116,11 @@ _warning_level_get_cb(void *data EINA_UNUSED,
113static void 116static void
114_warning_level_get(Eldbus_Proxy *proxy) 117_warning_level_get(Eldbus_Proxy *proxy)
115{ 118{
116 eldbus_proxy_property_get(proxy, "WarningLevel", 119 Eldbus_Pending *pend;
117 _warning_level_get_cb, NULL); 120
121 pend = eldbus_proxy_property_get(proxy, "WarningLevel",
122 _warning_level_get_cb, NULL);
123 _eldbus_pending = eina_list_append(_eldbus_pending, pend);
118} 124}
119 125
120static void 126static void
@@ -135,11 +141,12 @@ _on_low_battery_from_variant(Eldbus_Message_Iter *variant)
135 141
136static void 142static void
137_on_low_battery_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, 143_on_low_battery_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg,
138 Eldbus_Pending *pending EINA_UNUSED) 144 Eldbus_Pending *pending)
139{ 145{
140 Eldbus_Message_Iter *variant; 146 Eldbus_Message_Iter *variant;
141 const char *errname, *errmsg; 147 const char *errname, *errmsg;
142 148
149 _eldbus_pending = eina_list_remove(_eldbus_pending, pending);
143 if (eldbus_message_error_get(msg, &errname, &errmsg)) 150 if (eldbus_message_error_get(msg, &errname, &errmsg))
144 { 151 {
145 ERR("Message error %s - %s", errname, errmsg); 152 ERR("Message error %s - %s", errname, errmsg);
@@ -157,8 +164,11 @@ _on_low_battery_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg,
157static void 164static void
158_on_low_battery_get(Eldbus_Proxy *proxy) 165_on_low_battery_get(Eldbus_Proxy *proxy)
159{ 166{
160 eldbus_proxy_property_get(proxy, "OnLowBattery", 167 Eldbus_Pending *pend;
161 _on_low_battery_get_cb, NULL); 168
169 pend = eldbus_proxy_property_get(proxy, "OnLowBattery",
170 _on_low_battery_get_cb, NULL);
171 _eldbus_pending = eina_list_append(_eldbus_pending, pend);
162} 172}
163 173
164static void 174static void
@@ -179,11 +189,12 @@ _on_battery_from_variant(Eldbus_Message_Iter *variant)
179 189
180static void 190static void
181_on_battery_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, 191_on_battery_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg,
182 Eldbus_Pending *pending EINA_UNUSED) 192 Eldbus_Pending *pending)
183{ 193{
184 Eldbus_Message_Iter *variant; 194 Eldbus_Message_Iter *variant;
185 const char *errname, *errmsg; 195 const char *errname, *errmsg;
186 196
197 _eldbus_pending = eina_list_remove(_eldbus_pending, pending);
187 if (eldbus_message_error_get(msg, &errname, &errmsg)) 198 if (eldbus_message_error_get(msg, &errname, &errmsg))
188 { 199 {
189 ERR("Message error %s - %s", errname, errmsg); 200 ERR("Message error %s - %s", errname, errmsg);
@@ -201,8 +212,11 @@ _on_battery_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg,
201static void 212static void
202_on_battery_get(Eldbus_Proxy *proxy) 213_on_battery_get(Eldbus_Proxy *proxy)
203{ 214{
204 eldbus_proxy_property_get(proxy, "OnBattery", 215 Eldbus_Pending *pend;
205 _on_battery_get_cb, NULL); 216
217 pend = eldbus_proxy_property_get(proxy, "OnBattery",
218 _on_battery_get_cb, NULL);
219 _eldbus_pending = eina_list_append(_eldbus_pending, pend);
206} 220}
207 221
208static void 222static void
@@ -263,11 +277,12 @@ _daemon_version_from_variant(Eldbus_Message_Iter *variant)
263 277
264static void 278static void
265_daemon_version_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, 279_daemon_version_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg,
266 Eldbus_Pending *pending EINA_UNUSED) 280 Eldbus_Pending *pending)
267{ 281{
268 Eldbus_Message_Iter *variant; 282 Eldbus_Message_Iter *variant;
269 const char *errname, *errmsg; 283 const char *errname, *errmsg;
270 284
285 _eldbus_pending = eina_list_remove(_eldbus_pending, pending);
271 if (eldbus_message_error_get(msg, &errname, &errmsg)) 286 if (eldbus_message_error_get(msg, &errname, &errmsg))
272 { 287 {
273 ERR("Message error %s - %s", errname, errmsg); 288 ERR("Message error %s - %s", errname, errmsg);
@@ -285,8 +300,11 @@ _daemon_version_get_cb(void *data EINA_UNUSED, const Eldbus_Message *msg,
285static void 300static void
286_daemon_version_get(Eldbus_Proxy *proxy) 301_daemon_version_get(Eldbus_Proxy *proxy)
287{ 302{
288 eldbus_proxy_property_get(proxy, "DaemonVersion", 303 Eldbus_Pending *pend;
289 _daemon_version_get_cb, NULL); 304
305 pend = eldbus_proxy_property_get(proxy, "DaemonVersion",
306 _daemon_version_get_cb, NULL);
307 _eldbus_pending = eina_list_append(_eldbus_pending, pend);
290} 308}
291 309
292static void 310static void
@@ -445,6 +463,8 @@ _ecore_system_upower_init(void)
445static void 463static void
446_ecore_system_upower_shutdown(void) 464_ecore_system_upower_shutdown(void)
447{ 465{
466 Eldbus_Pending *pend;
467
448 DBG("ecore system 'upower' unloaded"); 468 DBG("ecore system 'upower' unloaded");
449 469
450 eldbus_name_owner_changed_callback_del(_conn, "org.freedesktop.UPower", 470 eldbus_name_owner_changed_callback_del(_conn, "org.freedesktop.UPower",
@@ -486,6 +506,11 @@ _ecore_system_upower_shutdown(void)
486 _log_dom = -1; 506 _log_dom = -1;
487 } 507 }
488 508
509 EINA_LIST_FREE(_eldbus_pending, pend)
510 {
511 eldbus_pending_cancel(pend);
512 }
513
489 eldbus_shutdown(); 514 eldbus_shutdown();
490} 515}
491 516