Fixes crashes when asyncdispatch.adjustTimeout returns a negative value. (#11231)

This commit is contained in:
Dominik Picheta 2019-05-15 17:15:10 +01:00 • committed by Andreas Rumpf
commit d0b8724aa2
6 changed files with 22 additions and 7 deletions

View file

@ -44,8 +44,8 @@ elif defined(netbsd) or defined(openbsd):
when hasThreadSupport:
type
SelectorImpl[T] = object
kqFD : cint
maxFD : int
kqFD: cint
maxFD: int
changes: ptr SharedArray[KEvent]
fds: ptr SharedArray[SelectorKey[T]]
count: int
@ -57,8 +57,8 @@ when hasThreadSupport:
else:
type
SelectorImpl[T] = object
kqFD : cint
maxFD : int
kqFD: cint
maxFD: int
changes: seq[KEvent]
fds: seq[SelectorKey[T]]
count: int
@ -447,6 +447,8 @@ proc selectInto*[T](s: Selector[T], timeout: int,
ptv = addr tv
maxres = MAX_KQUEUE_EVENTS
verifySelectParams(timeout)
if timeout != -1:
if timeout >= 1000:
tv.tv_sec = posix.Time(timeout div 1_000)