fixes based on code review by @dom96
- For clarity: Changed the unregister if statement to use the in operator instead of the set intersection operator in ioselectors_epoll.nim and ioselectors_select.nim. - Fixed unregister of Event.User case on the Android branch.
This commit is contained in:
parent
233455a685
commit
bef1c4437d
2 changed files with 4 additions and 4 deletions
|
|
@ -197,7 +197,7 @@ proc unregister*[T](s: Selector[T], fd: int|SocketHandle) =
|
|||
"Descriptor $# is not registered in the selector!" % $fdi)
|
||||
if pkey.events != {}:
|
||||
when not defined(android):
|
||||
if pkey.events * {Event.Read, Event.Write, Event.User} != {}:
|
||||
if Event.Read in pkey.events or Event.Write in pkey.events or Event.User in pkey.events:
|
||||
var epv = EpollEvent()
|
||||
# TODO: Refactor all these EPOLL_CTL_DEL + dec(s.count) into a proc.
|
||||
if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
|
||||
|
|
@ -237,7 +237,7 @@ proc unregister*[T](s: Selector[T], fd: int|SocketHandle) =
|
|||
if posix.close(cint(fdi)) != 0:
|
||||
raiseIOSelectorsError(osLastError())
|
||||
else:
|
||||
if pkey.events * {Event.Read, Event.Write} != {}:
|
||||
if Event.Read in pkey.events or Event.Write in pkey.events or Event.User in pkey.events:
|
||||
var epv = EpollEvent()
|
||||
if epoll_ctl(s.epollFD, EPOLL_CTL_DEL, fdi.cint, addr epv) != 0:
|
||||
raiseIOSelectorsError(osLastError())
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ proc unregister*[T](s: Selector[T], fd: SocketHandle|int) =
|
|||
s.withSelectLock():
|
||||
let fd = fd.SocketHandle
|
||||
var pkey = s.getKey(fd)
|
||||
if pkey.events * {Event.Read, Event.User} != {}:
|
||||
if Event.Read in pkey.events or Event.User in pkey.events:
|
||||
IOFD_CLR(fd, addr s.rSet)
|
||||
dec(s.count)
|
||||
if Event.Write in pkey.events:
|
||||
|
|
@ -462,4 +462,4 @@ template withData*[T](s: Selector[T], fd: SocketHandle|int, value,
|
|||
|
||||
|
||||
proc getFd*[T](s: Selector[T]): int =
|
||||
return -1
|
||||
return -1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue