Cygwin: timerfd: reduce size of shared mem region to a single page
The share section was created using the PAGE_SIZE constant, but PAGE_SIZE is 64K. Fix that by using wincap.page_size() instead, which returns the desired actual page size of 4K. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
3b3ba558e9
commit
5a483b6bca
|
@ -210,8 +210,8 @@ timerfd_tracker::create (clockid_t clock_id)
|
||||||
|
|
||||||
const ACCESS_MASK access = STANDARD_RIGHTS_REQUIRED
|
const ACCESS_MASK access = STANDARD_RIGHTS_REQUIRED
|
||||||
| SECTION_MAP_READ | SECTION_MAP_WRITE;
|
| SECTION_MAP_READ | SECTION_MAP_WRITE;
|
||||||
SIZE_T vsize = PAGE_SIZE;
|
SIZE_T vsize = wincap.page_size ();
|
||||||
LARGE_INTEGER sectionsize = { QuadPart: PAGE_SIZE };
|
LARGE_INTEGER sectionsize = { QuadPart: (LONGLONG) wincap.page_size () };
|
||||||
|
|
||||||
/* Valid clock? */
|
/* Valid clock? */
|
||||||
if (!get_clock (clock_id))
|
if (!get_clock (clock_id))
|
||||||
|
@ -290,7 +290,7 @@ timerfd_tracker::create (clockid_t clock_id)
|
||||||
/* Create section mapping (has to be recreated after fork/exec) */
|
/* Create section mapping (has to be recreated after fork/exec) */
|
||||||
tfd_shared = NULL;
|
tfd_shared = NULL;
|
||||||
status = NtMapViewOfSection (tfd_shared_hdl, NtCurrentProcess (),
|
status = NtMapViewOfSection (tfd_shared_hdl, NtCurrentProcess (),
|
||||||
(void **) &tfd_shared, 0, PAGE_SIZE, NULL,
|
(void **) &tfd_shared, 0, vsize, NULL,
|
||||||
&vsize, ViewShare, 0, PAGE_READWRITE);
|
&vsize, ViewShare, 0, PAGE_READWRITE);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
|
@ -397,7 +397,7 @@ timerfd_tracker::fixup_after_fork_exec (bool execing)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
SIZE_T vsize = PAGE_SIZE;
|
SIZE_T vsize = wincap.page_size ();
|
||||||
|
|
||||||
/* Run this only once per process */
|
/* Run this only once per process */
|
||||||
if (winpid == GetCurrentProcessId ())
|
if (winpid == GetCurrentProcessId ())
|
||||||
|
@ -405,7 +405,7 @@ timerfd_tracker::fixup_after_fork_exec (bool execing)
|
||||||
/* Recreate shared section mapping */
|
/* Recreate shared section mapping */
|
||||||
tfd_shared = NULL;
|
tfd_shared = NULL;
|
||||||
status = NtMapViewOfSection (tfd_shared_hdl, NtCurrentProcess (),
|
status = NtMapViewOfSection (tfd_shared_hdl, NtCurrentProcess (),
|
||||||
(PVOID *) &tfd_shared, 0, PAGE_SIZE, NULL,
|
(PVOID *) &tfd_shared, 0, vsize, NULL,
|
||||||
&vsize, ViewShare, 0, PAGE_READWRITE);
|
&vsize, ViewShare, 0, PAGE_READWRITE);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
api_fatal ("Can't recreate shared timerfd section during %s, status %y!",
|
api_fatal ("Can't recreate shared timerfd section during %s, status %y!",
|
||||||
|
|
Loading…
Reference in New Issue