watcher: Change handling of POLLERR and remove WATCHER_EXCEPT
We can't actually explicitly listen for errors by passing POLLERR in `events` (the man page for poll() clearly states it's ignored). On the other hand, POLLERR can be returned for any FD and, even worse, it might be the only event indicated. The latter caused an infinite loop as we didn't notify the callback nor clear the error by calling `getsockopt(..., SOL_SOCKET, SO_ERROR, ...)`. And while the latter would be able to reset the state to break the loop, it seems to leave the FD in a defunct state where no further events will be returned by poll(). Notifying the callback works better (the error is then reported by e.g. recvfrom()) and automatically happened already if POLLERR was returned together with e.g. POLLIN. So we now treat POLLERR like the other error indicators we handle (POLLHUP and POLLINVAL) and just notify the callbacks.
This commit is contained in:
@@ -55,7 +55,6 @@ typedef bool (*watcher_cb_t)(void *data, int fd, watcher_event_t event);
|
||||
enum watcher_event_t {
|
||||
WATCHER_READ = (1<<0),
|
||||
WATCHER_WRITE = (1<<1),
|
||||
WATCHER_EXCEPT = (1<<2),
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user