Test + fix for epoll and kqueue selector modules to properly unregister
event handles that have the key type "User"
This commit is contained in:
parent
5be8e0b088
commit
adc1419499
3 changed files with 26 additions and 3 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} != {}:
|
||||
if pkey.events * {Event.Read, Event.Write, Event.User} != {}:
|
||||
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:
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ proc unregister*[T](s: Selector[T], fd: int|SocketHandle) =
|
|||
"Descriptor [" & $fdi & "] is not registered in the queue!")
|
||||
|
||||
if pkey.events != {}:
|
||||
if pkey.events * {Event.Read, Event.Write} != {}:
|
||||
if pkey.events * {Event.Read, Event.Write, Event.User} != {}:
|
||||
if Event.Read in pkey.events:
|
||||
modifyKQueue(s, uint(fdi), EVFILT_READ, EV_DELETE, 0, 0, nil)
|
||||
dec(s.count)
|
||||
|
|
@ -632,4 +632,4 @@ template withData*[T](s: Selector[T], fd: SocketHandle|int, value, body1,
|
|||
|
||||
|
||||
proc getFd*[T](s: Selector[T]): int =
|
||||
return s.kqFD.int
|
||||
return s.kqFD.int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue