Skip to content

Commit

Permalink
quic: avoid sending 1-RTT frames in initial/handshake packets
Browse files Browse the repository at this point in the history
Restructure the send path a little to make it clear that
1-RTT frames go in 1-RTT packets.

For golang/go#58547

Change-Id: Id4c2c86c8ccd350bf490f38a8bb01ad9bc2639ee
Reviewed-on: https://go-review.googlesource.com/c/net/+/524035
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
neild committed Aug 29, 2023
1 parent 4332436 commit d1b0a97
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions internal/quic/conn_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,28 +224,13 @@ func (c *Conn) appendFrames(now time.Time, space numberSpace, pnum packetNumber,

// TODO: Add all the other frames we can send.

// HANDSHAKE_DONE
if c.handshakeConfirmed.shouldSendPTO(pto) {
if !c.w.appendHandshakeDoneFrame() {
return
}
c.handshakeConfirmed.setSent(pnum)
}

// CRYPTO
c.crypto[space].dataToSend(pto, func(off, size int64) int64 {
b, _ := c.w.appendCryptoFrame(off, int(size))
c.crypto[space].sendData(off, b)
return int64(len(b))
})

// NEW_CONNECTION_ID, RETIRE_CONNECTION_ID
if space == appDataSpace {
if !c.connIDState.appendFrames(&c.w, pnum, pto) {
return
}
}

// Test-only PING frames.
if space == c.testSendPingSpace && c.testSendPing.shouldSendPTO(pto) {
if !c.w.appendPingFrame() {
Expand All @@ -254,11 +239,26 @@ func (c *Conn) appendFrames(now time.Time, space numberSpace, pnum packetNumber,
c.testSendPing.setSent(pnum)
}

// All stream-related frames. This should come last in the packet,
// so large amounts of STREAM data don't crowd out other frames
// we may need to send.
if !c.appendStreamFrames(&c.w, pnum, pto) {
return
if space == appDataSpace {
// HANDSHAKE_DONE
if c.handshakeConfirmed.shouldSendPTO(pto) {
if !c.w.appendHandshakeDoneFrame() {
return
}
c.handshakeConfirmed.setSent(pnum)
}

// NEW_CONNECTION_ID, RETIRE_CONNECTION_ID
if !c.connIDState.appendFrames(&c.w, pnum, pto) {
return
}

// All stream-related frames. This should come last in the packet,
// so large amounts of STREAM data don't crowd out other frames
// we may need to send.
if !c.appendStreamFrames(&c.w, pnum, pto) {
return
}
}

// If this is a PTO probe and we haven't added an ack-eliciting frame yet,
Expand Down

0 comments on commit d1b0a97

Please sign in to comment.