Add comments to latest fixes.

One more fix.
Some artifacts removed.
This commit is contained in:
cheatfate 2016-11-30 04:55:17 +02:00
commit d40b783110
2 changed files with 18 additions and 26 deletions

View file

@ -893,9 +893,11 @@ when defined(windows) or defined(nimdoc):
deallocShared(cast[pointer](pcd)) deallocShared(cast[pointer](pcd))
raiseOSError(osLastError()) raiseOSError(osLastError())
else: else:
# we ref pcd.ovl one more time, because it will be unrefed in # we incref `pcd.ovl` and `protect` callback one more time,
# poll() # because it will be unrefed and disposed in `poll()` after
# callback finishes.
GC_ref(pcd.ovl) GC_ref(pcd.ovl)
pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb))
) )
# We need to protect our callback environment value, so GC will not free it # We need to protect our callback environment value, so GC will not free it
# accidentally. # accidentally.
@ -956,17 +958,8 @@ when defined(windows) or defined(nimdoc):
initAll() initAll()
else: else:
import selectors import selectors
when defined(windows): from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
import winlean MSG_NOSIGNAL
const
EINTR = WSAEINPROGRESS
EINPROGRESS = WSAEINPROGRESS
EWOULDBLOCK = WSAEWOULDBLOCK
EAGAIN = EINPROGRESS
MSG_NOSIGNAL = 0
else:
from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
MSG_NOSIGNAL
type type
AsyncFD* = distinct cint AsyncFD* = distinct cint

View file

@ -878,9 +878,11 @@ when defined(windows) or defined(nimdoc):
deallocShared(cast[pointer](pcd)) deallocShared(cast[pointer](pcd))
raiseOSError(osLastError()) raiseOSError(osLastError())
else: else:
# we ref pcd.ovl one more time, because it will be unrefed in # we incref `pcd.ovl` and `protect` callback one more time,
# poll() # because it will be unrefed and disposed in `poll()` after
# callback finishes.
GC_ref(pcd.ovl) GC_ref(pcd.ovl)
pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb))
) )
# We need to protect our callback environment value, so GC will not free it # We need to protect our callback environment value, so GC will not free it
# accidentally. # accidentally.
@ -988,6 +990,9 @@ when defined(windows) or defined(nimdoc):
deallocShared(cast[pointer](pcd)) deallocShared(cast[pointer](pcd))
p.handles.excl(fd) p.handles.excl(fd)
else: else:
# if callback returned `false`, then it wants to be called again, so
# we need to ref and protect `pcd.ovl` again, because it will be
# unrefed and disposed in `poll()`.
GC_ref(pcd.ovl) GC_ref(pcd.ovl)
pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb)) pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb))
@ -1073,6 +1078,9 @@ when defined(windows) or defined(nimdoc):
if ev.hWaiter != 0: unregister(ev) if ev.hWaiter != 0: unregister(ev)
deallocShared(cast[pointer](pcd)) deallocShared(cast[pointer](pcd))
else: else:
# if callback returned `false`, then it wants to be called again, so
# we need to ref and protect `pcd.ovl` again, because it will be
# unrefed and disposed in `poll()`.
GC_ref(pcd.ovl) GC_ref(pcd.ovl)
pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb)) pcd.ovl.data.cell = system.protect(rawEnv(pcd.ovl.data.cb))
@ -1082,17 +1090,8 @@ when defined(windows) or defined(nimdoc):
initAll() initAll()
else: else:
import ioselectors import ioselectors
when defined(windows): from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
import winlean MSG_NOSIGNAL
const
EINTR = WSAEINPROGRESS
EINPROGRESS = WSAEINPROGRESS
EWOULDBLOCK = WSAEWOULDBLOCK
EAGAIN = EINPROGRESS
MSG_NOSIGNAL = 0
else:
from posix import EINTR, EAGAIN, EINPROGRESS, EWOULDBLOCK, MSG_PEEK,
MSG_NOSIGNAL
const supportedPlatform = defined(linux) or defined(freebsd) or const supportedPlatform = defined(linux) or defined(freebsd) or
defined(netbsd) or defined(openbsd) or defined(netbsd) or defined(openbsd) or