summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-12-15 17:42:08 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-12-18 19:54:31 +0900
commit9427862d4010572a1c905fbcdd42a300751f8aa1 (patch)
tree7b7ac98b121ee83eff61ef38a5934a1282c5cde0 /src/lib
parentb6eeed74bb810292e273b7b221e2569fd8845b55 (diff)
ecore: Fix clean shutdown
There is no good reason to not shutdown a library properly. The loop object can easily be deleted safely, if it is properly initialized. The del event happens before destruction so it is too early to set the singleton variable to NULL. Do that as late as possible and all calls to efl_loop_main_get() will work as expected. The issue with fd's was simply that they were not initialized to -1 (timer_fd), as some #ifdef statements have disappeared.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore/ecore_main.c6
-rw-r--r--src/lib/ecore/efl_loop.c25
2 files changed, 8 insertions, 23 deletions
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index 8b7a32239b..3ef5a7a5e0 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -1021,7 +1021,6 @@ _ecore_main_loop_clear(Eo *obj, Efl_Loop_Data *pd)
1021 } 1021 }
1022#endif 1022#endif
1023 } 1023 }
1024#ifdef HAVE_EPOLL
1025 if (pd->epoll_fd >= 0) 1024 if (pd->epoll_fd >= 0)
1026 { 1025 {
1027 close(pd->epoll_fd); 1026 close(pd->epoll_fd);
@@ -1032,7 +1031,6 @@ _ecore_main_loop_clear(Eo *obj, Efl_Loop_Data *pd)
1032 close(pd->timer_fd); 1031 close(pd->timer_fd);
1033 pd->timer_fd = -1; 1032 pd->timer_fd = -1;
1034 } 1033 }
1035#endif
1036} 1034}
1037 1035
1038void 1036void
@@ -1049,9 +1047,7 @@ _ecore_main_loop_shutdown(void)
1049 if (!ML_OBJ) return; 1047 if (!ML_OBJ) return;
1050 _ecore_main_loop_clear(ML_OBJ, ML_DAT); 1048 _ecore_main_loop_clear(ML_OBJ, ML_DAT);
1051// XXX: this seemingly closes fd's it shouldn't.... :( fd 0? 1049// XXX: this seemingly closes fd's it shouldn't.... :( fd 0?
1052// efl_del(ML_OBJ); 1050 efl_del(ML_OBJ);
1053 ML_OBJ = NULL;
1054 ML_DAT = NULL;
1055} 1051}
1056 1052
1057void 1053void
diff --git a/src/lib/ecore/efl_loop.c b/src/lib/ecore/efl_loop.c
index 09ea62a1ac..1cd808d010 100644
--- a/src/lib/ecore/efl_loop.c
+++ b/src/lib/ecore/efl_loop.c
@@ -51,25 +51,12 @@ Efl_Version _app_efl_version = { 0, 0, 0, 0, NULL, NULL };
51Eo *_mainloop_singleton = NULL; 51Eo *_mainloop_singleton = NULL;
52Efl_Loop_Data *_mainloop_singleton_data = NULL; 52Efl_Loop_Data *_mainloop_singleton_data = NULL;
53 53
54static void
55_mainloop_singleton_cb_del(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
56{
57 _mainloop_singleton = NULL;
58 _mainloop_singleton_data = NULL;
59}
60
61EFL_CALLBACKS_ARRAY_DEFINE(_mainloop_singleton_callbacks,
62 { EFL_EVENT_DEL, _mainloop_singleton_cb_del });
63
64EOLIAN static Efl_Loop * 54EOLIAN static Efl_Loop *
65_efl_loop_main_get(Efl_Class *klass EINA_UNUSED, void *_pd EINA_UNUSED) 55_efl_loop_main_get(Efl_Class *klass EINA_UNUSED, void *_pd EINA_UNUSED)
66{ 56{
67 if (_mainloop_singleton) return _mainloop_singleton; 57 if (_mainloop_singleton) return _mainloop_singleton;
68 _mainloop_singleton = efl_add(EFL_LOOP_CLASS, NULL); 58 _mainloop_singleton = efl_add(EFL_LOOP_CLASS, NULL);
69 _mainloop_singleton_data = efl_data_scope_get(_mainloop_singleton, 59 _mainloop_singleton_data = efl_data_scope_get(_mainloop_singleton, EFL_LOOP_CLASS);
70 EFL_LOOP_CLASS);
71 efl_event_callback_array_add(_mainloop_singleton,
72 _mainloop_singleton_callbacks(), NULL);
73 return _mainloop_singleton; 60 return _mainloop_singleton;
74} 61}
75 62
@@ -318,12 +305,8 @@ _efl_loop_efl_object_constructor(Eo *obj, Efl_Loop_Data *pd)
318 pd->loop_time = ecore_time_get(); 305 pd->loop_time = ecore_time_get();
319 pd->providers = eina_hash_pointer_new(EINA_FREE_CB(efl_unref)); 306 pd->providers = eina_hash_pointer_new(EINA_FREE_CB(efl_unref));
320 pd->message_handlers = eina_inarray_new(sizeof(Message_Handler), 32); 307 pd->message_handlers = eina_inarray_new(sizeof(Message_Handler), 32);
321#ifdef HAVE_EPOLL
322 pd->epoll_fd = -1; 308 pd->epoll_fd = -1;
323#endif
324#ifdef USE_G_MAIN_LOOP
325 pd->timer_fd = -1; 309 pd->timer_fd = -1;
326#endif
327 return obj; 310 return obj;
328} 311}
329 312
@@ -346,6 +329,12 @@ _efl_loop_efl_object_destructor(Eo *obj, Efl_Loop_Data *pd)
346 pd->message_handlers = NULL; 329 pd->message_handlers = NULL;
347 330
348 efl_destructor(efl_super(obj, EFL_LOOP_CLASS)); 331 efl_destructor(efl_super(obj, EFL_LOOP_CLASS));
332
333 if (obj == _mainloop_singleton)
334 {
335 _mainloop_singleton = NULL;
336 _mainloop_singleton_data = NULL;
337 }
349} 338}
350 339
351static void 340static void