]> mj.ucw.cz Git - libucw.git/commit
Main: Clean up handling of poll flags
authorMartin Mares <mj@ucw.cz>
Fri, 19 Aug 2011 10:29:34 +0000 (12:29 +0200)
committerMartin Mares <mj@ucw.cz>
Fri, 19 Aug 2011 10:29:34 +0000 (12:29 +0200)
commitcd7dce2a6e06894c5e8c24ae399fe1900d6462e1
tree545b3c544d6e85f9e6db950ae88bfc7608764d1a
parent06a563e3a33a8687f1ce75a7545dd9d88ea30f69
Main: Clean up handling of poll flags

- We no longer include POLLERR and POLLHUP in the set of requested
  events. The standard (SUSv2) says they will be delivered regardless
  of the event mask chosen.

- POLLERR is an output event, so we call only the write handler.

- POLLHUP is documented as an output event, but it sometimes signals
  events which we would like to process by the input handler. The
  situations when POLLHUP is generated include:

    *  on reading end of a pipe when the writing end has been closed
       -> we would like to call read handler and get EOF (write handler
       does not exist)

    *  on writing end of a pipe when the reading end has been closed
       -> we would like to call write handler (read handler does not
       exist)

    *  on a R/W socket when the other end has been closed -> better
       call read handler to get an EOF

    *  on a tty which has been hanged up -> probably the same as a R/W
       socket

  We have therefore decided to call the read handler, but fall back to
  the write handler if the read handler does not exist.

- When a handler decided to remove itself (but keep the main_file),
  we could have entered an infinite loop. This no longer happens.
ucw/mainloop.c