Commit Graph

3 Commits

Author SHA1 Message Date
Corinna Vinschen 95bc4240ed Cygwin: timerfd: convert expiry timestamp to LONG64
Turns out we never need it as LARGE_INTEGER.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-20 22:46:44 +01:00
Corinna Vinschen 693c98c5e2 Cygwin: timerfd: Fix entering critical section
Getting an abandonded mutex is just as well and must be handled.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-20 22:19:27 +01:00
Corinna Vinschen 40481dbabb Cygwin: timerfd: reimplement from scratch
Using posix timers "timer_tracker" as base class for timerfd was flawed.
Posix timers are not inherited by child processes and don't survive
execve.  The method used by posix timers didn't allow to share timers
between processes. The timers were still per-process timers and worked
entirely separate from each other.  Reading from these timers via
different descriptors was only synchronized within the same process.

This does not reflect the timerfd semantics in Linux: The per-file
timers can be dup'ed and survive fork and execve.  They are still just
descriptors pointing to the same timer object originally created by
timerfd_create.  Synchronization is performed between all descriptor
instances of the same timer, system-wide.

Thus, reimplement timerfd using a timer instance in shared memory,
a kernel timer, and a handful of sync objects.

Every process maintains a per-process timerfd struct on the cygheap
maintaining a per-process thread.  Every process sharing the same
timerfd will run this thread checking the state of the timer, similar
to the posix timer thread, just working on the shared objects and
synchronizing its job with each other thread.

Drop the timerfd implementation in the posix timer code and move the
public API to fhandler_timerfd.c.  Keep the ttstart timer_tracker
anchor out of "NO_COPY" since the fixup_after_fork code should run to
avoid memory leakage.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-19 20:00:06 +01:00