From: Manfred Spraul <manfred@colorfullife.com>
To: Marcelo Tosatti <marcelo.tosatti@cyclades.com>
Cc: linux-kernel@vger.kernel.org, Armin Schindler <aml@melware.de>
Subject: Re: [PATCH 2.4] sys_select() return error on bad file
Date: Sun, 14 Mar 2004 19:18:59 +0100 [thread overview]
Message-ID: <4054A213.6010402@colorfullife.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1482 bytes --]
Marcelo wrote:
>>
>> Anyway, I don't see how your proposal would do better performance?
>> My patch just adds a new variable on the stack, which should not make any
>> difference in performance. And later, it is the same if the new or another
>> variable gets changed or checked.
>
>Curiosity: Does SuS/POSIX define behaviour for "all fds are closed" ?
>
>
I'd interpret SuS that a closed fd is ready for reading and writing:
From the select page:
<<<
A descriptor shall be considered ready for reading when a call to an
input function with O_NONBLOCK clear would not block, whether or not the
function would transfer data successfully. (The function might return
data, an end-of-file indication, or an error other than one indicating
that it is blocked, and in each of these cases the descriptor shall be
considered ready for reading.)
<<<
read(fd,,) will return immediately with EBADF, thus the fd is ready.
But that's a grey area, especially if you close the fd during the select
call. For example HP UX just kills the current process if an fd that is
polled is closed by overwriting it with dup2. I didn't test select, but
I'd expect a similar behavior.
Armin: did you compare the Linux behavior with other unices? Are there
other unices that return EBADF for select() if all fds are closed?
Attached is an untested proposal, against 2.6, but I'm not sure if it's
really a good idea to change the current code - it might break existing
apps.
--
Manfred
[-- Attachment #2: patch-select-2.6 --]
[-- Type: text/plain, Size: 1013 bytes --]
--- 2.6/fs/select.c 2004-03-14 14:28:28.000000000 +0100
+++ build-2.6/fs/select.c 2004-03-14 19:08:57.000000000 +0100
@@ -223,25 +223,25 @@
break;
if (!(bit & all_bits))
continue;
+ mask = DEFAULT_POLLMASK;
file = fget(i);
if (file) {
f_op = file->f_op;
- mask = DEFAULT_POLLMASK;
if (f_op && f_op->poll)
mask = (*f_op->poll)(file, retval ? NULL : wait);
fput(file);
- if ((mask & POLLIN_SET) && (in & bit)) {
- res_in |= bit;
- retval++;
- }
- if ((mask & POLLOUT_SET) && (out & bit)) {
- res_out |= bit;
- retval++;
- }
- if ((mask & POLLEX_SET) && (ex & bit)) {
- res_ex |= bit;
- retval++;
- }
+ }
+ if ((mask & POLLIN_SET) && (in & bit)) {
+ res_in |= bit;
+ retval++;
+ }
+ if ((mask & POLLOUT_SET) && (out & bit)) {
+ res_out |= bit;
+ retval++;
+ }
+ if ((mask & POLLEX_SET) && (ex & bit)) {
+ res_ex |= bit;
+ retval++;
}
}
if (res_in)
next reply other threads:[~2004-03-14 18:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-14 18:18 Manfred Spraul [this message]
2004-03-15 10:33 ` [PATCH 2.4] sys_select() return error on bad file Armin Schindler
-- strict thread matches above, loose matches on Subject: below --
2004-03-03 8:46 Armin Schindler
2004-03-04 7:22 ` Willy Tarreau
2004-03-04 9:20 ` Armin Schindler
2004-03-04 13:48 ` Willy Tarreau
2004-03-14 15:58 ` Marcelo Tosatti
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=4054A213.6010402@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=aml@melware.de \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.tosatti@cyclades.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