1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-06 22:22:38 +03:00

Move Quic packet header encoding out of builder constructor

Summary:
Currently the packet builder contructor will encode the packet
builder. This is fine when the builder creates its own output buffer. If later
on we decides not to use this builder, or it fails to build packet, the buffer
will be thrown away. But once the builder uses a buffer provided by caller, and
will be reused, we can no longer just throw it away if we decide not to use
this builder. So we have to delay the header encoding until we know we will use
the builder.

This is still not enough to solve the case where we want to use this builder,
it builds, then it fails . For that, we will need to retreat the tail position
of the IOBuf.

Reviewed By: mjoras

Differential Revision: D21000658

fbshipit-source-id: 4d758b3e260463b17c870618ba68bd4b898a7d4c
This commit is contained in:
Yang Chi
2020-04-28 22:11:49 -07:00
committed by Facebook GitHub Bot
parent f36747c31b
commit 2a1529068d
17 changed files with 179 additions and 143 deletions

View File

@@ -121,6 +121,7 @@ auto buildEmptyPacket(
conn.udpSendPacketLen,
std::move(*header),
getAckState(conn, pnSpace).largestAckedByPeer);
builder.encodePacketHeader();
DCHECK(builder.canBuildPacket());
return std::move(builder).buildPacket();
}