summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorShinwoo Kim <cinoo.kim@samsung.com>2018-08-17 12:42:18 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-08-17 12:42:18 -0400
commitcbe9b6f7700aaa3c87a203e69b5ab543cee68c20 (patch)
treedbe4e219ac2685a7f1fe87830598991c4ff489d5 /src/lib/eina
parentae894a0509e0c1db1dc94ce5b959028b28639fd1 (diff)
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')
-rw-r--r--src/lib/eina/eina_file_common.c16
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)
474 { 474 {
475 EINA_FILE_MAGIC_CHECK(f, NULL); 475 EINA_FILE_MAGIC_CHECK(f, NULL);
476 eina_lock_take(&file->lock); 476 eina_lock_take(&file->lock);
477 if (file->virtual) 477
478 // For ease of use and safety of the API, if you dup a virtualized file, we prefer to make a copy
479 if (file->virtual && !file->copied)
478 { 480 {
479 // For ease of use and safety of the API, if you dup a virtualized file, we prefer to make a copy 481 Eina_File *r;
480 if (file->global_map != (void*)(file->filename + strlen(file->filename) + 1))
481 {
482 Eina_File *r;
483 482
484 r = eina_file_virtualize(file->filename, file->global_map, file->length, EINA_TRUE); 483 r = eina_file_virtualize(file->filename, file->global_map, file->length, EINA_TRUE);
485 eina_lock_release(&file->lock); 484 eina_lock_release(&file->lock);
486 485
487 return r; 486 return r;
488 }
489 } 487 }
490 file->refcount++; 488 file->refcount++;
491 eina_lock_release(&file->lock); 489 eina_lock_release(&file->lock);