Fixes compilation of asyncio2 on Windows.
Added a close(PDispatcher, TSocketHandle) implementation which unregisters the handle.
This commit is contained in:
parent
1a75b17cd0
commit
afb7dbf81a
1 changed files with 5 additions and 1 deletions
|
|
@ -132,7 +132,6 @@ when defined(windows) or defined(nimdoc):
|
||||||
cast[TCompletionKey](sock), 1) == 0:
|
cast[TCompletionKey](sock), 1) == 0:
|
||||||
OSError(OSLastError())
|
OSError(OSLastError())
|
||||||
p.handles.incl(sock)
|
p.handles.incl(sock)
|
||||||
# TODO: fd closure detection, we need to remove the fd from handles set
|
|
||||||
|
|
||||||
proc verifyPresence(p: PDispatcher, sock: TSocketHandle) =
|
proc verifyPresence(p: PDispatcher, sock: TSocketHandle) =
|
||||||
## Ensures that socket has been registered with the dispatcher.
|
## Ensures that socket has been registered with the dispatcher.
|
||||||
|
|
@ -475,6 +474,11 @@ when defined(windows) or defined(nimdoc):
|
||||||
result = socket(domain, typ, protocol)
|
result = socket(domain, typ, protocol)
|
||||||
disp.register(result)
|
disp.register(result)
|
||||||
|
|
||||||
|
proc close*(disp: PDispatcher, socket: TSocketHandle) =
|
||||||
|
## Closes a socket and ensures that it is unregistered.
|
||||||
|
socket.close()
|
||||||
|
disp.handles.excl(socket)
|
||||||
|
|
||||||
initAll()
|
initAll()
|
||||||
else:
|
else:
|
||||||
import selectors
|
import selectors
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue