diff options
author | Elie Zedeck <elie.zedeck@gmail.com> | 2015-01-21 18:15:38 +0300 |
---|---|---|
committer | Elie Zedeck <elie.zedeck@gmail.com> | 2015-01-21 18:15:38 +0300 |
commit | 1845e05a34665c3dace740a953065f535ec66fc6 (patch) | |
tree | f40a57da26a09b867ba4b65cff4f8464019ea878 | |
parent | a295866ce8381f3a5bb723e2687282bb38896e65 (diff) | |
download | Nim-1845e05a34665c3dace740a953065f535ec66fc6.tar.gz |
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.
-rw-r--r-- | lib/pure/selectors.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim index 29f6cd3ab..bd2564937 100644 --- a/lib/pure/selectors.nim +++ b/lib/pure/selectors.nim @@ -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] |