Skip to content

[+] Fix: Support more specific idletimeout calculation#535

Open
Sy0307 wants to merge 1 commit intomainfrom
dev/bug_fix_idletimeout
Open

[+] Fix: Support more specific idletimeout calculation#535
Sy0307 wants to merge 1 commit intomainfrom
dev/bug_fix_idletimeout

Conversation

@Sy0307
Copy link
Collaborator

@Sy0307 Sy0307 commented Jan 29, 2026

As RFC 9000 wrote here :

Each endpoint advertises a max_idle_timeout, but the effective value at an endpoint is computed as the minimum of the two advertised values (or the sole advertised value, if only one endpoint advertises a non-zero value). By announcing a max_idle_timeout, an endpoint commits to initiating an immediate close (Section 10.2) if it abandons the connection prior to the effective value.

....

The closing and draining connection states exist to ensure that connections close cleanly and that delayed or reordered packets are properly discarded. These states SHOULD persist for at least three times the current PTO interval as defined in [QUIC-RECOVERY].

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts QUIC connection idle-timeout handling to better align with RFC 9000 semantics, and tightens stateless reset handling.

Changes:

  • Reset the connection idle timer on sending ACK-eliciting packets (with new conn_last_ack_eliciting_send_time tracking).
  • Refine effective idle-timeout computation to consider both local and remote advertised values.
  • Fix stateless reset minimum-length parsing and update stateless reset token association to the server’s CID.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/transport/xqc_send_ctl.c Updates connection idle timer when sending ACK-eliciting packets and tracks last ACK-eliciting send time.
src/transport/xqc_packet_parser.c Corrects stateless reset minimum-length check (< vs <=).
src/transport/xqc_conn.h Adds conn_last_ack_eliciting_send_time to the connection struct.
src/transport/xqc_conn.c Initializes conn_paths_list earlier, changes stateless reset token generation CID, and updates idle-timeout calculation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +6410 to +6415
xqc_usec_t pto = xqc_conn_get_max_pto(conn);
if (pto > 0) {
xqc_msec_t min_idle_timeout = (xqc_msec_t)((3 * pto + 999) / 1000);
idle_timeout = xqc_max(idle_timeout, min_idle_timeout);
}

Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xqc_conn_get_idle_timeout() computes the effective idle timeout as min(local, remote) but then increases it to at least 3PTO. This can make the actual idle timeout exceed the negotiated/advertised max_idle_timeout, which is contrary to RFC 9000’s definition of the effective value (minimum of the two advertised values). If you need a minimum duration of 3PTO, that should be applied to the closing/draining timers (or a separate timeout) rather than the negotiated idle timeout.

Suggested change
xqc_usec_t pto = xqc_conn_get_max_pto(conn);
if (pto > 0) {
xqc_msec_t min_idle_timeout = (xqc_msec_t)((3 * pto + 999) / 1000);
idle_timeout = xqc_max(idle_timeout, min_idle_timeout);
}

Copilot uses AI. Check for mistakes.
Comment on lines +6404 to +6408
xqc_msec_t local = conn->local_settings.max_idle_timeout == 0
? XQC_CONN_DEFAULT_IDLE_TIMEOUT : conn->local_settings.max_idle_timeout;

xqc_msec_t remote_idle_timeout = (xqc_msec_t)conn->remote_settings.max_idle_timeout;
xqc_msec_t idle_timeout = (remote_idle_timeout > 0) ? xqc_min(local, remote_idle_timeout) : local;
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in xqc_conn_get_idle_timeout() alter timeout semantics (using both local and remote advertised values). There are no unit tests covering the effective idle-timeout calculation; please add targeted cases in tests/unittest/xqc_conn_test.c to prevent regressions.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants