cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4766316935589b6191e047ad697ab10ae2027a43

commit 4766316935589b6191e047ad697ab10ae2027a43
Author: Cedric Bail <[email protected]>
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
---
 src/lib/eina/eina_file_common.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index b47cad7..cd842a7 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)
      {
         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->global_map != (void*)(file->filename + 
strlen(file->filename) + 1))
+               {
+                  Eina_File *r;
+
+                  r = eina_file_virtualize(file->filename, file->global_map, 
file->length, EINA_TRUE);
+                  eina_lock_release(&file->lock);
+
+                  return r;
+               }
+          }
         file->refcount++;
         eina_lock_release(&file->lock);
      }

-- 


Reply via email to