1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-25 15:43:13 +03:00

Write a buffer's meta data into QUIC

Summary:
Instead of writing real data into the transport, we want to support a
use case where only its metadata is written to the transport. Sending of the
real data is delegated to another entity in such setup.

Reviewed By: mjoras

Differential Revision: D26131772

fbshipit-source-id: 4fcfa3a1626203f63c61898e6de089a3079d043d
This commit is contained in:
Yang Chi
2021-03-03 23:48:14 -08:00
committed by Facebook GitHub Bot
parent 968b39f4a9
commit adc1e15eff
8 changed files with 229 additions and 0 deletions

View File

@@ -29,6 +29,9 @@ void prependToBuf(quic::Buf& buf, quic::Buf toAppend) {
namespace quic {
void writeDataToQuicStream(QuicStreamState& stream, Buf data, bool eof) {
// Once data is written to writeBufMeta, no more data can be written to
// writeBuffer.
CHECK_EQ(0, stream.writeBufMeta.offset);
uint64_t len = 0;
if (data) {
len = data->computeChainDataLength();
@@ -48,6 +51,28 @@ void writeDataToQuicStream(QuicStreamState& stream, Buf data, bool eof) {
stream.conn.streamManager->updateWritableStreams(stream);
}
void writeBufMetaToQuicStream(
QuicStreamState& stream,
const BufferMeta& data,
bool eof) {
if (data.length > 0) {
maybeWriteBlockAfterAPIWrite(stream);
}
if (stream.writeBufMeta.offset == 0) {
CHECK(!stream.finalWriteOffset.has_value());
stream.writeBufMeta.offset =
stream.currentWriteOffset + stream.writeBuffer.chainLength();
}
stream.writeBufMeta.length += data.length;
if (eof) {
stream.finalWriteOffset =
stream.writeBufMeta.offset + stream.writeBufMeta.length;
stream.writeBufMeta.eof = true;
}
updateFlowControlOnWriteToStream(stream, data.length);
stream.conn.streamManager->updateWritableStreams(stream);
}
void writeDataToQuicStream(QuicCryptoStream& stream, Buf data) {
stream.writeBuffer.append(std::move(data));
}