cedric pushed a commit to branch master.

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

commit 05f05dde5c96b284c4fafd8457e6c3bb30c47c73
Author: Cedric Bail <ced...@osg.samsung.com>
Date:   Fri Sep 2 09:59:09 2016 -0700

    eo: protect efl_isa from thread race condition.
---
 src/lib/eo/eo.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index de05690..560b928 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1441,14 +1441,21 @@ static Eina_Bool cached_isa = EINA_FALSE;
 EAPI Eina_Bool
 efl_isa(const Eo *eo_id, const Efl_Class *klass_id)
 {
+   eina_spinlock_take(&_eoid_lock);
    if (cached_isa_id == eo_id && cached_klass == klass_id)
-     return cached_isa;
+     {
+        eina_spinlock_release(&_eoid_lock);
+        return cached_isa;
+     }
+   eina_spinlock_release(&_eoid_lock);
 
    EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE);
    EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, EINA_FALSE);
    const op_type_funcs *func = _vtable_func_get(obj->vtable,
          klass->base_id + klass->desc->ops.count);
 
+   eina_spinlock_take(&_eoid_lock);
+
    // Caching the result as we do a lot of serial efl_isa due to 
evas_object_image using it.
    cached_isa_id = eo_id;
    cached_klass = klass_id;
@@ -1457,6 +1464,8 @@ efl_isa(const Eo *eo_id, const Efl_Class *klass_id)
     * _eo_class_isa_func. */
    cached_isa = (func && (func->func == _eo_class_isa_func));
 
+   eina_spinlock_release(&_eoid_lock);
+
    return cached_isa;
 }
 

-- 


Reply via email to