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

quic: fix idle timeout #166

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/node_quic_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,10 @@ void QuicSession::StreamReset(

void QuicSession::UpdateIdleTimer() {
CHECK_NOT_NULL(idle_);
uint64_t timeout = ngtcp2_conn_get_idle_expiry(Connection()) / 1000000UL;
uint64_t now = uv_hrtime();
uint64_t expiry = ngtcp2_conn_get_idle_expiry(Connection());
uint64_t timeout = (expiry - now) / 1000000UL;
if (expiry < now || timeout == 0) timeout = 1;
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