mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +00:00
Ensure we correctly handle deregister while still in the whenReady(...) method and using kqueue
This commit is contained in:
1 parent
f091d61576
commit
ca794b158c
1 file changed
+5
-2
@@ -295,8 +295,11 @@ public final class Selector {
|
||||
for i in 0..<ready {
|
||||
let ev = events[i]
|
||||
if ev.ident != Selector.EvUserIdent {
|
||||
let registration = registrations[Int(ev.ident)]!
|
||||
try fn((SelectorEvent(isReadable: Int32(ev.filter) == EVFILT_READ, isWritable: Int32(ev.filter) == EVFILT_WRITE, selectable: registration.selectable, attachment: registration.attachment)))
|
||||
guard let registration = registrations[Int(ev.ident)] else {
|
||||
// Just ignore as this means the user deregistered already in between. This can happen as kevent returns two different events, one for EVFILT_READ and one for EVFILT_WRITE.
|
||||
continue
|
||||
}
|
||||
try fn((SelectorEvent(isReadable: Int32(ev.filter) == EVFILT_READ, isWritable: Int32(ev.filter) == EVFILT_WRITE, selectable: registration.selectable, attachment: registration.attachment)))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user