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:
parent
a295866ce8
commit
1845e05a34
1 changed files with 1 additions and 1 deletions
|
|
@ -156,7 +156,7 @@ elif defined(linux):
|
||||||
let fd = s.events[i].data.fd.SocketHandle
|
let fd = s.events[i].data.fd.SocketHandle
|
||||||
|
|
||||||
var evSet: set[Event] = {}
|
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 EPOLLIN) != 0: evSet = evSet + {EvRead}
|
||||||
if (s.events[i].events and EPOLLOUT) != 0: evSet = evSet + {EvWrite}
|
if (s.events[i].events and EPOLLOUT) != 0: evSet = evSet + {EvWrite}
|
||||||
let selectorKey = s.fds[fd]
|
let selectorKey = s.fds[fd]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue