Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-09-18 19:59:50 +0400
committerCorinna Vinschen <corinna@vinschen.de>2007-09-18 19:59:50 +0400
commit4090f565a839d8e846cf9c6249a5ebbfd8ad9790 (patch)
treeab050a5c077b3d3415d24e0008f43126bab4a96c /winsup/cygwin/mmap.cc
parentd81b646dc3d3f80f6247945f2bdf54381f8ac808 (diff)
* mmap.cc (fh_disk_file): Delete as global static variable and...
(mmap64): ...define as local pointer to make mmap thread-safe. Accommodate throughout. Only initialize fh_disk_file after file could be opened with GENERIC_EXECUTE access. Call fstat_by_handle instead of fstat to avoid overhead.
Diffstat (limited to 'winsup/cygwin/mmap.cc')
-rw-r--r--winsup/cygwin/mmap.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 60c8db27a..69e64b48b 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -49,8 +49,6 @@ details. */
/* Used for anonymous mappings. */
static fhandler_dev_zero fh_anonymous;
-/* Used for reopening a disk file when necessary. */
-static fhandler_disk_file fh_disk_file;
/* Small helpers to avoid having lots of flag bit tests in the code. */
static inline bool
@@ -807,6 +805,8 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
caddr_t ret = (caddr_t) MAP_FAILED;
fhandler_base *fh = NULL;
+ fhandler_disk_file *fh_disk_file = NULL; /* Used for reopening a disk file
+ when necessary. */
list *map_list = NULL;
size_t orig_len = 0;
caddr_t base = NULL;
@@ -816,7 +816,6 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
fh_anonymous.set_io_handle (INVALID_HANDLE_VALUE);
fh_anonymous.set_access (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE);
- fh_disk_file.set_io_handle (NULL);
SetResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
@@ -888,9 +887,11 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
| FILE_OPEN_FOR_BACKUP_INTENT);
if (NT_SUCCESS (status))
{
- fh_disk_file.set_io_handle (h);
- fh_disk_file.set_access (fh->get_access () | GENERIC_EXECUTE);
- fh = &fh_disk_file;
+ fh_disk_file = new (alloca (sizeof *fh_disk_file)) fhandler_disk_file;
+ fh_disk_file->set_name (fh->pc);
+ fh_disk_file->set_io_handle (h);
+ fh_disk_file->set_access (fh->get_access () | GENERIC_EXECUTE);
+ fh = fh_disk_file;
}
else if (prot & PROT_EXEC)
{
@@ -901,7 +902,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
goto out;
}
- if (fh->fstat (&st))
+ if (fh->fstat_by_handle (&st))
{
__seterrno ();
goto out;
@@ -1074,8 +1075,8 @@ out:
ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
- if (fh_disk_file.get_handle ())
- NtClose (fh_disk_file.get_handle ());
+ if (fh_disk_file)
+ NtClose (fh_disk_file->get_handle ());
syscall_printf ("%p = mmap() ", ret);
return ret;