Commit 4cd4b6d4 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Linus Torvalds
Browse files

signals: fold complete_signal() into send_signal/do_send_sigqueue



Factor out complete_signal() callsites.  This change completely unifies the
helpers sending the specific/group signals.

Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5fcd835b
Loading
Loading
Loading
Loading
+11 −35
Original line number Original line Diff line number Diff line
@@ -826,7 +826,8 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,


out_set:
out_set:
	sigaddset(&pending->signal, sig);
	sigaddset(&pending->signal, sig);
	return 1;
	complete_signal(sig, t, group);
	return 0;
}
}


int print_fatal_signals;
int print_fatal_signals;
@@ -861,17 +862,16 @@ static int __init setup_print_fatal_signals(char *str)


__setup("print-fatal-signals=", setup_print_fatal_signals);
__setup("print-fatal-signals=", setup_print_fatal_signals);


int
__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
{
	return send_signal(sig, info, p, 1);
}

static int
static int
specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
{
{
	int ret;
	return send_signal(sig, info, t, 0);

	ret = send_signal(sig, info, t, 0);
	if (ret <= 0)
		return ret;

	complete_signal(sig, t, 0);
	return 0;
}
}


/*
/*
@@ -914,24 +914,6 @@ force_sig_specific(int sig, struct task_struct *t)
	force_sig_info(sig, SEND_SIG_FORCED, t);
	force_sig_info(sig, SEND_SIG_FORCED, t);
}
}


int
__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
{
	int ret;

	/*
	 * Put this signal on the shared-pending queue, or fail with EAGAIN.
	 * We always use the shared queue for process-wide signals,
	 * to avoid several races.
	 */
	ret = send_signal(sig, info, p, 1);
	if (ret <= 0)
		return ret;

	complete_signal(sig, p, 1);
	return 0;
}

/*
/*
 * Nuke all other threads in the group.
 * Nuke all other threads in the group.
 */
 */
@@ -1263,6 +1245,7 @@ static int do_send_sigqueue(int sig, struct sigqueue *q, struct task_struct *t,
{
{
	struct sigpending *pending;
	struct sigpending *pending;


	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
	handle_stop_signal(sig, t);
	handle_stop_signal(sig, t);


	if (unlikely(!list_empty(&q->list))) {
	if (unlikely(!list_empty(&q->list))) {
@@ -1283,6 +1266,7 @@ static int do_send_sigqueue(int sig, struct sigqueue *q, struct task_struct *t,
	pending = group ? &t->signal->shared_pending : &t->pending;
	pending = group ? &t->signal->shared_pending : &t->pending;
	list_add_tail(&q->list, &pending->list);
	list_add_tail(&q->list, &pending->list);
	sigaddset(&pending->signal, sig);
	sigaddset(&pending->signal, sig);
	complete_signal(sig, t, group);


	return 0;
	return 0;
}
}
@@ -1292,8 +1276,6 @@ int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)
	unsigned long flags;
	unsigned long flags;
	int ret = -1;
	int ret = -1;


	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));

	/*
	/*
	 * The rcu based delayed sighand destroy makes it possible to
	 * The rcu based delayed sighand destroy makes it possible to
	 * run this without tasklist lock held. The task struct itself
	 * run this without tasklist lock held. The task struct itself
@@ -1307,8 +1289,6 @@ int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)


	ret = do_send_sigqueue(sig, q, p, 0);
	ret = do_send_sigqueue(sig, q, p, 0);


	complete_signal(sig, p, 0);

	unlock_task_sighand(p, &flags);
	unlock_task_sighand(p, &flags);
out_err:
out_err:
	return ret;
	return ret;
@@ -1320,15 +1300,11 @@ send_group_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)
	unsigned long flags;
	unsigned long flags;
	int ret;
	int ret;


	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));

	/* Since it_lock is held, p->sighand cannot be NULL. */
	/* Since it_lock is held, p->sighand cannot be NULL. */
	spin_lock_irqsave(&p->sighand->siglock, flags);
	spin_lock_irqsave(&p->sighand->siglock, flags);


	ret = do_send_sigqueue(sig, q, p, 1);
	ret = do_send_sigqueue(sig, q, p, 1);


	complete_signal(sig, p, 1);

	spin_unlock_irqrestore(&p->sighand->siglock, flags);
	spin_unlock_irqrestore(&p->sighand->siglock, flags);


	return ret;
	return ret;