linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Armin Schindler <aml@melware.de>
To: Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>
Cc: Armin Schindler <armin@melware.de>
Subject: [PATCH 2.4] sys_select() return error on bad file
Date: Wed, 3 Mar 2004 09:46:54 +0100 (MET)	[thread overview]
Message-ID: <Pine.LNX.4.31.0403030936570.9608-100000@phoenix.one.melware.de> (raw)

Hi,

the following patch now returns -EBADF in sys_select()/do_select()
if all specified file-descriptors are bad (e.g. were closed by another
thread).

Without this patch, the for-loop in do_select() won't stop if there are no
valid files any more. It stops only if a specified timeout occured or a
signal arrived.

If there are no objections on this patch, I would also create a patch for
kernel 2.6 and the poll() code. I didn't have a closer look at this yet.

Armin

--- linux/fs/select.c_orig	2004-03-02 19:06:44.000000000 +0100
+++ linux/fs/select.c	2004-03-03 09:25:24.000000000 +0100
@@ -183,6 +183,8 @@
 		wait = NULL;
 	retval = 0;
 	for (;;) {
+		int file_err = 1;
+
 		set_current_state(TASK_INTERRUPTIBLE);
 		for (i = 0 ; i < n; i++) {
 			unsigned long bit = BIT(i);
@@ -199,6 +201,7 @@
 						  i /*  The fd*/,
 						  __timeout,
 						  NULL);
+				file_err = 0;
 				mask = DEFAULT_POLLMASK;
 				if (file->f_op && file->f_op->poll)
 					mask = file->f_op->poll(file, wait);
@@ -227,6 +230,10 @@
 			retval = table.error;
 			break;
 		}
+		if (file_err) {
+			retval = -EBADF;
+			break;
+		}
 		__timeout = schedule_timeout(__timeout);
 	}
 	current->state = TASK_RUNNING;


             reply	other threads:[~2004-03-03  8:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-03  8:46 Armin Schindler [this message]
2004-03-04  7:22 ` [PATCH 2.4] sys_select() return error on bad file Willy Tarreau
2004-03-04  9:20   ` Armin Schindler
2004-03-04 13:48     ` Willy Tarreau
2004-03-14 15:58     ` Marcelo Tosatti
2004-03-14 18:18 Manfred Spraul
2004-03-15 10:33 ` Armin Schindler

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=Pine.LNX.4.31.0403030936570.9608-100000@phoenix.one.melware.de \
    --to=aml@melware.de \
    --cc=armin@melware.de \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).