Cygwin: timerfd: implement execve semantics
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
4195bae67f
commit
0e8c7b8689
|
@ -161,10 +161,15 @@ fhandler_timerfd::dup (fhandler_base *child, int flags)
|
||||||
void
|
void
|
||||||
fhandler_timerfd::fixup_after_exec ()
|
fhandler_timerfd::fixup_after_exec ()
|
||||||
{
|
{
|
||||||
if (!close_on_exec ())
|
if (close_on_exec ())
|
||||||
|
return;
|
||||||
|
__try
|
||||||
{
|
{
|
||||||
/* TODO after exec */
|
timer_tracker *tt = (timer_tracker *) timerid;
|
||||||
|
tt->fixup_after_exec ();
|
||||||
}
|
}
|
||||||
|
__except (EFAULT) {}
|
||||||
|
__endtry
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -108,16 +108,6 @@ timer_tracker::timer_tracker (clockid_t c, const sigevent *e, bool fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_tracker::increment_instances ()
|
|
||||||
{
|
|
||||||
InterlockedIncrement (&instance_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
LONG timer_tracker::decrement_instances ()
|
|
||||||
{
|
|
||||||
return InterlockedDecrement (&instance_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int64_t
|
static inline int64_t
|
||||||
timespec_to_us (const timespec& ts)
|
timespec_to_us (const timespec& ts)
|
||||||
{
|
{
|
||||||
|
@ -152,7 +142,6 @@ timer_tracker::_disarm_event ()
|
||||||
yield ();
|
yield ();
|
||||||
if (ret == EVENT_ARMED)
|
if (ret == EVENT_ARMED)
|
||||||
{
|
{
|
||||||
|
|
||||||
InterlockedExchange64 (&overrun_count_curr, overrun_count);
|
InterlockedExchange64 (&overrun_count_curr, overrun_count);
|
||||||
ret = overrun_count_curr;
|
ret = overrun_count_curr;
|
||||||
InterlockedExchange64 (&overrun_count, 0);
|
InterlockedExchange64 (&overrun_count, 0);
|
||||||
|
@ -461,6 +450,23 @@ timer_tracker::restart ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Only called from fhandler_timerfd::fixup_after_exec. Note that
|
||||||
|
we don't touch the instance count. This is handled by closing
|
||||||
|
the timer from fhandler_timerfd::close on O_CLOEXEC. Ultimately
|
||||||
|
the instance count should be correct after execve. */
|
||||||
|
void
|
||||||
|
timer_tracker::fixup_after_exec ()
|
||||||
|
{
|
||||||
|
lock_timer_tracker here;
|
||||||
|
/* Check if timer is already in the list. If so, skip it. */
|
||||||
|
for (timer_tracker *tt = &ttstart; tt->next != NULL; tt = tt->next)
|
||||||
|
if (tt->next == this)
|
||||||
|
return;
|
||||||
|
next = ttstart.next;
|
||||||
|
ttstart.next = this;
|
||||||
|
restart ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
timer_tracker::fixup_after_fork ()
|
timer_tracker::fixup_after_fork ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ class timer_tracker
|
||||||
LONG64 overrun_count;
|
LONG64 overrun_count;
|
||||||
|
|
||||||
bool cancel ();
|
bool cancel ();
|
||||||
LONG decrement_instances ();
|
LONG decrement_instances () { return InterlockedDecrement (&instance_count); }
|
||||||
int clean_and_unhook ();
|
int clean_and_unhook ();
|
||||||
LONG64 _disarm_event ();
|
LONG64 _disarm_event ();
|
||||||
void restart ();
|
void restart ();
|
||||||
|
@ -45,7 +45,8 @@ class timer_tracker
|
||||||
~timer_tracker ();
|
~timer_tracker ();
|
||||||
inline bool is_timer_tracker () const { return magic == TT_MAGIC; }
|
inline bool is_timer_tracker () const { return magic == TT_MAGIC; }
|
||||||
|
|
||||||
void increment_instances ();
|
|
||||||
|
void increment_instances () { InterlockedIncrement (&instance_count); }
|
||||||
LONG64 wait (bool nonblocking);
|
LONG64 wait (bool nonblocking);
|
||||||
HANDLE get_timerfd_handle () const { return timerfd_event; }
|
HANDLE get_timerfd_handle () const { return timerfd_event; }
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ class timer_tracker
|
||||||
unsigned int disarm_event ();
|
unsigned int disarm_event ();
|
||||||
|
|
||||||
DWORD thread_func ();
|
DWORD thread_func ();
|
||||||
|
void fixup_after_exec ();
|
||||||
static void fixup_after_fork ();
|
static void fixup_after_fork ();
|
||||||
static int close (timer_tracker *tt);
|
static int close (timer_tracker *tt);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue