Cygwin: timerfd: fix shared memory allocation in fork/exec
timerfd_tracker::fixup_after_fork_exec always tries to restore the shared timer region at the same address as in the parent. This is entirely unnecessary and wasn't intended, rather some kind of copy/paste thinko. Fix that. Print NtMapViewOfSection status code in api_fatal on failure for debugging. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
aeaa051f3b
commit
a4e2eb6ba3
|
@ -12,6 +12,9 @@ Bug Fixes
|
||||||
- Fix timerfd select always returning immediately.
|
- Fix timerfd select always returning immediately.
|
||||||
Addresses: https://cygwin.com/ml/cygwin/2019-02/msg00364.html
|
Addresses: https://cygwin.com/ml/cygwin/2019-02/msg00364.html
|
||||||
|
|
||||||
|
- Fix fork/exec failing to restore timerfd share mem in child process.
|
||||||
|
Addresses: https://cygwin.com/ml/cygwin/2019-02/msg00400.html
|
||||||
|
|
||||||
- Drop enforcing case-correct group names for AD accounts to avoid
|
- Drop enforcing case-correct group names for AD accounts to avoid
|
||||||
excessively long startup times.
|
excessively long startup times.
|
||||||
Addresses: https://cygwin.com/ml/cygwin/2019-02/msg00301.html
|
Addresses: https://cygwin.com/ml/cygwin/2019-02/msg00301.html
|
||||||
|
|
|
@ -408,6 +408,7 @@ void
|
||||||
timerfd_tracker::fixup_after_fork_exec (bool execing)
|
timerfd_tracker::fixup_after_fork_exec (bool execing)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
PVOID base_address = NULL;
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
SIZE_T vsize = PAGE_SIZE;
|
SIZE_T vsize = PAGE_SIZE;
|
||||||
|
|
||||||
|
@ -416,11 +417,12 @@ timerfd_tracker::fixup_after_fork_exec (bool execing)
|
||||||
return;
|
return;
|
||||||
/* Recreate shared section mapping */
|
/* Recreate shared section mapping */
|
||||||
status = NtMapViewOfSection (tfd_shared_hdl, NtCurrentProcess (),
|
status = NtMapViewOfSection (tfd_shared_hdl, NtCurrentProcess (),
|
||||||
(void **) &tfd_shared, 0, PAGE_SIZE, NULL,
|
&base_address, 0, PAGE_SIZE, NULL,
|
||||||
&vsize, ViewShare, MEM_TOP_DOWN, 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!",
|
api_fatal ("Can't recreate shared timerfd section during %s, status %y!",
|
||||||
execing ? "execve" : "fork");
|
execing ? "execve" : "fork", status);
|
||||||
|
tfd_shared = (timerfd_shared *) base_address;
|
||||||
/* Increment global instance count by the number of instances in this
|
/* Increment global instance count by the number of instances in this
|
||||||
process */
|
process */
|
||||||
InterlockedAdd (&tfd_shared->instance_count, local_instance_count);
|
InterlockedAdd (&tfd_shared->instance_count, local_instance_count);
|
||||||
|
@ -430,8 +432,8 @@ timerfd_tracker::fixup_after_fork_exec (bool execing)
|
||||||
status = NtCreateEvent (&cancel_evt, EVENT_ALL_ACCESS, &attr,
|
status = NtCreateEvent (&cancel_evt, EVENT_ALL_ACCESS, &attr,
|
||||||
NotificationEvent, FALSE);
|
NotificationEvent, FALSE);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
api_fatal ("Can't recreate timerfd cancel event during %s!",
|
api_fatal ("Can't recreate timerfd cancel event during %s, status %y!",
|
||||||
execing ? "execve" : "fork");
|
execing ? "execve" : "fork", status);
|
||||||
/* Set winpid so we don't run this twice */
|
/* Set winpid so we don't run this twice */
|
||||||
winpid = GetCurrentProcessId ();
|
winpid = GetCurrentProcessId ();
|
||||||
new cygthread (timerfd_thread, this, "timerfd", sync_thr);
|
new cygthread (timerfd_thread, this, "timerfd", sync_thr);
|
||||||
|
|
Loading…
Reference in New Issue