diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-20 10:19:16 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-20 10:22:00 +0100 |
commit | 58b578c9b07497496fedd51f3aa3bd434a0fa305 (patch) | |
tree | 00840be00995dfdd3b3595d32350ec5f1aae43c2 /src/lib/eina | |
parent | 8a3e021298c8d7ebf8cb587554422aa6a93edcc9 (diff) |
eina: fix a possible race condition during eina_file_close.
replay 7e8fb93 without the breakage
Diffstat (limited to 'src/lib/eina')
-rw-r--r-- | src/lib/eina/eina_file_common.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c index 7b05b3b249..7f83c87774 100644 --- a/src/lib/eina/eina_file_common.c +++ b/src/lib/eina/eina_file_common.c | |||
@@ -451,17 +451,20 @@ eina_file_close(Eina_File *file) | |||
451 | 451 | ||
452 | EINA_SAFETY_ON_NULL_RETURN(file); | 452 | EINA_SAFETY_ON_NULL_RETURN(file); |
453 | 453 | ||
454 | eina_lock_take(&_eina_file_lock_cache); | ||
455 | |||
454 | eina_lock_take(&file->lock); | 456 | eina_lock_take(&file->lock); |
455 | file->refcount--; | 457 | file->refcount--; |
456 | if (file->refcount == 0) leave = EINA_FALSE; | 458 | if (file->refcount == 0) leave = EINA_FALSE; |
457 | eina_lock_release(&file->lock); | 459 | eina_lock_release(&file->lock); |
458 | if (leave) return; | 460 | if (leave) goto end; |
459 | |||
460 | eina_lock_take(&_eina_file_lock_cache); | ||
461 | 461 | ||
462 | eina_hash_del(_eina_file_cache, file->filename, file); | 462 | eina_hash_del(_eina_file_cache, file->filename, file); |
463 | |||
464 | // Backend specific file resource close | ||
463 | eina_file_real_close(file); | 465 | eina_file_real_close(file); |
464 | 466 | ||
467 | end: | ||
465 | eina_lock_release(&_eina_file_lock_cache); | 468 | eina_lock_release(&_eina_file_lock_cache); |
466 | } | 469 | } |
467 | 470 | ||