Questions about select for sockets
Ken Brown
kbrown@cornell.edu
Sat Apr 3 18:16:20 GMT 2021
Some time ago I did a preliminary implementation of select for AF_UNIX sockets
on the topic/af_unix branch. I copied some things from the
fhandler_socket_wsock case without really understanding them. I'm taking a
second look now, and would like to clean this up. I'll start with just a few
questions, but there may be more to follow.
1. What's the purpose of 'except_on_write'? AFAICS, its only use is in
set_bits, to indicate that the readfds entry should be set in case of a failed
connect. But shouldn't that entry always be set if there's a failed connect
since a read won't block?
2. In that same place in set_bits where UNIX_FD_SET (me->fd, readfds) is called,
shouldn't ready be incremented?
3. In fhandler_socket_wsock::select_write where except_on_write is set,
except_ready is also set. Why is that done there? It seems to me that this is
redundant, because the same setting of except_ready is done in
fhandler_socket_wsock::select_except.
4. Why do we set
except_ready = saw_shutdown_write () || saw_shutdown_read () ?
I can't find any documentation that says that a shutdown should be considered an
exceptional condition. On the other hand, POSIX does say, "Other circumstances
under which a socket may be considered to have an exceptional condition pending
are protocol-specific and implementation-defined." So maybe there's some
Cygwin-specific reason for doing this?
Thanks.
Ken
More information about the Cygwin-developers
mailing list