fix getRelativeTimeout (assuming microseconds was wrong)
This commit is contained in:
parent
e936bc49d9
commit
6e7ab9369d
|
@ -43,8 +43,8 @@ proc PEM_read_PrivateKey(fp: File, x: ptr EVP_PKEY,
|
||||||
proc EVP_PKEY_free(key: EVP_PKEY) {.importc, dynlib: DLLSSLName, cdecl.}
|
proc EVP_PKEY_free(key: EVP_PKEY) {.importc, dynlib: DLLSSLName, cdecl.}
|
||||||
|
|
||||||
proc getRelativeTimeout(ctx: QuicP2PContext): int32 =
|
proc getRelativeTimeout(ctx: QuicP2PContext): int32 =
|
||||||
## Obtain the absolute int64 timeout (in microseconds) from quicly and convert
|
## Obtain the absolute int64 timeout from quicly and convert it to the
|
||||||
## it to the relative int32 timeout (in milliseconds) expected by poll.
|
## relative int32 timeout expected by poll.
|
||||||
result = 0
|
result = 0
|
||||||
var nextTimeout = int64.high
|
var nextTimeout = int64.high
|
||||||
var now = ctx.quiclyCtx.now.cb(ctx.quiclyCtx.now)
|
var now = ctx.quiclyCtx.now.cb(ctx.quiclyCtx.now)
|
||||||
|
@ -53,9 +53,7 @@ proc getRelativeTimeout(ctx: QuicP2PContext): int32 =
|
||||||
if connTimeout < nextTimeout:
|
if connTimeout < nextTimeout:
|
||||||
nextTimeout = connTimeout
|
nextTimeout = connTimeout
|
||||||
if now < nextTimeout:
|
if now < nextTimeout:
|
||||||
# calculate time until nextTimeout and convert from microseconds to
|
let delta = nextTimeout - now
|
||||||
# milliseconds
|
|
||||||
let delta = (nextTimeout - now) div 1_000
|
|
||||||
result = min(delta, int32.high).int32
|
result = min(delta, int32.high).int32
|
||||||
|
|
||||||
proc onStopSending(stream: ptr quicly_stream_t, err: cint) {.cdecl.} =
|
proc onStopSending(stream: ptr quicly_stream_t, err: cint) {.cdecl.} =
|
||||||
|
|
Loading…
Reference in New Issue