Skip to content

Commit af3bbab

Browse files
quic: fix stall datagrams, if no pending streams
If you are only sending datagrams and so streams, your datagrams could stall. There were two reasons: i. A SendPendingDataScope in SendDatagrams was missing. ii. SendPendingData did not attempt to send datagrams, if there were no stream data. Signed-off-by: Marten Richter <marten.richter@freenet.de> PR-URL: #64303 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d7aca7e commit af3bbab

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/quic/application.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ void Session::Application::SendPendingData() {
540540
// We call Application::ResumeStream directly (not Session::ResumeStream)
541541
// to avoid creating a SendPendingDataScope — we're already inside
542542
// SendPendingData and re-entering would just hit nwrite=0 again.
543-
if (nwrite == 0) {
543+
if (nwrite == 0 &&
544+
(stream_data.id >= 0 || !session_->HasPendingDatagrams())) {
544545
Debug(session_, "Congestion or not our turn to send");
545546
if (stream_data.id >= 0 && (stream_data.count > 0 || stream_data.fin)) {
546547
ResumeStream(stream_data.id);

src/quic/session.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,7 @@ datagram_id Session::SendDatagram(Store&& data) {
25932593
return did;
25942594
}
25952595
}
2596+
Session::SendPendingDataScope send_scope(this);
25962597

25972598
// Queue the datagram. It will be serialized into packets by
25982599
// SendPendingData alongside stream data.

test/parallel/test-quic-session-preferred-address-ipv6.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ const clientSession = await connect(serverEndpoint.address, {
100100
family: 'ipv6',
101101
},
102102
},
103+
maxDatagramSendAttempts: 100, // While the connection is restablished,
104+
// all the acknowledgement packets of ngtcp2 are counted as send attempts
105+
// so either this or a delay, or a change in ngtcp2 interfaces
103106
});
104107
await clientSession.opened;
105108

test/parallel/test-quic-session-preferred-address.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ const clientSession = await connect(serverEndpoint.address, {
7878
strictEqual(oldRemote, null);
7979
strictEqual(preferred, true);
8080
}),
81+
maxDatagramSendAttempts: 100, // While the connection is restablished,
82+
// all the acknowledgement packets of ngtcp2 are counted as send attempts
83+
// so either this or a delay, or a change in ngtcp2 interfaces
8184
});
8285
await clientSession.opened;
8386

0 commit comments

Comments
 (0)