cedric pushed a commit to branch master.

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

commit eeba25397f07ea044a1c4011b5c8dfcd46ccf0ea
Author: Thomas Guillem <tho...@gllm.fr>
Date:   Mon Sep 21 23:24:18 2015 +0200

    emotion: lock pending events and pending objects
    
    Summary:
    _emotion_pending_ecore_begin and _emotion_pending_ecore_end are not called 
from
    the same thread. Indeed, _emotion_pending_ecore_begin is called from 
gstreamer
    callbacks, and _emotion_pending_ecore_end is called from the mainloop.
    
    Reviewers: cedric
    
    Reviewed By: cedric
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D3061
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/lib/emotion/emotion_main.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/lib/emotion/emotion_main.c b/src/lib/emotion/emotion_main.c
index f827390..d641621 100644
--- a/src/lib/emotion/emotion_main.c
+++ b/src/lib/emotion/emotion_main.c
@@ -19,6 +19,7 @@
 
 static Emotion_Version _version = { VMAJ, VMIN, VMIC, VREV };
 static int emotion_pending_objects = 0;
+static Eina_Lock emotion_pending_lock;
 EAPI Emotion_Version *emotion_version = &_version;
 
 Eina_Prefix *_emotion_pfx = NULL;
@@ -199,13 +200,17 @@ static int emotion_pendig_events = 0;
 EAPI void
 _emotion_pending_ecore_begin(void)
 {
+   eina_lock_take(&emotion_pending_lock);
    emotion_pendig_events++;
+   eina_lock_release(&emotion_pending_lock);
 }
 
 EAPI void
 _emotion_pending_ecore_end(void)
 {
+   eina_lock_take(&emotion_pending_lock);
    emotion_pendig_events--;
+   eina_lock_release(&emotion_pending_lock);
 }
 
 EAPI Eina_Bool
@@ -220,11 +225,16 @@ emotion_shutdown(void)
      }
    if (--_emotion_init_count) return EINA_TRUE;
 
+   eina_lock_take(&emotion_pending_lock);
    start = ecore_time_get();
    while (((emotion_pending_objects > 0) ||
            (emotion_pendig_events > 0)) &&
           ((ecore_time_get() - start) < 0.5))
-     ecore_main_loop_iterate();
+     {
+        eina_lock_release(&emotion_pending_lock);
+        ecore_main_loop_iterate();
+        eina_lock_take(&emotion_pending_lock);
+     }
 
    if (emotion_pending_objects > 0)
      {
@@ -234,6 +244,9 @@ emotion_shutdown(void)
      {
         ERR("There is still %i Emotion events queued", emotion_pendig_events);
      }
+   eina_lock_release(&emotion_pending_lock);
+
+   eina_lock_free(&emotion_pending_lock);
 
    emotion_modules_shutdown();
 
@@ -263,11 +276,15 @@ emotion_shutdown(void)
 EAPI void
 _emotion_pending_object_ref(void)
 {
+   eina_lock_take(&emotion_pending_lock);
    emotion_pending_objects++;
+   eina_lock_release(&emotion_pending_lock);
 }
 
 EAPI void
 _emotion_pending_object_unref(void)
 {
+   eina_lock_take(&emotion_pending_lock);
    emotion_pending_objects--;
+   eina_lock_release(&emotion_pending_lock);
 }

-- 


Reply via email to