lkml.org 
[lkml]   [2003]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: epoll vs stdin/stdout
Eric Varsanyi wrote:
> Epoll's API/impl is great as it is IMO, not suggesting need for change, I was
> hoping there was a good standard trick someone worked up to get around
> this specifc end case of stdin/stdout usually being dups but sometimes
> not. Porting my event system over to use epoll was easy/straightforward
> except for this one minor hitch.

Easy: if it's a read event, it's stdin; if it's a write event, it's stdout :)

You've raised an interesting problem. It is easy to fix this in the
specific case of stdin/stdout, however what happens when your process
is passed a pair of fds from some other process (or more than one
process, using AF_UNIX), and told to read one and write the other?
What happens when you have 10 fds from different sources, some for
reading and some for writing (quite typical in a complex server)?

With the epoll API, your process has to know whether any paids or fds
correspond to the same file *, in order to decide whether to register
one interested in READ+WRITE or two interests separately.

Unfortunately I cannot think of a way for a process to know, in
general, whether two fds that it is passed correspond to the same file
*. Well, apart from trying epoll on it and seeing what happens :/

Perhaps this indicates the epoll API _is_ flawed. Epoll maintains
this state mapping:

file * -> (event mask, event states)

when it ought to maintain this:

(file *, event type) -> event state

In other words, perhaps epoll should be keeping registered interest in
read events and registered interest in write events completely
separate.

I suspect changing the API to do that wouldn't even break any of the
existing apps.

Davide, what do you think?

-- Jamie
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.056 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site