kernel - make POLLHUP conform better to OpenGroup
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 13 Aug 2010 22:06:12 +0000 (15:06 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 13 Aug 2010 22:06:12 +0000 (15:06 -0700)
commit9a5d20db2b31ebaf094a3cb60c7342b1026f2947
tree37a0ef142d7f997e9dae8c17cef09095f6ef9e5c
parent8c4ed4265ed709e0ff2e164b292fd6b3febef5d3
kernel - make POLLHUP conform better to OpenGroup

* The poll() backend now only evaluates EV_EOF for EVFILT_WRITE, and
  generates a POLLHUP which is properly mutually exclusive with
  POLLWRNORM and POLLOUT.

  We do this even for a half-closed (write-side-closed) socket.

* We no longer set POLLHUP for POLLRD* or POLLIN, instead relying on
  the userland doing the read() and checking the 0 result (which
  userland has always done historically).

  EV_EOF for EVFILT_READ cannot be used to set POLLHUP for POLLRD* or
  POLLIN because it could indicate a half-closed connection
  (read-side-closed) where writing is still allowed, which is a more
  common situation on sockets.

  We would have to add another EV_ flag to set POLLHUP for POLLRD* or
  POLLIN to detect the fully disconnected state.  The OpenGroup standard
  does allow POLLHUP to be mixed with POLLRD* or POLLIN but for now we
  just don't set it at all in that case.

  Only a POLLOUT/POLLWRNORM flag request can cause POLLHUP to be set
  for now.
sys/kern/sys_generic.c