ioselectors_poll: don't pollRemove() if not needed

pollAdd() is called only if events set isn't empty.
This commit is contained in:
Leorize
2018-09-22 11:24:29 +07:00
parent 0b3862df10
commit 08c6484298

View File

@@ -172,8 +172,9 @@ proc unregister*[T](s: Selector[T], fd: int|SocketHandle) =
doAssert(pkey.ident != InvalidIdent,
"Descriptor [" & $fdi & "] is not registered in the queue!")
pkey.ident = InvalidIdent
pkey.events = {}
s.pollRemove(fdi.cint)
if pkey.events != {}:
pkey.events = {}
s.pollRemove(fdi.cint)
proc unregister*[T](s: Selector[T], ev: SelectEvent) =
let fdi = int(ev.rfd)