Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
quic: fix idle timeout
Browse files Browse the repository at this point in the history
After ngtcp2 being updated, `ngtcp2_conn_get_idle_timeout` is renamed as
`ngtcp2_conn_get_idle_expiry` which returns `ngtcp2_tstamp` instead of
`ngtcp2_duration`.

Refs: https://github.com/ngtcp2/ngtcp2/blob/6f40668cdce7db7c043d3a80c07f379841d8c51e/lib/ngtcp2_conn.c#L8604
  • Loading branch information
oyyd committed Oct 10, 2019
1 parent 968a23c commit 24acab3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/node_quic_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,9 @@ void QuicSession::StreamReset(

void QuicSession::UpdateIdleTimer() {
CHECK_NOT_NULL(idle_);
uint64_t timeout = ngtcp2_conn_get_idle_expiry(Connection()) / 1000000UL;
uint64_t timeout = (ngtcp2_conn_get_idle_expiry(Connection()) - uv_hrtime()) / 1000000UL;
if (timeout < 0)
timeout = 0;
Debug(this, "Updating idle timeout to %" PRIu64, timeout);
idle_->Update(timeout);
}
Expand Down
10 changes: 6 additions & 4 deletions test/parallel/test-quic-idle-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ const idleTimeout = common.platformTimeout(1000);
idleTimeout,
});

server.on('session', common.mustCall(() => {
client.close();
server.close();
assert(Date.now() - start < idleTimeout + error);
server.on('session', common.mustCall((serverSession) => {
serverSession.on('close', common.mustCall(() => {
client.close();
server.close();
assert(Date.now() - start < idleTimeout + error);
}));
}));

server.on('ready', common.mustCall(() => {
Expand Down

0 comments on commit 24acab3

Please sign in to comment.