summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-11-21 14:58:32 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-11-21 14:58:32 +0900
commitba420c60474c23bfc0d59b07f9e4d0710ebcfa86 (patch)
tree0c6ec3872cfd94705c099c9b7a4debf48b0571b0
parent40d86ae6440c3c32abce55181147a92df69b1925 (diff)
eina: backport fix for race condition in Eina_File infrastructure.
-rw-r--r--ChangeLog5
-rw-r--r--NEWS9
-rw-r--r--src/lib/eina_file.c14
3 files changed, 23 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8970c02..bfefe9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -434,3 +434,8 @@
4342013-09-10 Eduardo Lima (Etrunko) 4342013-09-10 Eduardo Lima (Etrunko)
435 435
436 * 1.7.9 release 436 * 1.7.9 release
437
4382013-11-21 Cedric Bail
439
440 * Fix race condition when calling eina_file_open/eina_file_close.
441
diff --git a/NEWS b/NEWS
index 9aad8db..fb8dc75 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
1Eina 1.7.10
2
3Changes since Eina 1.7.9:
4-------------------------
5
6Fixes:
7 * Fix race condition when calling eina_file_open/eina_file_close.
8
9
1Eina 1.7.9 10Eina 1.7.9
2 11
3Changes since Eina 1.7.8: 12Changes since Eina 1.7.8:
diff --git a/src/lib/eina_file.c b/src/lib/eina_file.c
index 68a6cce..7fe6bb0 100644
--- a/src/lib/eina_file.c
+++ b/src/lib/eina_file.c
@@ -988,7 +988,6 @@ eina_file_open(const char *path, Eina_Bool shared)
988 { 988 {
989 file->delete_me = EINA_TRUE; 989 file->delete_me = EINA_TRUE;
990 eina_hash_del(_eina_file_cache, file->filename, file); 990 eina_hash_del(_eina_file_cache, file->filename, file);
991 _eina_file_real_close(file);
992 file = NULL; 991 file = NULL;
993 } 992 }
994 993
@@ -1050,18 +1049,23 @@ eina_file_open(const char *path, Eina_Bool shared)
1050EAPI void 1049EAPI void
1051eina_file_close(Eina_File *file) 1050eina_file_close(Eina_File *file)
1052{ 1051{
1052 Eina_Bool leave = EINA_TRUE;
1053
1053 EINA_SAFETY_ON_NULL_RETURN(file); 1054 EINA_SAFETY_ON_NULL_RETURN(file);
1054 1055
1056 eina_lock_take(&_eina_file_lock_cache);
1057
1055 eina_lock_take(&file->lock); 1058 eina_lock_take(&file->lock);
1056 file->refcount--; 1059 file->refcount--;
1060 if (file->refcount == 0) leave = EINA_FALSE;
1057 eina_lock_release(&file->lock); 1061 eina_lock_release(&file->lock);
1062 if (leave) goto end;
1058 1063
1059 if (file->refcount != 0) return; 1064 if (eina_hash_find(_eina_file_cache, file->filename) == file)
1060 eina_lock_take(&_eina_file_lock_cache); 1065 eina_hash_del(_eina_file_cache, file->filename, file);
1061
1062 eina_hash_del(_eina_file_cache, file->filename, file);
1063 _eina_file_real_close(file); 1066 _eina_file_real_close(file);
1064 1067
1068 end:
1065 eina_lock_release(&_eina_file_lock_cache); 1069 eina_lock_release(&_eina_file_lock_cache);
1066} 1070}
1067 1071