diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2008-09-22 17:42:46 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-09-24 09:45:47 -0400 |
commit | 4aa7361179bed905fd0f35b236a5c65db683b9e0 (patch) | |
tree | 115b16f51fafc38f8a76c9fd7e71ce44884aa8e7 /kernel/posix-timers.c | |
parent | bb34d92f643086d546b49cef680f6f305ed84414 (diff) |
posix-timers: don't switch to ->group_leader if ->it_process dies
posix_timer_event() drops SIGEV_THREAD_ID and switches to ->group_leader
if send_sigqueue() fails.
This is not very useful and doesn't work reliably. send_sigqueue() can
only fail if ->it_process is dead. But it can die before it dequeues the
SI_TIMER signal, in that case the timer stops anyway.
Remove this code. I guess it was needed a long ago to ensure that the
timer is not destroyed when when its creator thread dies.
Q: perhaps it makes sense to change sys_timer_settime() to return an error
if ->it_process is dead?
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: mingo@elte.hu
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/posix-timers.c')
-rw-r--r-- | kernel/posix-timers.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index e36d5798cbff..3dfd15aecc60 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -298,6 +298,7 @@ void do_schedule_next_timer(struct siginfo *info) | |||
298 | 298 | ||
299 | int posix_timer_event(struct k_itimer *timr, int si_private) | 299 | int posix_timer_event(struct k_itimer *timr, int si_private) |
300 | { | 300 | { |
301 | int shared, ret; | ||
301 | /* | 302 | /* |
302 | * FIXME: if ->sigq is queued we can race with | 303 | * FIXME: if ->sigq is queued we can race with |
303 | * dequeue_signal()->do_schedule_next_timer(). | 304 | * dequeue_signal()->do_schedule_next_timer(). |
@@ -316,20 +317,10 @@ int posix_timer_event(struct k_itimer *timr, int si_private) | |||
316 | timr->sigq->info.si_tid = timr->it_id; | 317 | timr->sigq->info.si_tid = timr->it_id; |
317 | timr->sigq->info.si_value = timr->it_sigev_value; | 318 | timr->sigq->info.si_value = timr->it_sigev_value; |
318 | 319 | ||
319 | if (timr->it_sigev_notify & SIGEV_THREAD_ID) { | 320 | shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID); |
320 | struct task_struct *leader; | 321 | ret = send_sigqueue(timr->sigq, timr->it_process, shared); |
321 | int ret = send_sigqueue(timr->sigq, timr->it_process, 0); | 322 | /* If we failed to send the signal the timer stops. */ |
322 | 323 | return ret > 0; | |
323 | if (likely(ret >= 0)) | ||
324 | return ret; | ||
325 | |||
326 | timr->it_sigev_notify = SIGEV_SIGNAL; | ||
327 | leader = timr->it_process->group_leader; | ||
328 | put_task_struct(timr->it_process); | ||
329 | timr->it_process = leader; | ||
330 | } | ||
331 | |||
332 | return send_sigqueue(timr->sigq, timr->it_process, 1); | ||
333 | } | 324 | } |
334 | EXPORT_SYMBOL_GPL(posix_timer_event); | 325 | EXPORT_SYMBOL_GPL(posix_timer_event); |
335 | 326 | ||