summaryrefslogtreecommitdiff
path: root/src/modules/ecore/system
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-02-02 16:59:56 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-02-02 16:59:44 -0500
commitedd0d75e030693dad12c79866a3c6c7a8c4ba6a5 (patch)
tree2197b7d34f0b1ab2fa0f867a4bc04055ed521af0 /src/modules/ecore/system
parent95a339733a6b296d445fa4cb03f6f88b12f415a7 (diff)
ecore: make dbus-using modules fork-safe
reset dbus connections to ensure continued functionality
Diffstat (limited to 'src/modules/ecore/system')
-rw-r--r--src/modules/ecore/system/systemd/ecore_system_systemd.c14
-rw-r--r--src/modules/ecore/system/upower/ecore_system_upower.c26
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,
249} 249}
250 250
251static void _ecore_system_systemd_shutdown(void); 251static void _ecore_system_systemd_shutdown(void);
252static Eina_Bool _ecore_system_systemd_init(void);
253static unsigned int reseting = 0;
252 254
255static void
256_ecore_system_systemd_reset()
257{
258 reseting = 1;
259 _ecore_system_systemd_shutdown();
260 _ecore_system_systemd_init();
261 reseting = 0;
262}
253static Eina_Bool 263static Eina_Bool
254_ecore_system_systemd_init(void) 264_ecore_system_systemd_init(void)
255{ 265{
256 eldbus_init(); 266 eldbus_init();
267 if (!reseting)
268 ecore_fork_reset_callback_add(_ecore_system_systemd_reset, NULL);
257 269
258 _log_dom = eina_log_domain_register("ecore_system_systemd", NULL); 270 _log_dom = eina_log_domain_register("ecore_system_systemd", NULL);
259 if (_log_dom < 0) 271 if (_log_dom < 0)
@@ -296,6 +308,8 @@ _ecore_system_systemd_shutdown(void)
296 Eldbus_Pending *pend; 308 Eldbus_Pending *pend;
297 309
298 DBG("ecore system 'systemd' unloaded"); 310 DBG("ecore system 'systemd' unloaded");
311 if (!reseting)
312 ecore_fork_reset_callback_del(_ecore_system_systemd_reset, NULL);
299 313
300 while (_proxies) 314 while (_proxies)
301 { 315 {
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:
408 return EINA_FALSE; 408 return EINA_FALSE;
409} 409}
410 410
411static Eina_Bool _ecore_system_upower_init(void);
412static void _ecore_system_upower_shutdown(void);
413static unsigned int reseting;
414
415static void
416_ecore_system_upower_reset()
417{
418 reseting = 1;
419 _ecore_system_upower_shutdown();
420 _ecore_system_upower_init();
421 reseting = 0;
422}
411static Eina_Bool 423static Eina_Bool
412_ecore_system_upower_init(void) 424_ecore_system_upower_init(void)
413{ 425{
414 Eldbus_Signal_Handler *s; 426 Eldbus_Signal_Handler *s;
415 427
416 eldbus_init(); 428 eldbus_init();
429 if (!reseting)
430 ecore_fork_reset_callback_add(_ecore_system_upower_reset, NULL);
417 431
418 _log_dom = eina_log_domain_register("ecore_system_upower", NULL); 432 _log_dom = eina_log_domain_register("ecore_system_upower", NULL);
419 if (_log_dom < 0) 433 if (_log_dom < 0)
@@ -469,6 +483,8 @@ _ecore_system_upower_shutdown(void)
469 Eldbus_Pending *pend; 483 Eldbus_Pending *pend;
470 484
471 DBG("ecore system 'upower' unloaded"); 485 DBG("ecore system 'upower' unloaded");
486 if (!reseting)
487 ecore_fork_reset_callback_del(_ecore_system_upower_reset, NULL);
472 488
473 eldbus_name_owner_changed_callback_del(_conn, "org.freedesktop.UPower", 489 eldbus_name_owner_changed_callback_del(_conn, "org.freedesktop.UPower",
474 _upower_name_owner_cb, 490 _upower_name_owner_cb,
@@ -497,6 +513,11 @@ _ecore_system_upower_shutdown(void)
497 _obj = NULL; 513 _obj = NULL;
498 } 514 }
499 515
516 EINA_LIST_FREE(_eldbus_pending, pend)
517 {
518 eldbus_pending_cancel(pend);
519 }
520
500 if (_conn) 521 if (_conn)
501 { 522 {
502 eldbus_connection_unref(_conn); 523 eldbus_connection_unref(_conn);
@@ -509,11 +530,6 @@ _ecore_system_upower_shutdown(void)
509 _log_dom = -1; 530 _log_dom = -1;
510 } 531 }
511 532
512 EINA_LIST_FREE(_eldbus_pending, pend)
513 {
514 eldbus_pending_cancel(pend);
515 }
516
517 eldbus_shutdown(); 533 eldbus_shutdown();
518} 534}
519 535