BUG IN CLIENT OF LIBDISPATCH: Unexpected EV_VANISHED (do not destroy random mach ports or file descriptors)
Which, ok, clear: somehow a file descriptor is being closed before DispatchIO.close()
is called, yes?
Only I can't figure out where it is being closed. I am currently using change_fdguard_np()
to prevent closes anywhere else, and every single place where I call Darwin.close() is preceded by another call to
change_fdguard_npand then
DispatchIO.close()`. eg
self.unguardSocket()
self.readDispatcher?.close()
Darwin.close(self.socket)
self.socket = -1
self.completion(self)
Create a socketpair Create a DispatchIO using socket[0] Create a FileHandle using socket[1] Do work When done, DispatchIO.close() and FileHandle.close() Also close the sockets using Darwin.close().
Did you immediately issue the "Darwin.close"? If so, then I believe that's a programmatic error. This isn't very clear in the swift documentation, but "close" doesn't mean that the system is done with your fd. That doesn't occur until your cleanup handler is called:
"If the existing channel is associated with a file descriptor, the system maintains control over the file descriptor until the new channel is also closed, an error occurs on the file descriptor, or all references to channels tied to that file descriptor are released. When the file descriptor is released, the cleanup_handler block is enqueued on the specified queue and the system relinquishes control over the file descriptor."
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware