diff options
author | Shinwoo Kim <cinoo.kim@samsung.com> | 2018-08-17 12:42:18 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@samsung.com> | 2018-08-17 12:42:18 -0400 |
commit | cbe9b6f7700aaa3c87a203e69b5ab543cee68c20 (patch) | |
tree | dbe4e219ac2685a7f1fe87830598991c4ff489d5 /src/lib/eina/eina_file_common.c | |
parent | ae894a0509e0c1db1dc94ce5b959028b28639fd1 (diff) | |
download | efl-cbe9b6f7700aaa3c87a203e69b5ab543cee68c20.tar.gz |
eina_file: check copied using copied
Summary:
From (1) "the following commit" message, the changed condition in this patch
should check if the virtualized file is copied or not.
In eina_file_virtualize
head_padded = 16 * ((sizeof(Eina_File) + slen + 15) / 16);
file->global_map = ((char *)file) + head_padded;
In eina_file_dup
file->global_map != (void*)(file->filename + strlen(file->filename) + 1)
Because of this discord condition makes eina_file_dup copies always.
(1) This is "the following commit":
commit 4766316935589b6191e047ad697ab10ae2027a43
Author: Cedric Bail <cedric@osg.samsung.com>
Date: Wed Mar 8 10:13:36 2017 -0800
eina: force copy of not copied virtualized file while doing an eina_file_dup.
The other way around is pretty much impossible as you don't know who does
an eina_file_dup and for how long they keep there reference.
T5234
Reviewers: zmike, Hermet
Reviewed By: zmike
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D6857
Diffstat (limited to 'src/lib/eina/eina_file_common.c')
-rw-r--r-- | src/lib/eina/eina_file_common.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c index 3de42523ca..c87b7d94aa 100644 --- a/src/lib/eina/eina_file_common.c +++ b/src/lib/eina/eina_file_common.c @@ -474,18 +474,16 @@ eina_file_dup(const Eina_File *f) { EINA_FILE_MAGIC_CHECK(f, NULL); eina_lock_take(&file->lock); - if (file->virtual) + + // For ease of use and safety of the API, if you dup a virtualized file, we prefer to make a copy + if (file->virtual && !file->copied) { - // For ease of use and safety of the API, if you dup a virtualized file, we prefer to make a copy - if (file->global_map != (void*)(file->filename + strlen(file->filename) + 1)) - { - Eina_File *r; + Eina_File *r; - r = eina_file_virtualize(file->filename, file->global_map, file->length, EINA_TRUE); - eina_lock_release(&file->lock); + r = eina_file_virtualize(file->filename, file->global_map, file->length, EINA_TRUE); + eina_lock_release(&file->lock); - return r; - } + return r; } file->refcount++; eina_lock_release(&file->lock); |