commit
08e7c16d67
2 changed files with 13 additions and 2 deletions
|
|
@ -878,6 +878,10 @@ else:
|
||||||
let data = PData(info.key.data)
|
let data = PData(info.key.data)
|
||||||
assert data.fd == info.key.fd.TAsyncFD
|
assert data.fd == info.key.fd.TAsyncFD
|
||||||
#echo("In poll ", data.fd.cint)
|
#echo("In poll ", data.fd.cint)
|
||||||
|
if EvError in info.events:
|
||||||
|
closeSocket(data.fd)
|
||||||
|
continue
|
||||||
|
|
||||||
if EvRead in info.events:
|
if EvRead in info.events:
|
||||||
# Callback may add items to ``data.readCBs`` which causes issues if
|
# Callback may add items to ``data.readCBs`` which causes issues if
|
||||||
# we are iterating over ``data.readCBs`` at the same time. We therefore
|
# we are iterating over ``data.readCBs`` at the same time. We therefore
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ proc `$`*(x: SocketHandle): string {.borrow.}
|
||||||
|
|
||||||
type
|
type
|
||||||
Event* = enum
|
Event* = enum
|
||||||
EvRead, EvWrite
|
EvRead, EvWrite, EvError
|
||||||
|
|
||||||
SelectorKey* = ref object
|
SelectorKey* = ref object
|
||||||
fd*: SocketHandle
|
fd*: SocketHandle
|
||||||
|
|
@ -146,12 +146,19 @@ elif defined(linux):
|
||||||
## on the ``fd``.
|
## on the ``fd``.
|
||||||
result = @[]
|
result = @[]
|
||||||
let evNum = epoll_wait(s.epollFD, addr s.events[0], 64.cint, timeout.cint)
|
let evNum = epoll_wait(s.epollFD, addr s.events[0], 64.cint, timeout.cint)
|
||||||
if evNum < 0: raiseOSError(osLastError())
|
if evNum < 0:
|
||||||
|
let err = osLastError()
|
||||||
|
if err.cint == EINTR:
|
||||||
|
return @[]
|
||||||
|
raiseOSError(osLastError())
|
||||||
if evNum == 0: return @[]
|
if evNum == 0: return @[]
|
||||||
for i in 0 .. <evNum:
|
for i in 0 .. <evNum:
|
||||||
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 EPOLLHUP) != 0: evSet = evSet + {EvError}
|
||||||
|
if (s.events[i].events and EPOLLRDHUP) != 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