Messages in this thread | | | Date | Thu, 4 Mar 2004 08:22:25 +0100 | From | Willy Tarreau <> | Subject | Re: [PATCH 2.4] sys_select() return error on bad file |
| |
Hi,
On Wed, Mar 03, 2004 at 09:46:54AM +0100, Armin Schindler wrote: > --- 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; > +
Just a thought, select() is often performance-critical, and adding one more variable inside the loop can slow it down a bit. Wouldn't it be cheaper to set retval to -EBADF above and avoid using file_err ?
> 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;
There you would put retval=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; > + }
And there : if (retval == -EBADF) break;
> __timeout = schedule_timeout(__timeout); > } > current->state = TASK_RUNNING;
Just a thought anyway, I've not read the complete function.
Cheers, Willy
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |