From 08f721ece0b97550e407e1d6550a08185a4bdd8b Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 8 Oct 2019 18:20:40 +0200 Subject: [PATCH] quic: compute retransmission timeout correctly Previously, if the expiry timestamp was in the future by less than 1ms, the retransmission timer would not have been scheduled. (This also removes an unused line from the test that this problem made flaky.) PR-URL: https://github.com/nodejs/quic/pull/157 Reviewed-By: James M Snell --- src/node_quic_session.cc | 3 ++- test/parallel/test-quic-packetloss.js | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_quic_session.cc b/src/node_quic_session.cc index 41472d974f..fcf0271237 100644 --- a/src/node_quic_session.cc +++ b/src/node_quic_session.cc @@ -1291,7 +1291,8 @@ void QuicSession::RemoveStream(int64_t stream_id) { void QuicSession::ScheduleRetransmit() { uint64_t now = uv_hrtime(); uint64_t expiry = ngtcp2_conn_get_expiry(Connection()); - uint64_t interval = (expiry < now) ? 1 : ((expiry - now) / 1000000UL); + uint64_t interval = (expiry - now) / 1000000UL; + if (expiry < now || interval == 0) interval = 1; Debug(this, "Scheduling the retransmit timer for %" PRIu64, interval); UpdateRetransmitTimer(interval); } diff --git a/test/parallel/test-quic-packetloss.js b/test/parallel/test-quic-packetloss.js index 78bd4a3894..577b798f62 100644 --- a/test/parallel/test-quic-packetloss.js +++ b/test/parallel/test-quic-packetloss.js @@ -1,4 +1,3 @@ -// Flags: --expose-internals 'use strict'; // This test is not yet working correctly because data