summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-12-16 20:21:34 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-12-16 20:46:09 +0900
commit3153061c12079d42689ba6120786601cd7fe0d0d (patch)
tree584f8a1dde725d3d7721239f42b8a5851d771ef0
parente9e712b9f38c48654f2700a0b69da6ebdc5861dc (diff)
downloadelementary-3153061c12079d42689ba6120786601cd7fe0d0d.tar.gz
image: Lock access to thread variables
Fixes CID 1343345 "Data race condition"
-rw-r--r--src/lib/elm_image.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/elm_image.c b/src/lib/elm_image.c
index f76eb9ac8..27adeda2d 100644
--- a/src/lib/elm_image.c
+++ b/src/lib/elm_image.c
@@ -333,16 +333,20 @@ _elm_image_async_open_done(void *data, Ecore_Thread *thread EINA_UNUSED)
ELM_IMAGE_DATA_GET(obj, sd);
- // no need to lock here, thread can't be running now
+ // async open thread can't be running now
+ // locking anyways to be sure (memory barrier), see CID 1343345
+ eina_spinlock_take(&sd->async.lck);
sd->async.th = NULL;
sd->async_failed = EINA_FALSE;
if (sd->async.todo)
{
+ eina_spinlock_release(&sd->async.lck);
sd->async.th = ecore_thread_run(_elm_image_async_open_do,
_elm_image_async_open_done,
_elm_image_async_open_cancel, obj);
+
return;
}
@@ -354,12 +358,14 @@ _elm_image_async_open_done(void *data, Ecore_Thread *thread EINA_UNUSED)
// done should be NULL only after cancel... not here
ERR("Async open failed for an unknown reason.");
sd->async_failed = EINA_TRUE;
+ eina_spinlock_release(&sd->async.lck);
eo_do(obj, eo_event_callback_call(EFL_FILE_EVENT_ASYNC_ERROR, NULL));
return;
}
DBG("Async open succeeded");
sd->async.done = NULL;
+ eina_spinlock_release(&sd->async.lck);
key = done->key;
map = done->map;
f = done->f_open;