jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9427862d4010572a1c905fbcdd42a300751f8aa1

commit 9427862d4010572a1c905fbcdd42a300751f8aa1
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Fri Dec 15 17:42:08 2017 +0900

    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.
---
 src/lib/ecore/ecore_main.c |  6 +-----
 src/lib/ecore/efl_loop.c   | 25 +++++++------------------
 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)
           }
 #endif
      }
-#ifdef HAVE_EPOLL
    if (pd->epoll_fd >= 0)
      {
         close(pd->epoll_fd);
@@ -1032,7 +1031,6 @@ _ecore_main_loop_clear(Eo *obj, Efl_Loop_Data *pd)
         close(pd->timer_fd);
         pd->timer_fd = -1;
      }
-#endif
 }
 
 void
@@ -1049,9 +1047,7 @@ _ecore_main_loop_shutdown(void)
    if (!ML_OBJ) return;
    _ecore_main_loop_clear(ML_OBJ, ML_DAT);
 // XXX: this seemingly closes fd's it shouldn't.... :( fd 0?
-//   efl_del(ML_OBJ);
-   ML_OBJ = NULL;
-   ML_DAT = NULL;
+   efl_del(ML_OBJ);
 }
 
 void
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 };
 Eo            *_mainloop_singleton = NULL;
 Efl_Loop_Data *_mainloop_singleton_data = NULL;
 
-static void
-_mainloop_singleton_cb_del(void *data EINA_UNUSED, const Efl_Event *event 
EINA_UNUSED)
-{
-   _mainloop_singleton = NULL;
-   _mainloop_singleton_data = NULL;
-}
-
-EFL_CALLBACKS_ARRAY_DEFINE(_mainloop_singleton_callbacks,
-                           { EFL_EVENT_DEL, _mainloop_singleton_cb_del });
-
 EOLIAN static Efl_Loop *
 _efl_loop_main_get(Efl_Class *klass EINA_UNUSED, void *_pd EINA_UNUSED)
 {
    if (_mainloop_singleton) return _mainloop_singleton;
    _mainloop_singleton = efl_add(EFL_LOOP_CLASS, NULL);
-   _mainloop_singleton_data = efl_data_scope_get(_mainloop_singleton,
-                                                 EFL_LOOP_CLASS);
-   efl_event_callback_array_add(_mainloop_singleton,
-                                _mainloop_singleton_callbacks(), NULL);
+   _mainloop_singleton_data = efl_data_scope_get(_mainloop_singleton, 
EFL_LOOP_CLASS);
    return _mainloop_singleton;
 }
 
@@ -318,12 +305,8 @@ _efl_loop_efl_object_constructor(Eo *obj, Efl_Loop_Data 
*pd)
    pd->loop_time = ecore_time_get();
    pd->providers = eina_hash_pointer_new(EINA_FREE_CB(efl_unref));
    pd->message_handlers = eina_inarray_new(sizeof(Message_Handler), 32);
-#ifdef HAVE_EPOLL
    pd->epoll_fd = -1;
-#endif
-#ifdef USE_G_MAIN_LOOP
    pd->timer_fd = -1;
-#endif
    return obj;
 }
 
@@ -346,6 +329,12 @@ _efl_loop_efl_object_destructor(Eo *obj, Efl_Loop_Data *pd)
    pd->message_handlers = NULL;
 
    efl_destructor(efl_super(obj, EFL_LOOP_CLASS));
+
+   if (obj == _mainloop_singleton)
+     {
+        _mainloop_singleton = NULL;
+        _mainloop_singleton_data = NULL;
+     }
 }
 
 static void

-- 


Reply via email to