summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2006-03-28 16:11:17 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-28 18:36:43 -0800
commit29ff471234d53c7235db287bc52f91884c2977c6 (patch)
tree1572661596414515ebfcfd0d2ea55a4217606a5e /kernel
parent6b3934ef52712ece50605dfc72e55d00c580831a (diff)
downloadlinux-29ff471234d53c7235db287bc52f91884c2977c6.tar.gz
linux-29ff471234d53c7235db287bc52f91884c2977c6.tar.bz2
linux-29ff471234d53c7235db287bc52f91884c2977c6.zip
[PATCH] cleanup __exit_signal()
This patch factors out duplicated code under 'if' branches. Also, BUG_ON() conversions and whitespace cleanups. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: "Paul E. McKenney" <paulmck@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/signal.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index 54e9ef673e68..ca1fa854e469 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -341,24 +341,20 @@ void __exit_sighand(struct task_struct *tsk)
*/
void __exit_signal(struct task_struct *tsk)
{
- struct signal_struct * sig = tsk->signal;
- struct sighand_struct * sighand;
+ struct signal_struct *sig = tsk->signal;
+ struct sighand_struct *sighand;
+
+ BUG_ON(!sig);
+ BUG_ON(!atomic_read(&sig->count));
- if (!sig)
- BUG();
- if (!atomic_read(&sig->count))
- BUG();
rcu_read_lock();
sighand = rcu_dereference(tsk->sighand);
spin_lock(&sighand->siglock);
+
posix_cpu_timers_exit(tsk);
- if (atomic_dec_and_test(&sig->count)) {
+ if (atomic_dec_and_test(&sig->count))
posix_cpu_timers_exit_group(tsk);
- tsk->signal = NULL;
- __exit_sighand(tsk);
- spin_unlock(&sighand->siglock);
- flush_sigqueue(&sig->shared_pending);
- } else {
+ else {
/*
* If there is any task waiting for the group exit
* then notify it:
@@ -369,7 +365,6 @@ void __exit_signal(struct task_struct *tsk)
}
if (tsk == sig->curr_target)
sig->curr_target = next_thread(tsk);
- tsk->signal = NULL;
/*
* Accumulate here the counters for all threads but the
* group leader as they die, so they can be added into
@@ -387,14 +382,18 @@ void __exit_signal(struct task_struct *tsk)
sig->nvcsw += tsk->nvcsw;
sig->nivcsw += tsk->nivcsw;
sig->sched_time += tsk->sched_time;
- __exit_sighand(tsk);
- spin_unlock(&sighand->siglock);
- sig = NULL; /* Marker for below. */
+ sig = NULL; /* Marker for below. */
}
+
+ tsk->signal = NULL;
+ __exit_sighand(tsk);
+ spin_unlock(&sighand->siglock);
rcu_read_unlock();
+
clear_tsk_thread_flag(tsk,TIF_SIGPENDING);
flush_sigqueue(&tsk->pending);
if (sig) {
+ flush_sigqueue(&sig->shared_pending);
__cleanup_signal(sig);
}
}