From 6e7ab9369d5e60e82e1fd8385e907decf5c99da7 Mon Sep 17 00:00:00 2001 From: Christian Ulrich Date: Sun, 8 Nov 2020 01:22:53 +0100 Subject: [PATCH] fix getRelativeTimeout (assuming microseconds was wrong) --- quicp2p.nim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/quicp2p.nim b/quicp2p.nim index 11c66e1..ebac3f9 100644 --- a/quicp2p.nim +++ b/quicp2p.nim @@ -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 getRelativeTimeout(ctx: QuicP2PContext): int32 = - ## Obtain the absolute int64 timeout (in microseconds) from quicly and convert - ## it to the relative int32 timeout (in milliseconds) expected by poll. + ## Obtain the absolute int64 timeout from quicly and convert it to the + ## relative int32 timeout expected by poll. result = 0 var nextTimeout = int64.high var now = ctx.quiclyCtx.now.cb(ctx.quiclyCtx.now) @@ -53,9 +53,7 @@ proc getRelativeTimeout(ctx: QuicP2PContext): int32 = if connTimeout < nextTimeout: nextTimeout = connTimeout if now < nextTimeout: - # calculate time until nextTimeout and convert from microseconds to - # milliseconds - let delta = (nextTimeout - now) div 1_000 + let delta = nextTimeout - now result = min(delta, int32.high).int32 proc onStopSending(stream: ptr quicly_stream_t, err: cint) {.cdecl.} =