From: Matthew Wilcox <willy@debian.org>
To: mingo@redhat.com, Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Remove another for_each_process loop
Date: Thu, 3 Oct 2002 22:39:18 +0100 [thread overview]
Message-ID: <20021003223918.K28586@parcelfarce.linux.theplanet.co.uk> (raw)
Convert send_sigurg() to the for_each_task_pid() mechanism. Also in
the case where we were trying to send a signal to a non-existent PID,
don't bother searching for -PID in the PGID array; we won't find it.
diff -urpNX dontdiff linux-2.5.40/fs/fcntl.c linux-2.5.40-willy/fs/fcntl.c
--- linux-2.5.40/fs/fcntl.c 2002-10-01 03:06:17.000000000 -0400
+++ linux-2.5.40-willy/fs/fcntl.c 2002-10-03 15:48:19.000000000 -0400
@@ -491,15 +491,17 @@ void send_sigio(struct fown_struct *fown
goto out_unlock_fown;
read_lock(&tasklist_lock);
- if ( (pid > 0) && (p = find_task_by_pid(pid)) ) {
- send_sigio_to_task(p, fown, fd, band);
- goto out_unlock_task;
- }
- for_each_task_pid(-pid, PIDTYPE_PGID, p, l, pidptr)
- send_sigio_to_task(p, fown,fd,band);
-out_unlock_task:
+ if (pid > 0) {
+ if (p = find_task_by_pid(pid)) {
+ send_sigio_to_task(p, fown, fd, band);
+ }
+ } else {
+ for_each_task_pid(-pid, PIDTYPE_PGID, p, l, pidptr) {
+ send_sigio_to_task(p, fown, fd, band);
+ }
+ }
read_unlock(&tasklist_lock);
-out_unlock_fown:
+ out_unlock_fown:
read_unlock(&fown->lock);
}
@@ -523,21 +525,17 @@ int send_sigurg(struct fown_struct *fown
ret = 1;
read_lock(&tasklist_lock);
- if ((pid > 0) && (p = find_task_by_pid(pid))) {
- send_sigurg_to_task(p, fown);
- goto out_unlock_task;
- }
- for_each_process(p) {
- int match = p->pid;
- if (pid < 0)
- match = -p->pgrp;
- if (pid != match)
- continue;
- send_sigurg_to_task(p, fown);
+ if (pid > 0) {
+ if (p = find_task_by_pid(pid)) {
+ send_sigurg_to_task(p, fown);
+ }
+ } else {
+ for_each_task_pid(-pid, PIDTYPE_PGID, p, l, pidptr) {
+ send_sigurg_to_task(p, fown);
+ }
}
-out_unlock_task:
read_unlock(&tasklist_lock);
-out_unlock_fown:
+ out_unlock_fown:
read_unlock(&fown->lock);
return ret;
}
--
Revolutions do not require corporate support.
reply other threads:[~2002-10-03 21:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021003223918.K28586@parcelfarce.linux.theplanet.co.uk \
--to=willy@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®