evas: fix preload thread dead lock issue 82/64782/1
authorjiin.moon <jiin.moon@samsung.com>
Mon, 29 Feb 2016 07:24:10 +0000 (16:24 +0900)
committerjiin.moon <jiin.moon@samsung.com>
Tue, 5 Apr 2016 09:19:21 +0000 (18:19 +0900)
    Summary:
    Add spin lock to access to new flag can check to
    status of the preload

    Reviewers: jpeg, cedric, jypark

    Subscribers: raster

    Differential Revision: https://phab.enlightenment.org/D3775

Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
    evas: fix preload thread deadlock issue

    Summary: Wrong condition makes deadlock issue.

    Reviewers: jpeg, jypark

    Subscribers: cedric

    Differential Revision: https://phab.enlightenment.org/D3742

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Change-Id: I8fc9fa60c574c6dbfb6c3073925da867408cdb95

src/lib/evas/cache/evas_cache_image.c
src/lib/evas/include/evas_common_private.h

index e1f8c69..2175dee 100644 (file)
@@ -374,6 +374,10 @@ _evas_cache_image_async_heavy(void *data)
      }
    SLKU(current->lock_cancel);
    SLKU(current->lock);
+
+   LKL(wakeup);
+   current->flags.preload_pending = 0;
+   LKU(wakeup);
 }
 
 static void
@@ -388,6 +392,11 @@ _evas_cache_image_async_end(void *data)
    ie->preload = NULL;
    ie->flags.preload_done = ie->flags.loaded;
    ie->flags.updated_data = 1;
+
+   LKL(wakeup);
+   ie->flags.preload_pending = 0;
+   LKU(wakeup);
+
    while ((tmp = ie->targets))
      {
         evas_object_inform_call_image_preloaded((Evas_Object*) tmp->target);
@@ -409,6 +418,11 @@ _evas_cache_image_async_cancel(void *data)
 
    ie->preload = NULL;
    ie->cache->pending = eina_list_remove(ie->cache->pending, ie);
+
+   LKL(wakeup);
+   ie->flags.preload_pending = 0;
+   LKU(wakeup);
+
    if ((ie->flags.delete_me) || (ie->flags.dirty))
      {
         ie->flags.delete_me = 0;
@@ -466,6 +480,9 @@ _evas_cache_image_entry_preload_add(Image_Entry *ie, const Eo *target,
      {
         ie->cache->preload = eina_list_append(ie->cache->preload, ie);
         ie->flags.pending = 0;
+        LKL(wakeup);
+        ie->flags.preload_pending = 1;
+        LKU(wakeup);
         ie->preload = evas_preload_thread_run(_evas_cache_image_async_heavy,
                                               _evas_cache_image_async_end,
                                               _evas_cache_image_async_cancel,
@@ -1158,9 +1175,9 @@ evas_cache_image_load_data(Image_Entry *im)
              evas_preload_thread_cancel(im->preload);
           }
         evas_async_events_process();
-        
+
         LKL(wakeup);
-        while (im->preload)
+        while (im->flags.preload_pending)
           {
              eina_condition_wait(&cond_wakeup);
              LKU(wakeup);
index addf056..efd9568 100644 (file)
@@ -567,6 +567,7 @@ struct _Image_Entry_Flags
    Eina_Bool updated_data  : 1;
    Eina_Bool flipped       : 1;
    Eina_Bool textured      : 1;
+   Eina_Bool preload_pending : 1;
 };
 
 struct _Image_Entry_Frame