Handle EPOLLHUP to avoid chaos/runaways when using certain file descriptors.

A concrete example is pipe file descriptors: they generate EPOLLHUP instead of a EPOLLIN (then 0 bytes read). The loop will run wild if this event is not handled.
This commit is contained in:
Elie Zedeck
2015-01-21 18:15:38 +03:00
parent a295866ce8
commit 1845e05a34

View File

@@ -156,7 +156,7 @@ elif defined(linux):
let fd = s.events[i].data.fd.SocketHandle
var evSet: set[Event] = {}
if (s.events[i].events and EPOLLERR) != 0: evSet = evSet + {EvError}
if (s.events[i].events and EPOLLERR) != 0 or (s.events[i].events and EPOLLHUP) != 0: evSet = evSet + {EvError}
if (s.events[i].events and EPOLLIN) != 0: evSet = evSet + {EvRead}
if (s.events[i].events and EPOLLOUT) != 0: evSet = evSet + {EvWrite}
let selectorKey = s.fds[fd]