From b2ea60691e45674a4e283e0535634bdd699544ea Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 15 Sep 2017 14:38:29 +0900 Subject: [PATCH] eina file: Fix map_populate on the global map If eina_file_map_all() is called, the map isn't added to the internal hash "rmap" and so _eina_file_map_rule_apply() would never be called. @fix asa --- src/lib/eina/eina_file.c | 23 ++++++++++++++++++----- src/lib/eina/eina_file_common.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c index c2c7f8f..97dec3e 100644 --- a/src/lib/eina/eina_file.c +++ b/src/lib/eina/eina_file.c @@ -936,6 +936,11 @@ eina_file_map_all(Eina_File *file, Eina_File_Populate rule) #ifdef MAP_HUGETLB hugetlb = !!(flags & MAP_HUGETLB); #endif + if (!file->global_refcount) + file->global_hugetlb = hugetlb; + else + hugetlb = file->global_hugetlb; + _eina_file_map_rule_apply(rule, file->global_map, file->length, hugetlb); file->global_refcount++; ret = file->global_map; @@ -1059,13 +1064,21 @@ EAPI void eina_file_map_populate(Eina_File *file, Eina_File_Populate rule, const void *map, unsigned long int offset, unsigned long int length) { - Eina_File_Map *em; - EINA_SAFETY_ON_NULL_RETURN(file); eina_lock_take(&file->lock); - em = eina_hash_find(file->rmap, &map); - if (em) _eina_file_map_rule_apply(rule, ((char *)em->map) + offset, - length, em->hugetlb); + if (map == file->global_map) + { + _eina_file_map_rule_apply(rule, ((char*) map) + offset, length, + file->global_hugetlb); + } + else + { + Eina_File_Map *em; + + em = eina_hash_find(file->rmap, &map); + if (em) _eina_file_map_rule_apply(rule, ((char *) em->map) + offset, + length, em->hugetlb); + } eina_lock_release(&file->lock); } diff --git a/src/lib/eina/eina_file_common.h b/src/lib/eina/eina_file_common.h index 0502029..93ba274 100644 --- a/src/lib/eina/eina_file_common.h +++ b/src/lib/eina/eina_file_common.h @@ -101,6 +101,7 @@ struct _Eina_File Eina_Bool shared : 1; /**< Indicates whether this file can be shared */ Eina_Bool delete_me : 1; /**< Indicates that this file should be deleted */ Eina_Bool global_faulty : 1; /**< Indicates whether #global_map is bad */ + Eina_Bool global_hugetlb : 1; /**< Indicates whether #global_map uses HugeTLB */ Eina_Bool virtual : 1; /**< Indicates that this is a virtual file */ Eina_Bool copied : 1; /**< Indicates whether this file has copied data */ }; -- 2.7.4