calls to select(2) ignore exceptions
archie at whistle.com
Tue Aug 18 09:28:22 PDT 1998
Godmar Back writes:
> > In the course of trying to track down an unrelated bug, I noticed that
> > when calling select(2), kaffe is ignoring any "exceptional conditions".
> > This seems like a bad thing to do. It should throw an IOException if
> > there are any exceptions on a file descriptor.
> Why should it do that? Can you give examples where exceptional
> conditions are mapped to exceptions?
Sure.. if you have an open TCP socket, for example, and the remote
side resets the connection, you'll get an exceptional condition.
I guess you're right in that you don't want to throw an IOException
in this case -- so I take that back. However, you do want to do
*something* when there's an exceptional condition, like return EOF.
I think if you simply wake up the thread when an exceptional condition
is detected (which is what my patch does, I think), that should be
sufficient, because on the next read/write attempt it will get a
corresponding error as appropriate.
The TCP socket example is not the best one because it will probably
become readable at the same time. Perhaps better would be when writing
to a pipe, and the remote side closes the pipe. Then the file descriptor
will get an exceptional condition. You need to detect this, or else
the thread will remain blocked until the next write attempt (at which
point you then get EPIPE).
Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com
More information about the kaffe