summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-03-08 10:13:36 -0800
committerCedric Bail <cedric@osg.samsung.com>2017-03-08 12:24:41 -0800
commit4766316935589b6191e047ad697ab10ae2027a43 (patch)
treeef35a81614992d81d030057ce238ea51c2515b39 /src/lib/eina
parent8ed9aec49be611cb3eb255604d3869e3c6c60fbe (diff)
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
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_file_common.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index b47cad72e3..cd842a7572 100644
--- a/src/lib/eina/eina_file_common.c
+++ b/src/lib/eina/eina_file_common.c
@@ -477,6 +477,19 @@ eina_file_dup(const Eina_File *f)
477 { 477 {
478 EINA_FILE_MAGIC_CHECK(f, NULL); 478 EINA_FILE_MAGIC_CHECK(f, NULL);
479 eina_lock_take(&file->lock); 479 eina_lock_take(&file->lock);
480 if (file->virtual)
481 {
482 // For ease of use and safety of the API, if you dup a virtualized file, we prefer to make a copy
483 if (file->global_map != (void*)(file->filename + strlen(file->filename) + 1))
484 {
485 Eina_File *r;
486
487 r = eina_file_virtualize(file->filename, file->global_map, file->length, EINA_TRUE);
488 eina_lock_release(&file->lock);
489
490 return r;
491 }
492 }
480 file->refcount++; 493 file->refcount++;
481 eina_lock_release(&file->lock); 494 eina_lock_release(&file->lock);
482 } 495 }