1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-07-30 14:43:05 +03:00

Change more instances of folly::IOBuf to the typealiases

Summary: See title

Differential Revision: D76769545

fbshipit-source-id: 0e4ff49ba34377acec4382b7e9628626f9971984
This commit is contained in:
Aman Sharma
2025-06-16 20:11:29 -07:00
committed by Facebook GitHub Bot
parent 3f2bd6f618
commit 8eef42f39b
9 changed files with 26 additions and 29 deletions

View File

@ -333,8 +333,7 @@ continuousMemoryBuildScheduleEncrypt(
packetBuf->prepend(prevSize);
if (connection.transportSettings.isPriming && packetBuf) {
packetBuf->coalesce();
connection.bufAccessor->release(
folly::IOBuf::create(packetBuf->capacity()));
connection.bufAccessor->release(BufHelpers::create(packetBuf->capacity()));
connection.primingData_.emplace_back(std::move(packetBuf));
return DataPathResult::makeWriteResult(
true, std::move(result.value()), encodedSize, encodedBodySize);
@ -1470,7 +1469,7 @@ void writeCloseCommon(
bufUniquePtr->data(),
bufUniquePtr->length(),
headerCipher);
folly::IOBuf packetBuf(std::move(packet.header));
Buf packetBuf(std::move(packet.header));
packetBuf.appendToChain(std::move(bufUniquePtr));
auto packetSize = packetBuf.computeChainDataLength();
if (connection.qLogger) {

View File

@ -354,7 +354,7 @@ QuicReadCodec::tryParseShortHeaderPacket(
// don't clone the buffer, the buffer will not show up as shared and we can
// decrypt in-place.
size_t aadLen = packetNumberOffset + packetNum.second;
folly::IOBuf headerData = BufHelpers::wrapBufferAsValue(data->data(), aadLen);
Buf headerData = BufHelpers::wrapBufferAsValue(data->data(), aadLen);
data->trimStart(aadLen);
BufPtr decrypted;

View File

@ -52,7 +52,7 @@ const RegularQuicWritePacket& writeQuicPacket(
ConnectionId dstConnId,
quic::test::MockAsyncUDPSocket& sock,
QuicStreamState& stream,
const folly::IOBuf& data,
const Buf& data,
bool eof = false);
RegularQuicPacketBuilder::Packet createAckPacket(
@ -82,7 +82,7 @@ RegularQuicPacketBuilder::Packet createStreamPacket(
ConnectionId dstConnId,
PacketNum packetNum,
StreamId streamId,
folly::IOBuf& data,
Buf& data,
uint8_t cipherOverhead,
PacketNum largestAcked,
Optional<std::pair<LongHeader::Types, QuicVersion>> longHeaderOverride =
@ -169,7 +169,7 @@ std::unique_ptr<T> createNoOpAeadImpl(uint64_t cipherOverhead = 0) {
if (buf) {
return std::move(buf);
} else {
return folly::IOBuf::create(0);
return BufHelpers::create(0);
}
}));
// Fake that the handshake has already occurred and fix the keys.
@ -248,7 +248,7 @@ OutstandingPacketWrapper* findOutstandingPacket(
}
// Helper function to generate a buffer containing random data of given length
std::unique_ptr<folly::IOBuf> buildRandomInputData(size_t length);
BufPtr buildRandomInputData(size_t length);
void addAckStatesWithCurrentTimestamps(
AckState& ackState,
@ -336,9 +336,7 @@ void overridePacketWithToken(
PacketBuilderInterface::Packet& packet,
const StatelessResetToken& token);
void overridePacketWithToken(
folly::IOBuf& bodyBuf,
const StatelessResetToken& token);
void overridePacketWithToken(Buf& bodyBuf, const StatelessResetToken& token);
/*
* Returns if the current writable streams contains the given id.
@ -388,7 +386,7 @@ class TestPacketBatchWriter : public IOBufBatchWriter {
void reset() override;
bool append(
std::unique_ptr<folly::IOBuf>&& /*unused*/,
BufPtr&& /*unused*/,
size_t size,
const folly::SocketAddress& /*unused*/,
QuicAsyncUDPSocket* /*unused*/) override;
@ -407,7 +405,7 @@ class TestPacketBatchWriter : public IOBufBatchWriter {
size_t bufSize_{0};
};
std::unique_ptr<folly::IOBuf> getProtectionKey();
BufPtr getProtectionKey();
class FakeServerHandshake : public FizzServerHandshake {
public:
@ -439,12 +437,12 @@ class FakeServerHandshake : public FizzServerHandshake {
// Fall through and let the ServerStateMachine to process the event
writeDataToQuicStream(
*getCryptoStream(*conn_.cryptoState, EncryptionLevel::Initial),
folly::IOBuf::copyBuffer("SHLO"));
BufHelpers::copyBuffer("SHLO"));
if (chloWithCert) {
/* write 4000 bytes of data to the handshake crypto stream */
writeDataToQuicStream(
*getCryptoStream(*conn_.cryptoState, EncryptionLevel::Handshake),
folly::IOBuf::copyBuffer(std::string(4000, '.')));
BufHelpers::copyBuffer(std::string(4000, '.')));
}
if (allowZeroRttKeys_) {
@ -464,12 +462,12 @@ class FakeServerHandshake : public FizzServerHandshake {
}
folly::Expected<folly::Unit, QuicError> doHandshake(
std::unique_ptr<folly::IOBuf> data,
BufPtr data,
EncryptionLevel) override {
folly::IOBufEqualTo eq;
auto chlo = folly::IOBuf::copyBuffer("CHLO");
auto chloWithCert = folly::IOBuf::copyBuffer("CHLO_CERT");
auto clientFinished = folly::IOBuf::copyBuffer("FINISHED");
auto chlo = BufHelpers::copyBuffer("CHLO");
auto chloWithCert = BufHelpers::copyBuffer("CHLO_CERT");
auto clientFinished = BufHelpers::copyBuffer("FINISHED");
bool sendHandshakeBytes = false;
if (eq(data, chlo) || (sendHandshakeBytes = eq(data, chloWithCert))) {
@ -605,8 +603,8 @@ class FakeServerHandshake : public FizzServerHandshake {
CHECK(!oneRttReadHeaderCipherResult.hasError())
<< "Failed to create header cipher";
oneRttReadHeaderCipher_ = std::move(oneRttReadHeaderCipherResult.value());
readTrafficSecret_ = folly::IOBuf::copyBuffer(getRandSecret());
writeTrafficSecret_ = folly::IOBuf::copyBuffer(getRandSecret());
readTrafficSecret_ = BufHelpers::copyBuffer(getRandSecret());
writeTrafficSecret_ = BufHelpers::copyBuffer(getRandSecret());
}
std::unique_ptr<Aead> buildAead(ByteRange /*secret*/) override {
@ -614,7 +612,7 @@ class FakeServerHandshake : public FizzServerHandshake {
}
BufPtr getNextTrafficSecret(ByteRange /*secret*/) const override {
return folly::IOBuf::copyBuffer(getRandSecret());
return BufHelpers::copyBuffer(getRandSecret());
}
void setHandshakeKeys() {

View File

@ -168,7 +168,7 @@ folly::Expected<bool, QuicError> FizzClientHandshake::verifyRetryIntegrityTag(
auto expectedIntegrityTag = retryIntegrityTagGenerator.getRetryIntegrityTag(
retryPacket.header.getVersion(), pseudoRetryPacket.get());
folly::IOBuf integrityTagWrapper = BufHelpers::wrapBufferAsValue(
Buf integrityTagWrapper = BufHelpers::wrapBufferAsValue(
retryPacket.integrityTag.data(), retryPacket.integrityTag.size());
return BufEq()(*expectedIntegrityTag, integrityTagWrapper);
} catch (const std::exception& ex) {

View File

@ -29,7 +29,7 @@ inline quic::BufPtr encodeVarintParams(
}
// callers expect empty buf if no parameters supplied
return folly::IOBuf::create(0);
return quic::BufHelpers::create(0);
}
inline fizz::ExtensionType getQuicTransportParametersExtention(

View File

@ -140,7 +140,7 @@ class FileQLogger : public BaseQLogger {
std::unique_ptr<folly::AsyncFileWriter> writer_;
std::unique_ptr<folly::compression::StreamCodec> compressionCodec_;
std::unique_ptr<folly::IOBuf> compressionBuffer_;
BufPtr compressionBuffer_;
std::string path_;
std::string basePadding_ = " ";

View File

@ -606,7 +606,7 @@ void QuicServerWorker::eventRecvmsgCallback(MsgHdr* msgHdr, int bytesRead) {
bool QuicServerWorker::tryHandlingAsHealthCheck(
const folly::SocketAddress& client,
const folly::IOBuf& data) {
const Buf& data) {
// If we cannot parse the long header then it is not a QUIC invariant
// packet, so just drop it after checking whether it could be a health
// check.

View File

@ -462,7 +462,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback,
*/
bool tryHandlingAsHealthCheck(
const folly::SocketAddress& client,
const folly::IOBuf& data);
const Buf& data);
/**
* Return Infocallback ptr for various transport stats (such as packet

View File

@ -96,7 +96,7 @@ void writeDataToQuicStream(QuicCryptoStream& stream, BufPtr data) {
// a logic IOBuf chain, buf. The function will pack data into the available
// tail agressively, and allocate in terms of appendLen until the push is
// complete.
static void pushToTail(folly::IOBuf* dst, BufPtr src, size_t allocSize) {
static void pushToTail(Buf* dst, BufPtr src, size_t allocSize) {
size_t appended = 0;
auto len = src->length();
auto data = src->data();
@ -340,7 +340,7 @@ std::pair<BufPtr, bool> readDataInOrderFromReadBuffer(
uint64_t toRead =
std::min<uint64_t>(currSize, amount == 0 ? currSize : remaining);
std::unique_ptr<folly::IOBuf> splice;
BufPtr splice;
if (sinkData) {
curr->data.trimStart(toRead);
} else {