summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorIvan Furs <i.furs@samsung.com>2017-03-06 19:18:46 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-03-06 19:18:46 +0900
commit8a10ef10cbc2d7513e8e4600dc26bb696f78dc62 (patch)
tree93239aaa3e78f359f256ce475131a67c5b455a29 /src/lib/eina
parentf7c1ac94f7d154a08660e40b5c0e676d8bd7d8e7 (diff)
eina_file: delete handle->fm(handel of function CreateFileMapping)
Summary: CreateFileMapping return handle. The handle before use is always closed. This handle can be immediately closed after use. Reviewers: cedric, raster, vtorri, rimmed, an.kroitor, FurryMyad, NikaWhite Reviewed By: raster Subscribers: artem.popov, cedric, jpeg Tags: #windows Differential Revision: https://phab.enlightenment.org/D4699
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_file_common.c3
-rw-r--r--src/lib/eina/eina_file_common.h1
-rw-r--r--src/lib/eina/eina_file_win32.c36
3 files changed, 15 insertions, 25 deletions
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index 2c5eeb1bf0..b47cad72e3 100644
--- a/src/lib/eina/eina_file_common.c
+++ b/src/lib/eina/eina_file_common.c
@@ -436,8 +436,7 @@ eina_file_virtualize(const char *virtual_name, const void *data, unsigned long l
436#ifndef _WIN32 436#ifndef _WIN32
437 file->fd = -1; 437 file->fd = -1;
438#else 438#else
439 file->handle = NULL; 439 file->handle = INVALID_HANDLE_VALUE;
440 file->fm = NULL;
441#endif 440#endif
442 file->virtual = EINA_TRUE; 441 file->virtual = EINA_TRUE;
443 file->map = eina_hash_new(EINA_KEY_LENGTH(eina_file_map_key_length), 442 file->map = eina_hash_new(EINA_KEY_LENGTH(eina_file_map_key_length),
diff --git a/src/lib/eina/eina_file_common.h b/src/lib/eina/eina_file_common.h
index e8241d9ae1..6fcecb2fa8 100644
--- a/src/lib/eina/eina_file_common.h
+++ b/src/lib/eina/eina_file_common.h
@@ -94,7 +94,6 @@ struct _Eina_File
94 int fd; /**< The file descriptor. */ 94 int fd; /**< The file descriptor. */
95#else 95#else
96 HANDLE handle; /**< A Win32 file handle for this file. */ 96 HANDLE handle; /**< A Win32 file handle for this file. */
97 HANDLE fm; /**< A Win32 file handle to a file mapping object for this file. */
98#endif 97#endif
99 98
100 Eina_List *dead_map; /**< Tracks regions that get a failure from mmap(2). */ 99 Eina_List *dead_map; /**< Tracks regions that get a failure from mmap(2). */
diff --git a/src/lib/eina/eina_file_win32.c b/src/lib/eina/eina_file_win32.c
index fe83c6710c..9d6bf1b444 100644
--- a/src/lib/eina/eina_file_win32.c
+++ b/src/lib/eina/eina_file_win32.c
@@ -386,8 +386,8 @@ eina_file_real_close(Eina_File *file)
386 if (file->global_map != MAP_FAILED && file->handle != NULL) 386 if (file->global_map != MAP_FAILED && file->handle != NULL)
387 UnmapViewOfFile(file->global_map); 387 UnmapViewOfFile(file->global_map);
388 388
389 if (file->fm) CloseHandle(file->fm); 389 if (file->handle != INVALID_HANDLE_VALUE)
390 if (file->handle) CloseHandle(file->handle); 390 CloseHandle(file->handle);
391} 391}
392 392
393static void 393static void
@@ -871,29 +871,26 @@ eina_file_map_all(Eina_File *file, Eina_File_Populate rule EINA_UNUSED)
871 eina_lock_take(&file->lock); 871 eina_lock_take(&file->lock);
872 if (file->global_map == MAP_FAILED) 872 if (file->global_map == MAP_FAILED)
873 { 873 {
874 void *data;
875 DWORD max_size_high; 874 DWORD max_size_high;
876 DWORD max_size_low; 875 DWORD max_size_low;
876 HANDLE fm;
877 877
878 if (file->fm)
879 CloseHandle(file->fm);
880 878
881 max_size_high = (DWORD)((file->length & 0xffffffff00000000ULL) >> 32); 879 max_size_high = (DWORD)((file->length & 0xffffffff00000000ULL) >> 32);
882 max_size_low = (DWORD)(file->length & 0x00000000ffffffffULL); 880 max_size_low = (DWORD)(file->length & 0x00000000ffffffffULL);
883 file->fm = CreateFileMapping(file->handle, NULL, PAGE_READONLY, 881 fm = CreateFileMapping(file->handle, NULL, PAGE_READONLY,
884 max_size_high, max_size_low, NULL); 882 max_size_high, max_size_low, NULL);
885 if (!file->fm) 883 if (!fm)
886 { 884 {
887 eina_lock_release(&file->lock); 885 eina_lock_release(&file->lock);
888 return NULL; 886 return NULL;
889 } 887 }
890 888
891 data = MapViewOfFile(file->fm, FILE_MAP_READ, 889 file->global_map = MapViewOfFile(fm, FILE_MAP_READ,
892 0, 0, file->length); 890 0, 0, file->length);
893 if (!data) 891 CloseHandle(fm);
892 if (!file->global_map)
894 file->global_map = MAP_FAILED; 893 file->global_map = MAP_FAILED;
895 else
896 file->global_map = data;
897 } 894 }
898 895
899 if (file->global_map != MAP_FAILED) 896 if (file->global_map != MAP_FAILED)
@@ -935,8 +932,7 @@ eina_file_map_new(Eina_File *file, Eina_File_Populate rule,
935 map = eina_hash_find(file->map, &key); 932 map = eina_hash_find(file->map, &key);
936 if (!map) 933 if (!map)
937 { 934 {
938 void *data; 935 HANDLE fm;
939
940 map = malloc(sizeof (Eina_File_Map)); 936 map = malloc(sizeof (Eina_File_Map));
941 if (!map) 937 if (!map)
942 { 938 {
@@ -944,24 +940,20 @@ eina_file_map_new(Eina_File *file, Eina_File_Populate rule,
944 return NULL; 940 return NULL;
945 } 941 }
946 942
947 if (file->fm)
948 CloseHandle(file->fm);
949
950 /* the length parameter is unsigned long, that is a DWORD */ 943 /* the length parameter is unsigned long, that is a DWORD */
951 /* so the max size high parameter of CreateFileMapping is 0 */ 944 /* so the max size high parameter of CreateFileMapping is 0 */
952 file->fm = CreateFileMapping(file->handle, NULL, PAGE_READONLY, 945 fm = CreateFileMapping(file->handle, NULL, PAGE_READONLY,
953 0, (DWORD)length, NULL); 946 0, (DWORD)length, NULL);
954 if (!file->fm) 947 if (!fm)
955 return NULL; 948 return NULL;
956 949
957 data = MapViewOfFile(file->fm, FILE_MAP_READ, 950 map->map = MapViewOfFile(fm, FILE_MAP_READ,
958 offset & 0xffff0000, 951 offset & 0xffff0000,
959 offset & 0x0000ffff, 952 offset & 0x0000ffff,
960 length); 953 length);
961 if (!data) 954 CloseHandle(fm);
955 if (!map->map)
962 map->map = MAP_FAILED; 956 map->map = MAP_FAILED;
963 else
964 map->map = data;
965 957
966 map->offset = offset; 958 map->offset = offset;
967 map->length = length; 959 map->length = length;