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

QuicAsyncUDPSocketWrapper

Reviewed By: jbeshay

Differential Revision: D46379200

fbshipit-source-id: f6a7c1cf68108872e05e6fd8adb7f00aae22b2ed
This commit is contained in:
Konstantin Tsoy
2023-07-11 15:21:15 -07:00
committed by Facebook GitHub Bot
parent cb0acbd84a
commit 4a0dd1e2a4
59 changed files with 273 additions and 251 deletions

View File

@@ -14,7 +14,7 @@ namespace quic {
IOBufQuicBatch::IOBufQuicBatch(
BatchWriterPtr&& batchWriter,
bool threadLocal,
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& peerAddress,
QuicTransportStatsCallback* statsCallback,
QuicClientConnectionState::HappyEyeballsState* happyEyeballsState)

View File

@@ -28,7 +28,7 @@ class IOBufQuicBatch {
IOBufQuicBatch(
BatchWriterPtr&& batchWriter,
bool threadLocal,
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& peerAddress,
QuicTransportStatsCallback* statsCallback,
QuicClientConnectionState::HappyEyeballsState* happyEyeballsState);
@@ -62,7 +62,7 @@ class IOBufQuicBatch {
BatchWriterPtr batchWriter_;
bool threadLocal_;
folly::AsyncUDPSocket& sock_;
QuicAsyncUDPSocketType& sock_;
const folly::SocketAddress& peerAddress_;
QuicTransportStatsCallback* statsCallback_{nullptr};
QuicClientConnectionState::HappyEyeballsState* happyEyeballsState_;

View File

@@ -100,11 +100,11 @@ class ThreadLocalBatchWriterCache : public folly::AsyncTimeout {
if (evb && evb->getBackingEventBase() && !socket_) {
auto fd = writer->getAndResetFd();
if (fd >= 0) {
socket_ = std::make_unique<folly::AsyncUDPSocket>(
socket_ = std::make_unique<quic::QuicAsyncUDPSocketType>(
evb->getBackingEventBase());
socket_->setFD(
folly::NetworkSocket(fd),
folly::AsyncUDPSocket::FDOwnership::OWNS);
quic::QuicAsyncUDPSocketType::FDOwnership::OWNS);
}
attachTimeoutManager(evb->getBackingEventBase());
}
@@ -131,7 +131,7 @@ class ThreadLocalBatchWriterCache : public folly::AsyncTimeout {
quic::QuicBatchingMode::BATCHING_MODE_NONE};
// this is just an std::unique_ptr
std::unique_ptr<quic::BatchWriter> batchWriter_;
std::unique_ptr<folly::AsyncUDPSocket> socket_;
std::unique_ptr<quic::QuicAsyncUDPSocketType> socket_;
};
#endif
} // namespace
@@ -151,7 +151,7 @@ bool SinglePacketBatchWriter::append(
std::unique_ptr<folly::IOBuf>&& buf,
size_t /*unused*/,
const folly::SocketAddress& /*unused*/,
folly::AsyncUDPSocket* /*unused*/) {
QuicAsyncUDPSocketType* /*unused*/) {
buf_ = std::move(buf);
// needs to be flushed
@@ -159,7 +159,7 @@ bool SinglePacketBatchWriter::append(
}
ssize_t SinglePacketBatchWriter::write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) {
return sock.write(address, buf_);
}
@@ -184,7 +184,7 @@ bool GSOPacketBatchWriter::append(
std::unique_ptr<folly::IOBuf>&& buf,
size_t size,
const folly::SocketAddress& /*unused*/,
folly::AsyncUDPSocket* /*unused*/) {
QuicAsyncUDPSocketType* /*unused*/) {
// first buffer
if (!buf_) {
DCHECK_EQ(currBufs_, 0);
@@ -216,7 +216,7 @@ bool GSOPacketBatchWriter::append(
}
ssize_t GSOPacketBatchWriter::write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) {
return (currBufs_ > 1)
? sock.writeGSO(address, buf_, static_cast<int>(prevSize_))
@@ -247,7 +247,7 @@ bool GSOInplacePacketBatchWriter::append(
std::unique_ptr<folly::IOBuf>&& /*buf*/,
size_t size,
const folly::SocketAddress& /* addr */,
folly::AsyncUDPSocket* /* sock */) {
QuicAsyncUDPSocketType* /* sock */) {
CHECK(!needsFlush(size));
ScopedBufAccessor scopedBufAccessor(conn_.bufAccessor);
auto& buf = scopedBufAccessor.buf();
@@ -275,7 +275,7 @@ bool GSOInplacePacketBatchWriter::append(
* conn_.bufAccessor.
*/
ssize_t GSOInplacePacketBatchWriter::write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) {
ScopedBufAccessor scopedBufAccessor(conn_.bufAccessor);
CHECK(lastPacketEnd_);
@@ -368,7 +368,7 @@ bool SendmmsgPacketBatchWriter::append(
std::unique_ptr<folly::IOBuf>&& buf,
size_t size,
const folly::SocketAddress& /*unused*/,
folly::AsyncUDPSocket* /*unused*/) {
QuicAsyncUDPSocketType* /*unused*/) {
CHECK_LT(bufs_.size(), maxBufs_);
bufs_.emplace_back(std::move(buf));
currSize_ += size;
@@ -383,7 +383,7 @@ bool SendmmsgPacketBatchWriter::append(
}
ssize_t SendmmsgPacketBatchWriter::write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) {
CHECK_GT(bufs_.size(), 0);
if (bufs_.size() == 1) {
@@ -435,7 +435,7 @@ bool SendmmsgGSOPacketBatchWriter::append(
std::unique_ptr<folly::IOBuf>&& buf,
size_t size,
const folly::SocketAddress& addr,
folly::AsyncUDPSocket* sock) {
QuicAsyncUDPSocketType* sock) {
setSock(sock);
currSize_ += size;
@@ -478,7 +478,7 @@ bool SendmmsgGSOPacketBatchWriter::append(
}
ssize_t SendmmsgGSOPacketBatchWriter::write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& /*unused*/) {
CHECK_GT(bufs_.size(), 0);
if (bufs_.size() == 1) {

View File

@@ -9,9 +9,9 @@
#include <folly/Portability.h>
#include <folly/io/IOBuf.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <quic/QuicConstants.h>
#include <quic/common/Events.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/state/StateData.h>
namespace quic {
@@ -25,7 +25,7 @@ class BatchWriter {
}
#ifndef MVFST_USE_LIBEV
void setSock(folly::AsyncUDPSocket* sock) {
void setSock(QuicAsyncUDPSocketType* sock) {
if (sock && !evb_.getBackingEventBase()) {
fd_ = ::dup(sock->getNetworkSocket().toFd());
evb_.setBackingEventBase(sock->getEventBase());
@@ -63,9 +63,9 @@ class BatchWriter {
std::unique_ptr<folly::IOBuf>&& buf,
size_t bufSize,
const folly::SocketAddress& addr,
folly::AsyncUDPSocket* sock) = 0;
QuicAsyncUDPSocketType* sock) = 0;
virtual ssize_t write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) = 0;
protected:
@@ -100,9 +100,9 @@ class SinglePacketBatchWriter : public IOBufBatchWriter {
std::unique_ptr<folly::IOBuf>&& buf,
size_t /*unused*/,
const folly::SocketAddress& /*unused*/,
folly::AsyncUDPSocket* /*unused*/) override;
QuicAsyncUDPSocketType* /*unused*/) override;
ssize_t write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) override;
};
@@ -117,9 +117,9 @@ class GSOPacketBatchWriter : public IOBufBatchWriter {
std::unique_ptr<folly::IOBuf>&& buf,
size_t size,
const folly::SocketAddress& /*unused*/,
folly::AsyncUDPSocket* /*unused*/) override;
QuicAsyncUDPSocketType* /*unused*/) override;
ssize_t write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) override;
private:
@@ -144,9 +144,9 @@ class GSOInplacePacketBatchWriter : public BatchWriter {
std::unique_ptr<folly::IOBuf>&& buf,
size_t size,
const folly::SocketAddress& addr,
folly::AsyncUDPSocket* sock) override;
QuicAsyncUDPSocketType* sock) override;
ssize_t write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) override;
bool empty() const override;
size_t size() const override;
@@ -182,9 +182,9 @@ class SendmmsgPacketBatchWriter : public BatchWriter {
std::unique_ptr<folly::IOBuf>&& buf,
size_t size,
const folly::SocketAddress& /*unused*/,
folly::AsyncUDPSocket* /*unused*/) override;
QuicAsyncUDPSocketType* /*unused*/) override;
ssize_t write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) override;
private:
@@ -211,9 +211,9 @@ class SendmmsgGSOPacketBatchWriter : public BatchWriter {
std::unique_ptr<folly::IOBuf>&& buf,
size_t size,
const folly::SocketAddress& address,
folly::AsyncUDPSocket* sock) override;
QuicAsyncUDPSocketType* sock) override;
ssize_t write(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& address) override;
private:

View File

@@ -14,6 +14,7 @@
#include <quic/QuicConstants.h>
#include <quic/codec/Types.h>
#include <quic/common/Events.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/common/SmallCollections.h>
#include <quic/congestion_control/Bandwidth.h>
#include <quic/observer/SocketObserverContainer.h>
@@ -473,7 +474,7 @@ class QuicSocket {
* @param socket The new socket that should be used by the transport.
* If this is null then do not replace the underlying socket.
*/
virtual void onNetworkSwitch(std::unique_ptr<folly::AsyncUDPSocket>) {}
virtual void onNetworkSwitch(std::unique_ptr<QuicAsyncUDPSocketType>) {}
/**
* Get the flow control settings for the given stream (or connection flow

View File

@@ -27,7 +27,7 @@ namespace quic {
QuicTransportBase::QuicTransportBase(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
bool useConnectionEndWithErrorCallback)
: socket_(std::move(socket)),
useConnectionEndWithErrorCallback_(useConnectionEndWithErrorCallback),

View File

@@ -12,6 +12,7 @@
#include <quic/api/QuicSocket.h>
#include <quic/common/Events.h>
#include <quic/common/FunctionLooper.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/common/Timers.h>
#include <quic/congestion_control/CongestionControllerFactory.h>
#include <quic/congestion_control/Copa.h>
@@ -20,7 +21,6 @@
#include <quic/state/StateData.h>
#include <folly/ExceptionWrapper.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <folly/io/async/HHWheelTimer.h>
namespace quic {
@@ -39,7 +39,7 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
public:
QuicTransportBase(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
bool useConnectionEndWithErrorCallback = false);
~QuicTransportBase() override;
@@ -841,7 +841,7 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
folly::Optional<folly::SocketOptionMap> getAdditionalCmsgsForAsyncUDPSocket();
std::atomic<QuicEventBase*> qEvbPtr_;
std::unique_ptr<folly::AsyncUDPSocket> socket_;
std::unique_ptr<QuicAsyncUDPSocketType> socket_;
ConnectionSetupCallback* connSetupCallback_{nullptr};
ConnectionCallback* connCallback_{nullptr};
// A flag telling transport if the new onConnectionEnd(error) cb must be used.

View File

@@ -115,7 +115,7 @@ uint64_t maybeUnvalidatedClientWritableBytes(
}
WriteQuicDataResult writeQuicDataToSocketImpl(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -1007,7 +1007,7 @@ HeaderBuilder ShortHeaderBuilder() {
}
WriteQuicDataResult writeCryptoAndAckDataToSocket(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -1090,7 +1090,7 @@ WriteQuicDataResult writeCryptoAndAckDataToSocket(
}
WriteQuicDataResult writeQuicDataToSocket(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -1113,7 +1113,7 @@ WriteQuicDataResult writeQuicDataToSocket(
}
WriteQuicDataResult writeQuicDataExceptCryptoStreamToSocket(
folly::AsyncUDPSocket& socket,
QuicAsyncUDPSocketType& socket,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -1135,7 +1135,7 @@ WriteQuicDataResult writeQuicDataExceptCryptoStreamToSocket(
}
uint64_t writeZeroRttDataToSocket(
folly::AsyncUDPSocket& socket,
QuicAsyncUDPSocketType& socket,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -1184,7 +1184,7 @@ uint64_t writeZeroRttDataToSocket(
}
void writeCloseCommon(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
PacketHeader&& header,
folly::Optional<QuicError> closeDetails,
@@ -1284,7 +1284,7 @@ void writeCloseCommon(
}
void writeLongClose(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -1315,7 +1315,7 @@ void writeLongClose(
}
void writeShortClose(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& connId,
folly::Optional<QuicError> closeDetails,
@@ -1364,7 +1364,7 @@ void encryptPacketHeader(
}
WriteQuicDataResult writeConnectionDataToSocket(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -1512,7 +1512,7 @@ WriteQuicDataResult writeConnectionDataToSocket(
}
WriteQuicDataResult writeProbingDataToSocket(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,

View File

@@ -8,7 +8,7 @@
#pragma once
#include <folly/Expected.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/QuicException.h>
#include <quic/api/IoBufQuicBatch.h>
@@ -91,7 +91,7 @@ struct WriteQuicDataResult {
* socket supplied with the aead and the headerCipher.
*/
WriteQuicDataResult writeQuicDataToSocket(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -107,7 +107,7 @@ WriteQuicDataResult writeQuicDataToSocket(
* return the number of packets written to socket.
*/
WriteQuicDataResult writeCryptoAndAckDataToSocket(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -124,7 +124,7 @@ WriteQuicDataResult writeCryptoAndAckDataToSocket(
* packets and cannot use the encryption of the data key.
*/
WriteQuicDataResult writeQuicDataExceptCryptoStreamToSocket(
folly::AsyncUDPSocket& socket,
QuicAsyncUDPSocketType& socket,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -138,7 +138,7 @@ WriteQuicDataResult writeQuicDataExceptCryptoStreamToSocket(
* zero rtt cipher.
*/
uint64_t writeZeroRttDataToSocket(
folly::AsyncUDPSocket& socket,
QuicAsyncUDPSocketType& socket,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -225,7 +225,7 @@ uint64_t congestionControlWritableBytes(QuicConnectionStateBase& conn);
uint64_t unlimitedWritableBytes(QuicConnectionStateBase&);
void writeCloseCommon(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
PacketHeader&& header,
folly::Optional<QuicError> closeDetails,
@@ -237,7 +237,7 @@ void writeCloseCommon(
* The close frame type written depends on the type of error in closeDetails.
*/
void writeLongClose(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -252,7 +252,7 @@ void writeLongClose(
* The close frame type written depends on the type of error in closeDetails.
*/
void writeShortClose(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& connId,
folly::Optional<QuicError> closeDetails,
@@ -280,7 +280,7 @@ void encryptPacketHeader(
* number of packetLimit packets at each invocation.
*/
WriteQuicDataResult writeConnectionDataToSocket(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,
@@ -296,7 +296,7 @@ WriteQuicDataResult writeConnectionDataToSocket(
const std::string& token = std::string());
WriteQuicDataResult writeProbingDataToSocket(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& connection,
const ConnectionId& srcConnId,
const ConnectionId& dstConnId,

View File

@@ -9,6 +9,7 @@
#include <gtest/gtest.h>
#include <quic/client/state/ClientStateMachine.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/common/test/TestUtils.h>
#include <quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h>
#include <quic/state/StateData.h>
@@ -20,7 +21,7 @@ namespace quic {
namespace testing {
void RunTest(int numBatch) {
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
QuicAsyncUDPSocketType sock(&evb);
auto batchWriter = BatchWriterPtr(new test::TestPacketBatchWriter(numBatch));
folly::SocketAddress peerAddress{"127.0.0.1", 1234};

View File

@@ -206,7 +206,7 @@ class MockQuicTransport : public QuicServerTransport {
MockQuicTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connCb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx)

View File

@@ -35,11 +35,6 @@ struct QuicBatchWriterTest : public ::testing::Test,
TEST_P(QuicBatchWriterTest, TestBatchingNone) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
sock.setReuseAddr(false);
sock.bind(folly::SocketAddress("127.0.0.1", 0));
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
quic::QuicBatchingMode::BATCHING_MODE_NONE,
kBatchNum,
@@ -67,7 +62,7 @@ TEST_P(QuicBatchWriterTest, TestBatchingNone) {
TEST_P(QuicBatchWriterTest, TestBatchingGSOBase) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
QuicAsyncUDPSocketType sock(&evb);
sock.setReuseAddr(false);
sock.bind(folly::SocketAddress("127.0.0.1", 0));
gsoSupported_ = sock.getGSO() >= 0;
@@ -97,7 +92,7 @@ TEST_P(QuicBatchWriterTest, TestBatchingGSOBase) {
TEST_P(QuicBatchWriterTest, TestBatchingGSOLastSmallPacket) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
QuicAsyncUDPSocketType sock(&evb);
sock.setReuseAddr(false);
sock.bind(folly::SocketAddress("127.0.0.1", 0));
gsoSupported_ = sock.getGSO() >= 0;
@@ -139,7 +134,7 @@ TEST_P(QuicBatchWriterTest, TestBatchingGSOLastSmallPacket) {
TEST_P(QuicBatchWriterTest, TestBatchingGSOLastBigPacket) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
QuicAsyncUDPSocketType sock(&evb);
sock.setReuseAddr(false);
sock.bind(folly::SocketAddress("127.0.0.1", 0));
gsoSupported_ = sock.getGSO() >= 0;
@@ -176,7 +171,7 @@ TEST_P(QuicBatchWriterTest, TestBatchingGSOLastBigPacket) {
TEST_P(QuicBatchWriterTest, TestBatchingGSOBatchNum) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
QuicAsyncUDPSocketType sock(&evb);
sock.setReuseAddr(false);
sock.bind(folly::SocketAddress("127.0.0.1", 0));
gsoSupported_ = sock.getGSO() >= 0;
@@ -221,11 +216,6 @@ TEST_P(QuicBatchWriterTest, TestBatchingGSOBatchNum) {
TEST_P(QuicBatchWriterTest, TestBatchingSendmmsg) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
sock.setReuseAddr(false);
sock.bind(folly::SocketAddress("127.0.0.1", 0));
auto batchWriter = quic::BatchWriterFactory::makeBatchWriter(
quic::QuicBatchingMode::BATCHING_MODE_SENDMMSG,
kBatchNum,
@@ -264,7 +254,7 @@ TEST_P(QuicBatchWriterTest, TestBatchingSendmmsg) {
TEST_P(QuicBatchWriterTest, TestBatchingSendmmsgGSOBatchNum) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
QuicAsyncUDPSocketType sock(&evb);
sock.setReuseAddr(false);
sock.bind(folly::SocketAddress("127.0.0.1", 0));
gsoSupported_ = sock.getGSO() >= 0;
@@ -310,7 +300,7 @@ TEST_P(QuicBatchWriterTest, TestBatchingSendmmsgGSOBatchNum) {
TEST_P(QuicBatchWriterTest, TestBatchingSendmmsgGSOBatcBigSmallPacket) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::AsyncUDPSocket sock(&evb);
QuicAsyncUDPSocketType sock(&evb);
sock.setReuseAddr(false);
sock.bind(folly::SocketAddress("127.0.0.1", 0));
gsoSupported_ = sock.getGSO() >= 0;
@@ -360,8 +350,6 @@ TEST_P(QuicBatchWriterTest, TestBatchingSendmmsgGSOBatcBigSmallPacket) {
TEST_P(QuicBatchWriterTest, InplaceWriterNeedsFlush) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::test::MockAsyncUDPSocket sock(&evb);
gsoSupported_ = true;
uint32_t batchSize = 20;
auto bufAccessor =
@@ -387,8 +375,6 @@ TEST_P(QuicBatchWriterTest, InplaceWriterNeedsFlush) {
TEST_P(QuicBatchWriterTest, InplaceWriterAppendLimit) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::test::MockAsyncUDPSocket sock(&evb);
gsoSupported_ = true;
uint32_t batchSize = 20;
auto bufAccessor =
@@ -422,8 +408,6 @@ TEST_P(QuicBatchWriterTest, InplaceWriterAppendLimit) {
TEST_P(QuicBatchWriterTest, InplaceWriterAppendSmaller) {
bool useThreadLocal = GetParam();
folly::EventBase evb;
folly::test::MockAsyncUDPSocket sock(&evb);
gsoSupported_ = true;
uint32_t batchSize = 20;
auto bufAccessor =

View File

@@ -52,7 +52,7 @@ class QuicStreamAsyncTransportTest : public Test {
EXPECT_CALL(*serverTransportFactory, _make(_, _, _, _))
.WillOnce(Invoke(
[&](folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket>& socket,
std::unique_ptr<QuicAsyncUDPSocketType>& socket,
const folly::SocketAddress& /*addr*/,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) {
auto transport = quic::QuicServerTransport::make(
@@ -156,7 +156,7 @@ class QuicStreamAsyncTransportTest : public Test {
.WillOnce(Invoke([&p = promise]() mutable { p.setValue(); }));
clientEvb_.runInLoop([&]() {
auto sock = std::make_unique<folly::AsyncUDPSocket>(&clientEvb_);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(&clientEvb_);
auto fizzClientContext =
FizzClientQuicHandshakeContext::Builder()
.setCertificateVerifier(test::createTestCertificateVerifier())

View File

@@ -227,7 +227,7 @@ class TestQuicTransport
public:
TestQuicTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connCb)
: QuicTransportBase(evb, std::move(socket)),

View File

@@ -28,7 +28,7 @@ namespace test {
using PacketStreamDetails = OutstandingPacketMetadata::StreamDetails;
uint64_t writeProbingDataToSocketForTest(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& conn,
uint8_t probesToSend,
const Aead& aead,
@@ -59,7 +59,7 @@ uint64_t writeProbingDataToSocketForTest(
}
void writeCryptoDataProbesToSocketForTest(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicConnectionStateBase& conn,
uint8_t probesToSend,
const Aead& aead,

View File

@@ -22,7 +22,7 @@ class TestQuicTransport
public:
TestQuicTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connCb)
: QuicTransportBase(evb, std::move(socket)),

View File

@@ -37,7 +37,7 @@ namespace quic {
QuicClientTransport::QuicClientTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize,
PacketNum startingPacketNum,
@@ -53,7 +53,7 @@ QuicClientTransport::QuicClientTransport(
QuicClientTransport::QuicClientTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize,
bool useConnectionEndWithErrorCallback)
@@ -1230,7 +1230,7 @@ bool QuicClientTransport::shouldOnlyNotify() {
}
void QuicClientTransport::recvMsg(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
uint64_t readBufferSize,
int numPackets,
NetworkData& networkData,
@@ -1253,7 +1253,7 @@ void QuicClientTransport::recvMsg(
}
int flags = 0;
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams params;
QuicAsyncUDPSocketWrapper::ReadCallback::OnDataAvailableParams params;
struct msghdr msg {};
msg.msg_name = rawAddr;
msg.msg_namelen = kAddrLen;
@@ -1262,8 +1262,8 @@ void QuicClientTransport::recvMsg(
#ifdef FOLLY_HAVE_MSG_ERRQUEUE
bool useGRO = sock.getGRO() > 0;
bool useTS = sock.getTimestamping() > 0;
char control[folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams::
kCmsgSpace] = {};
char control[QuicAsyncUDPSocketWrapper::ReadCallback::
OnDataAvailableParams::kCmsgSpace] = {};
if (useGRO || useTS) {
msg.msg_control = control;
@@ -1298,7 +1298,7 @@ void QuicClientTransport::recvMsg(
}
#ifdef FOLLY_HAVE_MSG_ERRQUEUE
if (useGRO) {
folly::AsyncUDPSocket::fromMsg(params, msg);
QuicAsyncUDPSocketType::fromMsg(params, msg);
// truncated
if ((size_t)ret > readBufferSize) {
@@ -1354,7 +1354,7 @@ void QuicClientTransport::recvMsg(
}
void QuicClientTransport::recvMmsg(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
uint64_t readBufferSize,
uint16_t numPackets,
NetworkData& networkData,
@@ -1367,7 +1367,8 @@ void QuicClientTransport::recvMmsg(
bool useTS = sock.getTimestamping() > 0;
std::vector<std::array<
char,
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams::kCmsgSpace>>
QuicAsyncUDPSocketWrapper::ReadCallback::OnDataAvailableParams::
kCmsgSpace>>
controlVec(useGRO ? numPackets : 0);
// we need to consider MSG_TRUNC too
@@ -1438,10 +1439,10 @@ void QuicClientTransport::recvMmsg(
// should ignore such datagrams.
continue;
}
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams params;
QuicAsyncUDPSocketWrapper::ReadCallback::OnDataAvailableParams params;
#ifdef FOLLY_HAVE_MSG_ERRQUEUE
if (useGRO || useTS) {
folly::AsyncUDPSocket::fromMsg(params, msg.msg_hdr);
QuicAsyncUDPSocketType::fromMsg(params, msg.msg_hdr);
// truncated
if (bytesRead > readBufferSize) {
@@ -1500,7 +1501,7 @@ void QuicClientTransport::recvMmsg(
}
void QuicClientTransport::onNotifyDataAvailable(
folly::AsyncUDPSocket& sock) noexcept {
QuicAsyncUDPSocketType& sock) noexcept {
DCHECK(conn_) << "trying to receive packets without a connection";
auto readBufferSize =
conn_->transportSettings.maxRecvPacketSize * numGROBuffers_;
@@ -1649,7 +1650,7 @@ void QuicClientTransport::setHappyEyeballsCachedFamily(
}
void QuicClientTransport::addNewSocket(
std::unique_ptr<folly::AsyncUDPSocket> socket) {
std::unique_ptr<QuicAsyncUDPSocketType> socket) {
happyEyeballsAddSocket(*clientConn_, std::move(socket));
}
@@ -1741,7 +1742,7 @@ void QuicClientTransport::setSupportedVersions(
}
void QuicClientTransport::onNetworkSwitch(
std::unique_ptr<folly::AsyncUDPSocket> newSock) {
std::unique_ptr<QuicAsyncUDPSocketType> newSock) {
if (!conn_->oneRttWriteCipher) {
return;
}
@@ -1753,10 +1754,8 @@ void QuicClientTransport::onNetworkSwitch(
sock->close();
socket_ = std::move(newSock);
if (socket_) {
socket_->setAdditionalCmsgsFunc(
[&]() { return getAdditionalCmsgsForAsyncUDPSocket(); });
}
happyEyeballsSetUpSocket(
*socket_,
conn_->localAddress,

View File

@@ -10,11 +10,11 @@
#include <folly/Random.h>
#include <folly/SocketAddress.h>
#include <folly/io/SocketOptionMap.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <folly/net/NetOps.h>
#include <quic/api/QuicTransportBase.h>
#include <quic/client/state/ClientStateMachine.h>
#include <quic/common/BufUtil.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/state/QuicConnectionStats.h>
namespace quic {
@@ -23,13 +23,13 @@ class ClientHandshakeFactory;
class QuicClientTransport
: public QuicTransportBase,
public folly::AsyncUDPSocket::ReadCallback,
public folly::AsyncUDPSocket::ErrMessageCallback,
public QuicAsyncUDPSocketWrapper::ReadCallback,
public QuicAsyncUDPSocketWrapper::ErrMessageCallback,
public std::enable_shared_from_this<QuicClientTransport> {
public:
QuicClientTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize = 0,
bool useConnectionEndWithErrorCallback = false);
@@ -37,7 +37,7 @@ class QuicClientTransport
// Testing only API:
QuicClientTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize,
PacketNum startingPacketNum,
@@ -58,7 +58,7 @@ class QuicClientTransport
template <class TransportType = QuicClientTransport>
static std::shared_ptr<TransportType> newClient(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connectionIdSize = 0,
bool useConnectionEndWithErrorCallback = false) {
@@ -88,7 +88,7 @@ class QuicClientTransport
* optional. If not called, INADDR_ANY will be used.
*/
void setLocalAddress(folly::SocketAddress localAddress);
void addNewSocket(std::unique_ptr<folly::AsyncUDPSocket> socket);
void addNewSocket(std::unique_ptr<QuicAsyncUDPSocketType> socket);
void setHappyEyeballsEnabled(bool happyEyeballsEnabled);
virtual void setHappyEyeballsCachedFamily(sa_family_t cachedFamily);
@@ -114,11 +114,11 @@ class QuicClientTransport
bool hasWriteCipher() const override;
std::shared_ptr<QuicTransportBase> sharedGuard() override;
// folly::AsyncUDPSocket::ReadCallback
// QuicAsyncUDPSocketWrapper::ReadCallback
void onReadClosed() noexcept override {}
void onReadError(const folly::AsyncSocketException&) noexcept override;
// folly::AsyncUDPSocket::ErrMessageCallback
// QuicAsyncUDPSocketWrapper::ErrMessageCallback
void errMessage(const cmsghdr& cmsg) noexcept override;
void errMessageError(const folly::AsyncSocketException&) noexcept override {}
@@ -138,7 +138,8 @@ class QuicClientTransport
*/
void setSelfOwning();
void onNetworkSwitch(std::unique_ptr<folly::AsyncUDPSocket> newSock) override;
void onNetworkSwitch(
std::unique_ptr<QuicAsyncUDPSocketType> newSock) override;
/**
* Set callback for various transport stats (such as packet received, dropped
@@ -188,7 +189,7 @@ class QuicClientTransport
return wrappedObserverContainer_.getPtr();
}
// From AsyncUDPSocket::ReadCallback
// From QuicAsyncUDPSocketWrapper::ReadCallback
void getReadBuffer(void** buf, size_t* len) noexcept override;
void onDataAvailable(
const folly::SocketAddress& server,
@@ -196,16 +197,17 @@ class QuicClientTransport
bool truncated,
OnDataAvailableParams params) noexcept override;
bool shouldOnlyNotify() override;
void onNotifyDataAvailable(folly::AsyncUDPSocket& sock) noexcept override;
void onNotifyDataAvailable(QuicAsyncUDPSocketType& sock) noexcept override;
void recvMsg(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
uint64_t readBufferSize,
int numPackets,
NetworkData& networkData,
folly::Optional<folly::SocketAddress>& server,
size_t& totalData);
void recvMmsg(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
uint64_t readBufferSize,
uint16_t numPackets,
NetworkData& networkData,

View File

@@ -54,7 +54,7 @@ void QuicConnector::connect(
return;
}
auto sock = std::make_unique<folly::AsyncUDPSocket>(eventBase);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(eventBase);
quicClient_ = quic::QuicClientTransport::newClient(
eventBase,
std::move(sock),

View File

@@ -9,6 +9,7 @@
#include <quic/client/handshake/ClientHandshake.h>
#include <quic/client/handshake/ClientHandshakeFactory.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/congestion_control/QuicCubic.h>
#include <quic/flowcontrol/QuicFlowController.h>
#include <quic/handshake/TransportParameters.h>
@@ -88,7 +89,7 @@ struct QuicClientConnectionState : public QuicConnectionStateBase {
folly::SocketAddress secondPeerAddress;
// The UDP socket that will be used for the second connection attempt
std::unique_ptr<folly::AsyncUDPSocket> secondSocket;
std::unique_ptr<QuicAsyncUDPSocketType> secondSocket;
// Whether should write to the first UDP socket
bool shouldWriteToFirstSocket{true};

View File

@@ -11,6 +11,7 @@
#include <quic/client/handshake/ClientHandshake.h>
#include <quic/client/state/ClientStateMachine.h>
#include <quic/client/test/Mocks.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h>
#include <quic/handshake/CryptoFactory.h>
#include <quic/handshake/TransportParameters.h>
@@ -104,7 +105,7 @@ TEST_F(ClientStateMachineTest, PreserveHappyeyabllsDuringUndo) {
client_->clientConnectionId = ConnectionId::createRandom(8);
client_->happyEyeballsState.finished = true;
client_->happyEyeballsState.secondSocket =
std::make_unique<folly::AsyncUDPSocket>(&evb);
std::make_unique<QuicAsyncUDPSocketType>(&evb);
auto newConn = undoAllClientStateForRetry(std::move(client_));
EXPECT_TRUE(newConn->happyEyeballsState.finished);
EXPECT_NE(nullptr, newConn->happyEyeballsState.secondSocket);

View File

@@ -13,6 +13,7 @@
#include <quic/client/handshake/CachedServerTransportParameters.h>
#include <quic/client/handshake/ClientHandshake.h>
#include <quic/client/handshake/ClientHandshakeFactory.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/handshake/CryptoFactory.h>
#include <quic/handshake/TransportParameters.h>
@@ -91,7 +92,7 @@ class MockQuicClientTransport : public quic::QuicClientTransport {
explicit MockQuicClientTransport(
TestType testType,
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory)
: QuicClientTransport(
evb,

View File

@@ -8,6 +8,7 @@
#include <gtest/gtest.h>
#include <quic/client/connector/QuicConnector.h>
#include <quic/client/test/Mocks.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/common/test/TestClientUtils.h>
#include <quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h>
@@ -31,7 +32,7 @@ class QuicConnectorTest : public Test {
auto verifier = createTestCertificateVerifier();
auto clientCtx = std::make_shared<fizz::client::FizzClientContext>();
auto pskCache = std::make_shared<BasicQuicPskCache>();
auto sock = std::make_unique<folly::AsyncUDPSocket>(&eventBase_);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(&eventBase_);
auto fizzClientContext = FizzClientQuicHandshakeContext::Builder()
.setFizzClientContext(clientCtx)
.setCertificateVerifier(verifier)

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <folly/Range.h>
#include <folly/SocketAddress.h>
#include <folly/io/IOBuf.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <folly/portability/Sockets.h>
#include <quic/common/Events.h>
namespace quic {
using QuicAsyncUDPSocketType = folly::AsyncUDPSocket;
class QuicAsyncUDPSocketWrapper {
public:
using ReadCallback = QuicAsyncUDPSocketType::ReadCallback;
using ErrMessageCallback = QuicAsyncUDPSocketType::ErrMessageCallback;
};
} // namespace quic

View File

@@ -7,8 +7,6 @@
#include <quic/common/SocketUtil.h>
using folly::AsyncUDPSocket;
namespace quic {
bool isNetworkUnreachable(int err) {
@@ -16,7 +14,7 @@ bool isNetworkUnreachable(int err) {
}
void applySocketOptions(
AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketOptionMap& options,
sa_family_t family,
folly::SocketOptionKey::ApplyPos pos) noexcept {

View File

@@ -8,15 +8,15 @@
#pragma once
#include <folly/io/SocketOptionMap.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <folly/net/NetOps.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
namespace quic {
bool isNetworkUnreachable(int err);
void applySocketOptions(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
const folly::SocketOptionMap& options,
sa_family_t family,
folly::SocketOptionKey::ApplyPos pos) noexcept;

View File

@@ -58,7 +58,7 @@ const RegularQuicWritePacket& writeQuicPacket(
PacketNum rstStreamAndSendPacket(
QuicServerConnectionState& conn,
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicStreamState& stream,
ApplicationErrorCode errorCode) {
auto aead = createNoOpAead();
@@ -769,14 +769,14 @@ bool TestPacketBatchWriter::append(
std::unique_ptr<folly::IOBuf>&& /*unused*/,
size_t size,
const folly::SocketAddress& /*unused*/,
folly::AsyncUDPSocket* /*unused*/) {
QuicAsyncUDPSocketType* /*unused*/) {
bufNum_++;
bufSize_ += size;
return ((maxBufs_ < 0) || (bufNum_ >= maxBufs_));
}
ssize_t TestPacketBatchWriter::write(
folly::AsyncUDPSocket& /*unused*/,
QuicAsyncUDPSocketType& /*unused*/,
const folly::SocketAddress& /*unused*/) {
return bufSize_;
}

View File

@@ -67,7 +67,7 @@ RegularQuicPacketBuilder::Packet createAckPacket(
PacketNum rstStreamAndSendPacket(
QuicServerConnectionState& conn,
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
QuicStreamState& stream,
ApplicationErrorCode errorCode);
@@ -365,10 +365,10 @@ class TestPacketBatchWriter : public IOBufBatchWriter {
std::unique_ptr<folly::IOBuf>&& /*unused*/,
size_t size,
const folly::SocketAddress& /*unused*/,
folly::AsyncUDPSocket* /*unused*/) override;
QuicAsyncUDPSocketType* /*unused*/) override;
ssize_t write(
folly::AsyncUDPSocket& /*unused*/,
QuicAsyncUDPSocketType& /*unused*/,
const folly::SocketAddress& /*unused*/) override;
size_t getBufSize() const {

View File

@@ -130,7 +130,7 @@ static auto& getThreadLocalConn(size_t maxPackets = 44) {
}
BufQuicBatchResult writePacketsGroup(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
RequestGroup& reqGroup,
const std::function<Buf(const PacketizationRequest& req)>& bufProvider) {
if (reqGroup.requests.empty()) {

View File

@@ -185,7 +185,7 @@ struct RequestGroup {
};
BufQuicBatchResult writePacketsGroup(
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
RequestGroup& reqGroup,
const std::function<Buf(const PacketizationRequest& req)>& bufProvider);

View File

@@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
#include <folly/io/async/test/MockAsyncUDPSocket.h>
#include <folly/portability/GTest.h>
#include <quic/common/test/TestUtils.h>
#include <quic/dsr/backend/DSRPacketizer.h>

View File

@@ -15,6 +15,7 @@
#include <folly/io/SocketOptionMap.h>
#include <folly/io/async/ScopedEventBaseThread.h>
#include <quic/QuicConstants.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/congestion_control/CongestionControllerFactory.h>
#include <quic/fizz/client/handshake/test/MockQuicPskCache.h>
#include <quic/fizz/client/test/QuicClientTransportTestUtil.h>
@@ -88,7 +89,7 @@ class QuicClientTransportIntegrationTest : public TestWithParam<TestingParams> {
std::shared_ptr<TestingQuicClientTransport> createClient() {
pskCache_ = std::make_shared<BasicQuicPskCache>();
auto sock = std::make_unique<folly::AsyncUDPSocket>(&eventbase_);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(&eventbase_);
auto fizzClientContext = FizzClientQuicHandshakeContext::Builder()
.setFizzClientContext(clientCtx)
.setCertificateVerifier(verifier)

View File

@@ -16,6 +16,7 @@
#include <quic/client/QuicClientTransport.h>
#include <quic/codec/DefaultConnectionIdAlgo.h>
#include <quic/common/Events.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/common/test/TestClientUtils.h>
#include <quic/common/test/TestUtils.h>
#include <quic/fizz/client/handshake/FizzClientHandshake.h>
@@ -45,7 +46,7 @@ class TestingQuicClientTransport : public QuicClientTransport {
TestingQuicClientTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
std::shared_ptr<ClientHandshakeFactory> handshakeFactory,
size_t connIdSize = kDefaultConnectionIdSize,
bool useConnectionEndWithErrorCallback = false)
@@ -150,7 +151,7 @@ class TestingQuicClientTransport : public QuicClientTransport {
onDataAvailable(addr, len, truncated, OnDataAvailableParams());
}
void invokeOnNotifyDataAvailable(folly::AsyncUDPSocket& sock) {
void invokeOnNotifyDataAvailable(QuicAsyncUDPSocketType& sock) {
onNotifyDataAvailable(sock);
}
@@ -910,7 +911,7 @@ class QuicClientTransportTestBase : public virtual testing::Test {
destructionCallback;
std::unique_ptr<folly::EventBase> eventbase_;
folly::SocketAddress serverAddr{"127.0.0.1", 443};
folly::AsyncUDPSocket::ReadCallback* networkReadCallback{nullptr};
QuicAsyncUDPSocketWrapper::ReadCallback* networkReadCallback{nullptr};
FakeOneRttHandshakeLayer* mockClientHandshake;
std::shared_ptr<FizzClientQuicHandshakeContext> fizzClientContext;
std::shared_ptr<TestingQuicClientTransport> client;

View File

@@ -13,10 +13,10 @@
#include <folly/SocketAddress.h>
#include <folly/io/SocketOptionMap.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <folly/io/async/HHWheelTimer.h>
#include <folly/net/NetOps.h>
#include <folly/portability/Sockets.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <chrono>
#include <memory>
@@ -58,7 +58,7 @@ void happyEyeballsAddPeerAddress(
void happyEyeballsAddSocket(
QuicClientConnectionState& connection,
std::unique_ptr<folly::AsyncUDPSocket> socket) {
std::unique_ptr<QuicAsyncUDPSocketType> socket) {
connection.happyEyeballsState.secondSocket = std::move(socket);
}
@@ -68,8 +68,8 @@ void startHappyEyeballs(
sa_family_t cachedFamily,
folly::HHWheelTimer::Callback& connAttemptDelayTimeout,
std::chrono::milliseconds connAttempDelay,
folly::AsyncUDPSocket::ErrMessageCallback* errMsgCallback,
folly::AsyncUDPSocket::ReadCallback* readCallback,
QuicAsyncUDPSocketWrapper::ErrMessageCallback* errMsgCallback,
QuicAsyncUDPSocketWrapper::ReadCallback* readCallback,
const folly::SocketOptionMap& options) {
if (connection.happyEyeballsState.v6PeerAddress.isInitialized() &&
connection.happyEyeballsState.v4PeerAddress.isInitialized()) {
@@ -123,12 +123,12 @@ void startHappyEyeballs(
}
void happyEyeballsSetUpSocket(
folly::AsyncUDPSocket& socket,
QuicAsyncUDPSocketType& socket,
folly::Optional<folly::SocketAddress> localAddress,
const folly::SocketAddress& peerAddress,
const TransportSettings& transportSettings,
folly::AsyncUDPSocket::ErrMessageCallback* errMsgCallback,
folly::AsyncUDPSocket::ReadCallback* readCallback,
QuicAsyncUDPSocketWrapper::ErrMessageCallback* errMsgCallback,
QuicAsyncUDPSocketWrapper::ReadCallback* readCallback,
const folly::SocketOptionMap& options) {
auto sockFamily = localAddress.value_or(peerAddress).getFamily();
socket.setReuseAddr(false);
@@ -189,7 +189,7 @@ void happyEyeballsStartSecondSocket(
void happyEyeballsOnDataReceived(
QuicClientConnectionState& connection,
folly::HHWheelTimer::Callback& connAttemptDelayTimeout,
std::unique_ptr<folly::AsyncUDPSocket>& socket,
std::unique_ptr<QuicAsyncUDPSocketType>& socket,
const folly::SocketAddress& peerAddress) {
if (connection.happyEyeballsState.finished) {
return;

View File

@@ -11,8 +11,8 @@
#include <quic/common/Events.h>
#include <folly/io/SocketOptionMap.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <folly/net/NetOps.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <chrono>
#include <memory>
@@ -31,7 +31,7 @@ void happyEyeballsAddPeerAddress(
void happyEyeballsAddSocket(
QuicClientConnectionState& connection,
std::unique_ptr<folly::AsyncUDPSocket> socket);
std::unique_ptr<QuicAsyncUDPSocketType> socket);
void startHappyEyeballs(
QuicClientConnectionState& connection,
@@ -39,17 +39,17 @@ void startHappyEyeballs(
sa_family_t cachedFamily,
folly::HHWheelTimer::Callback& connAttemptDelayTimeout,
std::chrono::milliseconds connAttemptDelay,
folly::AsyncUDPSocket::ErrMessageCallback* errMsgCallback,
folly::AsyncUDPSocket::ReadCallback* readCallback,
QuicAsyncUDPSocketWrapper::ErrMessageCallback* errMsgCallback,
QuicAsyncUDPSocketWrapper::ReadCallback* readCallback,
const folly::SocketOptionMap& options);
void happyEyeballsSetUpSocket(
folly::AsyncUDPSocket& socket,
QuicAsyncUDPSocketType& socket,
folly::Optional<folly::SocketAddress> localAddress,
const folly::SocketAddress& peerAddress,
const TransportSettings& transportSettings,
folly::AsyncUDPSocket::ErrMessageCallback* errMsgCallback,
folly::AsyncUDPSocket::ReadCallback* readCallback,
QuicAsyncUDPSocketWrapper::ErrMessageCallback* errMsgCallback,
QuicAsyncUDPSocketWrapper::ReadCallback* readCallback,
const folly::SocketOptionMap& options);
void happyEyeballsStartSecondSocket(
@@ -58,6 +58,6 @@ void happyEyeballsStartSecondSocket(
void happyEyeballsOnDataReceived(
QuicClientConnectionState& connection,
folly::HHWheelTimer::Callback& connAttemptDelayTimeout,
std::unique_ptr<folly::AsyncUDPSocket>& socket,
std::unique_ptr<QuicAsyncUDPSocketType>& socket,
const folly::SocketAddress& peerAddress);
} // namespace quic

View File

@@ -196,7 +196,7 @@ class EchoClient : public quic::QuicSocket::ConnectionSetupCallback,
folly::SocketAddress addr(host_.c_str(), port_);
evb->runInEventBaseThreadAndWait([&] {
auto sock = std::make_unique<folly::AsyncUDPSocket>(evb);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(evb);
auto fizzClientContext =
FizzClientQuicHandshakeContext::Builder()
.setCertificateVerifier(test::createTestCertificateVerifier())

View File

@@ -45,7 +45,7 @@ class EchoServerTransportFactory : public quic::QuicServerTransportFactory {
quic::QuicServerTransport::Ptr make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
const folly::SocketAddress&,
QuicVersion,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept

View File

@@ -17,9 +17,9 @@ class QuicReusePortUDPSocketFactory : public QuicUDPSocketFactory {
QuicReusePortUDPSocketFactory(bool reusePort = true, bool reuseAddr = false)
: reusePort_(reusePort), reuseAddr_(reuseAddr) {}
std::unique_ptr<folly::AsyncUDPSocket> make(folly::EventBase* evb, int)
std::unique_ptr<QuicAsyncUDPSocketType> make(folly::EventBase* evb, int)
override {
auto sock = std::make_unique<folly::AsyncUDPSocket>(evb);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(evb);
sock->setReusePort(reusePort_);
sock->setReuseAddr(reuseAddr_);
return sock;

View File

@@ -262,7 +262,7 @@ void QuicServer::bindWorkersToSocket(
folly::NetworkSocket::fromFd(::dup(takeoverOverFd)),
// set ownership to OWNS to allow ::close()'ing of of the fd
// when this server goes away
folly::AsyncUDPSocket::FDOwnership::OWNS);
QuicAsyncUDPSocketType::FDOwnership::OWNS);
worker->setSocket(std::move(workerSocket));
if (idx == 0) {
self->boundAddress_ = worker->getAddress();

View File

@@ -459,7 +459,7 @@ class QuicServer : public QuicServerWorker::WorkerCallback,
std::function<int()> unfinishedHandshakeLimitFn_{[]() { return 1048576; }};
// Options to AsyncUDPSocket::bind, only controls IPV6_ONLY currently.
folly::AsyncUDPSocket::BindOptions bindOptions_;
QuicAsyncUDPSocketType::BindOptions bindOptions_;
// set by getEventBaseBackend if multishot callback is
// supprted

View File

@@ -23,7 +23,7 @@ TakeoverHandlerCallback::TakeoverHandlerCallback(
QuicServerWorker* worker,
TakeoverPacketHandler& takeoverPktHandler,
const TransportSettings& transportSettings,
std::unique_ptr<folly::AsyncUDPSocket> socket)
std::unique_ptr<QuicAsyncUDPSocketType> socket)
: worker_(worker),
takeoverPktHandler_(takeoverPktHandler),
transportSettings_(transportSettings),
@@ -44,7 +44,7 @@ void TakeoverHandlerCallback::bind(const folly::SocketAddress& addr) {
}
void TakeoverHandlerCallback::rebind(
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
const folly::SocketAddress& addr) {
if (socket_) {
// first reset existing socket if any
@@ -170,10 +170,9 @@ void TakeoverPacketHandler::forwardPacket(Buf writeBuffer) {
pktForwardingSocket_->write(pktForwardDestAddr_, std::move(writeBuffer));
}
std::unique_ptr<folly::AsyncUDPSocket> TakeoverPacketHandler::makeSocket(
std::unique_ptr<QuicAsyncUDPSocketType> TakeoverPacketHandler::makeSocket(
folly::EventBase* evb) {
auto sock = std::make_unique<folly::AsyncUDPSocket>(evb);
return sock;
return std::make_unique<QuicAsyncUDPSocketType>(evb);
}
void TakeoverPacketHandler::processForwardedPacket(

View File

@@ -7,7 +7,7 @@
#pragma once
#include <folly/io/async/AsyncUDPSocket.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/QuicConstants.h>
#include <quic/codec/ConnectionIdAlgo.h>
@@ -94,7 +94,7 @@ class TakeoverPacketHandler {
TakeoverProtocolVersion takeoverProtocol_{TakeoverProtocolVersion::V0};
private:
std::unique_ptr<folly::AsyncUDPSocket> makeSocket(folly::EventBase* evb);
std::unique_ptr<QuicAsyncUDPSocketType> makeSocket(folly::EventBase* evb);
void forwardPacket(Buf packet);
// prevent copying
TakeoverPacketHandler(const TakeoverPacketHandler&);
@@ -102,7 +102,7 @@ class TakeoverPacketHandler {
QuicServerWorker* worker_;
folly::SocketAddress pktForwardDestAddr_;
std::unique_ptr<folly::AsyncUDPSocket> pktForwardingSocket_;
std::unique_ptr<QuicAsyncUDPSocketType> pktForwardingSocket_;
bool packetForwardingEnabled_{false};
QuicUDPSocketFactory* socketFactory_{nullptr};
};
@@ -110,14 +110,14 @@ class TakeoverPacketHandler {
/**
* Class for handling packets after the socket takeover has initiated
*/
class TakeoverHandlerCallback : public folly::AsyncUDPSocket::ReadCallback,
class TakeoverHandlerCallback : public QuicAsyncUDPSocketType::ReadCallback,
private folly::DelayedDestruction {
public:
explicit TakeoverHandlerCallback(
QuicServerWorker* worker,
TakeoverPacketHandler& takeoverPktHandler,
const TransportSettings& transportSettings,
std::unique_ptr<folly::AsyncUDPSocket> socket);
std::unique_ptr<QuicAsyncUDPSocketType> socket);
// prevent copying
TakeoverHandlerCallback(const TakeoverHandlerCallback&) = delete;
@@ -132,7 +132,7 @@ class TakeoverHandlerCallback : public folly::AsyncUDPSocket::ReadCallback,
* Frees existing socket if any
*/
void rebind(
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
const folly::SocketAddress& addr);
void pause();
@@ -161,7 +161,7 @@ class TakeoverHandlerCallback : public folly::AsyncUDPSocket::ReadCallback,
// QuicServerWorker owns the transport settings
const TransportSettings& transportSettings_;
folly::SocketAddress address_;
std::unique_ptr<folly::AsyncUDPSocket> socket_;
std::unique_ptr<QuicAsyncUDPSocketType> socket_;
Buf readBuffer_;
};
} // namespace quic

View File

@@ -23,7 +23,7 @@ namespace quic {
QuicServerTransport::QuicServerTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connStreamsCb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx,
@@ -41,7 +41,7 @@ QuicServerTransport::QuicServerTransport(
QuicServerTransport::QuicServerTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connStreamsCb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx,
@@ -83,7 +83,7 @@ QuicServerTransport::~QuicServerTransport() {
QuicServerTransport::Ptr QuicServerTransport::make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connStreamsCb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx,

View File

@@ -73,7 +73,7 @@ class QuicServerTransport
static QuicServerTransport::Ptr make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connStreamsCb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx,
@@ -81,7 +81,7 @@ class QuicServerTransport
QuicServerTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connStreamsCb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx,
@@ -91,7 +91,7 @@ class QuicServerTransport
// Testing only API:
QuicServerTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connStreamsCb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx,

View File

@@ -8,7 +8,7 @@
#pragma once
#include <fizz/server/FizzServerContext.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/server/QuicServerTransport.h>
namespace quic {
@@ -19,7 +19,7 @@ class QuicServerTransportFactory {
virtual QuicServerTransport::Ptr make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
const folly::SocketAddress& addr,
QuicVersion quicVersion,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept = 0;

View File

@@ -66,14 +66,14 @@ folly::EventBase* QuicServerWorker::getEventBase() const {
}
void QuicServerWorker::setSocket(
std::unique_ptr<folly::AsyncUDPSocket> socket) {
std::unique_ptr<QuicAsyncUDPSocketType> socket) {
socket_ = std::move(socket);
evb_ = folly::Executor::KeepAlive(socket_->getEventBase());
}
void QuicServerWorker::bind(
const folly::SocketAddress& address,
folly::AsyncUDPSocket::BindOptions bindOptions) {
QuicAsyncUDPSocketType::BindOptions bindOptions) {
DCHECK(!supportedVersions_.empty());
CHECK(socket_);
switch (setEventCallback_) {
@@ -90,7 +90,7 @@ void QuicServerWorker::bind(
// bind, since bind creates the fd.
if (socketOptions_) {
applySocketOptions(
*socket_.get(),
*socket_,
*socketOptions_,
address.getFamily(),
folly::SocketOptionKey::ApplyPos::PRE_BIND);
@@ -98,7 +98,7 @@ void QuicServerWorker::bind(
socket_->bind(address, bindOptions);
if (socketOptions_) {
applySocketOptions(
*socket_.get(),
*socket_,
*socketOptions_,
address.getFamily(),
folly::SocketOptionKey::ApplyPos::POST_BIND);
@@ -122,12 +122,12 @@ void QuicServerWorker::applyAllSocketOptions() {
CHECK(socket_);
if (socketOptions_) {
applySocketOptions(
*socket_.get(),
*socket_,
*socketOptions_,
getAddress().getFamily(),
folly::SocketOptionKey::ApplyPos::PRE_BIND);
applySocketOptions(
*socket_.get(),
*socket_,
*socketOptions_,
getAddress().getFamily(),
folly::SocketOptionKey::ApplyPos::POST_BIND);
@@ -504,7 +504,7 @@ void QuicServerWorker::recvmsgMultishotCallback(
struct msghdr msg;
msg.msg_controllen = p.control.size();
msg.msg_control = (void*)p.control.data();
folly::AsyncUDPSocket::fromMsg(params, msg);
QuicAsyncUDPSocketType::fromMsg(params, msg);
}
#endif
bool truncated = false;
@@ -530,7 +530,7 @@ void QuicServerWorker::eventRecvmsgCallback(MsgHdr* msgHdr, int bytesRead) {
OnDataAvailableParams params;
#ifdef FOLLY_HAVE_MSG_ERRQUEUE
if (msg.msg_control) {
folly::AsyncUDPSocket::fromMsg(params, msg);
QuicAsyncUDPSocketType::fromMsg(params, msg);
}
#endif
bool truncated = false;
@@ -1096,7 +1096,7 @@ void QuicServerWorker::sendRetryPacket(
}
void QuicServerWorker::allowBeingTakenOver(
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
const folly::SocketAddress& address) {
DCHECK(!takeoverCB_);
// We instantiate and bind the TakeoverHandlerCallback to the given address.
@@ -1107,7 +1107,7 @@ void QuicServerWorker::allowBeingTakenOver(
}
const folly::SocketAddress& QuicServerWorker::overrideTakeoverHandlerAddress(
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
const folly::SocketAddress& address) {
CHECK(takeoverCB_);
takeoverCB_->rebind(std::move(socket), address);
@@ -1229,7 +1229,7 @@ void QuicServerWorker::setHealthCheckToken(
healthCheckToken_ = folly::IOBuf::copyBuffer(healthCheckToken);
}
std::unique_ptr<folly::AsyncUDPSocket> QuicServerWorker::makeSocket(
std::unique_ptr<QuicAsyncUDPSocketType> QuicServerWorker::makeSocket(
folly::EventBase* evb) const {
CHECK(socket_);
auto sock = socketFactory_->make(evb, socket_->getNetworkSocket().toFd());
@@ -1239,7 +1239,7 @@ std::unique_ptr<folly::AsyncUDPSocket> QuicServerWorker::makeSocket(
return sock;
}
std::unique_ptr<folly::AsyncUDPSocket> QuicServerWorker::makeSocket(
std::unique_ptr<QuicAsyncUDPSocketType> QuicServerWorker::makeSocket(
folly::EventBase* evb,
int fd) const {
auto sock = socketFactory_->make(evb, fd);

View File

@@ -12,8 +12,8 @@
#include <folly/container/F14Map.h>
#include <folly/container/F14Set.h>
#include <folly/io/SocketOptionMap.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <folly/small_vector.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <cstdint>
#include <type_traits>
@@ -34,7 +34,7 @@ namespace quic {
class AcceptObserver;
class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
class QuicServerWorker : public QuicAsyncUDPSocketWrapper::ReadCallback,
public QuicServerTransport::RoutingCallback,
public QuicServerTransport::HandshakeFinishedCallback,
public ServerConnectionIdRejector,
@@ -108,8 +108,8 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
// addr
struct sockaddr_storage addrStorage_;
#ifdef FOLLY_HAVE_MSG_ERRQUEUE
char control_[folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams::
kCmsgSpace];
char control_[QuicAsyncUDPSocketWrapper::ReadCallback::
OnDataAvailableParams::kCmsgSpace];
#endif
};
@@ -124,9 +124,9 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
size_t total = 4 + sizeof(struct sockaddr_storage);
data_.msg_namelen = sizeof(struct sockaddr_storage);
#ifdef FOLLY_HAVE_MSG_ERRQUEUE
data_.msg_controllen = folly::AsyncUDPSocket::ReadCallback::
data_.msg_controllen = QuicAsyncUDPSocketWrapper::ReadCallback::
OnDataAvailableParams::kCmsgSpace;
total += folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams::
total += QuicAsyncUDPSocketWrapper::ReadCallback::OnDataAvailableParams::
kCmsgSpace;
data_.msg_controllen += total % 16;
#else
@@ -189,7 +189,7 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
/**
* Sets the listening socket
*/
void setSocket(std::unique_ptr<folly::AsyncUDPSocket> socket);
void setSocket(std::unique_ptr<QuicAsyncUDPSocketType> socket);
/**
* Sets the socket options
@@ -203,8 +203,8 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
*/
void bind(
const folly::SocketAddress& address,
folly::AsyncUDPSocket::BindOptions bindOptions =
folly::AsyncUDPSocket::BindOptions());
QuicAsyncUDPSocketType::BindOptions bindOptions =
QuicAsyncUDPSocketType::BindOptions());
/**
* start reading data from the socket
@@ -238,7 +238,7 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
* by other server
*/
void allowBeingTakenOver(
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
const folly::SocketAddress& address);
/**
@@ -246,7 +246,7 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
* Returns const ref to SocketAddress representing the address it is bound to.
*/
const folly::SocketAddress& overrideTakeoverHandlerAddress(
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
const folly::SocketAddress& address);
/**
@@ -445,7 +445,7 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
void shutdownAllConnections(LocalErrorCode error);
// for unit test
folly::AsyncUDPSocket::ReadCallback* getTakeoverHandlerCallback() {
QuicAsyncUDPSocketWrapper::ReadCallback* getTakeoverHandlerCallback() {
return takeoverCB_.get();
}
@@ -523,7 +523,7 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
* This socket is powered by the same underlying eventbase
* for this QuicServerWorker
*/
std::unique_ptr<folly::AsyncUDPSocket> makeSocket(
std::unique_ptr<QuicAsyncUDPSocketType> makeSocket(
folly::EventBase* evb) const;
/**
@@ -531,7 +531,7 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
* This socket is powered by the same underlying eventbase
* for this QuicServerWorker
*/
std::unique_ptr<folly::AsyncUDPSocket> makeSocket(
std::unique_ptr<QuicAsyncUDPSocketType> makeSocket(
folly::EventBase* evb,
int fd) const;
@@ -610,7 +610,7 @@ class QuicServerWorker : public folly::AsyncUDPSocket::ReadCallback,
const ConnectionId& dstConnId,
const folly::SocketAddress& client);
std::unique_ptr<folly::AsyncUDPSocket> socket_;
std::unique_ptr<QuicAsyncUDPSocketType> socket_;
folly::SocketOptionMap* socketOptions_{nullptr};
std::shared_ptr<WorkerCallback> callback_;
SetEventCallback setEventCallback_{SetEventCallback::NONE};

View File

@@ -16,13 +16,13 @@ class QuicSharedUDPSocketFactory : public QuicUDPSocketFactory {
~QuicSharedUDPSocketFactory() override {}
QuicSharedUDPSocketFactory() {}
std::unique_ptr<folly::AsyncUDPSocket> make(folly::EventBase* evb, int fd)
std::unique_ptr<QuicAsyncUDPSocketType> make(folly::EventBase* evb, int fd)
override {
auto sock = std::make_unique<folly::AsyncUDPSocket>(evb);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(evb);
if (fd != -1) {
sock->setFD(
folly::NetworkSocket::fromFd(fd),
folly::AsyncUDPSocket::FDOwnership::SHARED);
QuicAsyncUDPSocketType::FDOwnership::SHARED);
sock->setDFAndTurnOffPMTU();
}
return sock;

View File

@@ -7,7 +7,7 @@
#pragma once
#include <folly/io/async/AsyncUDPSocket.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
namespace quic {
@@ -15,7 +15,7 @@ class QuicUDPSocketFactory {
public:
virtual ~QuicUDPSocketFactory() {}
virtual std::unique_ptr<folly::AsyncUDPSocket> make(
virtual std::unique_ptr<QuicAsyncUDPSocketType> make(
folly::EventBase* evb,
int fd) = 0;
};

View File

@@ -19,7 +19,7 @@ QuicAsyncTransportAcceptor::QuicAsyncTransportAcceptor(
quic::QuicServerTransport::Ptr QuicAsyncTransportAcceptor::make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
const folly::SocketAddress&,
QuicVersion,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept {

View File

@@ -27,7 +27,7 @@ class QuicAsyncTransportAcceptor : public quic::QuicServerTransportFactory {
// quic::QuicServerTransportFactory
quic::QuicServerTransport::Ptr make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
const folly::SocketAddress&,
QuicVersion quickVersion,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept

View File

@@ -14,6 +14,7 @@
#include <quic/api/test/Mocks.h>
#include <quic/client/QuicClientAsyncTransport.h>
#include <quic/client/QuicClientTransport.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/common/test/TestClientUtils.h>
#include <quic/common/test/TestUtils.h>
#include <quic/fizz/client/handshake/FizzClientHandshake.h>
@@ -83,7 +84,7 @@ class QuicAsyncTransportServerTest : public Test {
EXPECT_CALL(clientWriteCB_, writeSuccess_()).WillOnce(Return());
clientEvb_.runInEventBaseThreadAndWait([&]() {
auto sock = std::make_unique<folly::AsyncUDPSocket>(&clientEvb_);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(&clientEvb_);
auto fizzClientContext =
FizzClientQuicHandshakeContext::Builder()
.setCertificateVerifier(test::createTestCertificateVerifier())

View File

@@ -9,6 +9,7 @@
#include <folly/portability/GMock.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/server/QuicServer.h>
#include <quic/server/QuicServerTransport.h>
#include <quic/server/QuicServerWorker.h>
@@ -37,7 +38,7 @@ class MockQuicServerTransportFactory : public QuicServerTransportFactory {
// wrapper for mocked make since gmock doesn't support methods with rvalue ref
QuicServerTransport::Ptr make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket,
std::unique_ptr<QuicAsyncUDPSocketType> socket,
const folly::SocketAddress& addr,
QuicVersion,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept
@@ -49,7 +50,7 @@ class MockQuicServerTransportFactory : public QuicServerTransportFactory {
(QuicServerTransport::Ptr),
_make,
(folly::EventBase*,
std::unique_ptr<folly::AsyncUDPSocket>&,
std::unique_ptr<QuicAsyncUDPSocketType>&,
const folly::SocketAddress&,
std::shared_ptr<const fizz::server::FizzServerContext>),
(noexcept));
@@ -99,10 +100,11 @@ class MockWorkerCallback : public QuicServerWorker::WorkerCallback {
class MockQuicUDPSocketFactory : public QuicUDPSocketFactory {
public:
~MockQuicUDPSocketFactory() = default;
std::unique_ptr<folly::AsyncUDPSocket> make(folly::EventBase* evb, int fd) {
return std::unique_ptr<folly::AsyncUDPSocket>(_make(evb, fd));
std::unique_ptr<QuicAsyncUDPSocketType> make(folly::EventBase* evb, int fd)
override {
return std::unique_ptr<QuicAsyncUDPSocketType>(_make(evb, fd));
}
MOCK_METHOD(folly::AsyncUDPSocket*, _make, (folly::EventBase*, int));
MOCK_METHOD(QuicAsyncUDPSocketType*, _make, (folly::EventBase*, int));
};
class MockRoutingCallback : public QuicServerTransport::RoutingCallback {
@@ -146,7 +148,7 @@ class MockQuicServerTransport : public QuicServerTransport {
public:
MockQuicServerTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> socket)
std::unique_ptr<QuicAsyncUDPSocketType> socket)
: QuicServerTransport(evb, std::move(socket), nullptr, nullptr, nullptr) {
}
MOCK_CONST_METHOD0(getOneRttCipherInfo, CipherInfo());

View File

@@ -31,7 +31,7 @@ using namespace testing;
using namespace folly;
using OnDataAvailableParams =
folly::AsyncUDPSocket::ReadCallback::OnDataAvailableParams;
quic::QuicAsyncUDPSocketWrapper::ReadCallback::OnDataAvailableParams;
const folly::SocketAddress kClientAddr("1.2.3.4", 1234);
const folly::SocketAddress kClientAddr2("1.2.3.5", 1235);
@@ -1949,7 +1949,7 @@ TEST_F(QuicServerWorkerTakeoverTest, QuicServerTakeoverProcessForwardedPkt) {
takeoverWorker_->setProcessId(ProcessId::ZERO);
// now invoke the Takeover Handler callback
folly::AsyncUDPSocket::ReadCallback* takeoverCb =
QuicAsyncUDPSocketWrapper::ReadCallback* takeoverCb =
takeoverWorker_->getTakeoverHandlerCallback();
uint8_t* workerBuf = nullptr;
size_t workerBufLen = 0;
@@ -2008,13 +2008,13 @@ TEST_F(QuicServerWorkerTakeoverTest, QuicServerTakeoverProcessForwardedPkt) {
}
TEST_F(QuicServerWorkerTakeoverTest, QuicServerTakeoverCbReadClose) {
folly::AsyncUDPSocket::ReadCallback* takeoverCb =
QuicAsyncUDPSocketWrapper::ReadCallback* takeoverCb =
takeoverWorker_->getTakeoverHandlerCallback();
takeoverCb->onReadClosed();
}
TEST_F(QuicServerWorkerTakeoverTest, QuicServerTakeoverCbReadError) {
folly::AsyncUDPSocket::ReadCallback* takeoverCb =
QuicAsyncUDPSocketWrapper::ReadCallback* takeoverCb =
takeoverWorker_->getTakeoverHandlerCallback();
EXPECT_CALL(*takeoverSocket_, pauseRead());
folly::AsyncSocketException ex(
@@ -2093,7 +2093,7 @@ class QuicServerTest : public Test {
std::shared_ptr<MockQuicTransport> createNewTransport(
folly::EventBase* eventBase,
folly::AsyncUDPSocket& client,
QuicAsyncUDPSocketType& client,
folly::SocketAddress serverAddr) {
// create payload
StreamId id = 1;
@@ -2127,7 +2127,7 @@ class QuicServerTest : public Test {
auto makeTransport =
[&](folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket>& /* socket */,
std::unique_ptr<QuicAsyncUDPSocketType>& /* socket */,
const folly::SocketAddress&,
std::shared_ptr<const fizz::server::FizzServerContext>) noexcept {
// set proper expectations for the transport after its creation
@@ -2184,18 +2184,18 @@ class QuicServerTest : public Test {
return transport;
}
std::unique_ptr<folly::AsyncUDPSocket> makeUdpClient() {
std::unique_ptr<QuicAsyncUDPSocketType> makeUdpClient() {
folly::SocketAddress addr2("::1", 0);
std::unique_ptr<folly::AsyncUDPSocket> client;
std::unique_ptr<QuicAsyncUDPSocketType> client;
evbThread_.getEventBase()->runInEventBaseThreadAndWait([&] {
client =
std::make_unique<folly::AsyncUDPSocket>(evbThread_.getEventBase());
std::make_unique<QuicAsyncUDPSocketType>(evbThread_.getEventBase());
client->bind(addr2);
});
return client;
}
void closeUdpClient(std::unique_ptr<folly::AsyncUDPSocket> client) {
void closeUdpClient(std::unique_ptr<QuicAsyncUDPSocketType> client) {
evbThread_.getEventBase()->runInEventBaseThreadAndWait(
[&] { client->close(); });
}
@@ -2396,7 +2396,7 @@ class QuicServerTakeoverTest : public Test {
NiceMock<MockConnectionCallback> connCb;
auto makeTransport =
[&](folly::EventBase* eventBase,
std::unique_ptr<folly::AsyncUDPSocket>& socket,
std::unique_ptr<QuicAsyncUDPSocketType>& socket,
const folly::SocketAddress&,
std::shared_ptr<const fizz::server::FizzServerContext>
ctx) noexcept {
@@ -2470,10 +2470,10 @@ class QuicServerTakeoverTest : public Test {
oldServer_->allowBeingTakenOver(takeoverAddr);
folly::SocketAddress clientAddr("::1", 0);
std::unique_ptr<folly::AsyncUDPSocket> client;
std::unique_ptr<QuicAsyncUDPSocketType> client;
evbThread_.getEventBase()->runInEventBaseThreadAndWait([&] {
client =
std::make_unique<folly::AsyncUDPSocket>(evbThread_.getEventBase());
std::make_unique<QuicAsyncUDPSocketType>(evbThread_.getEventBase());
client->bind(clientAddr);
});
// send packet to the server and wait
@@ -2609,7 +2609,7 @@ TEST_F(QuicServerTakeoverTest, TakeoverTest) {
runTest(evbs1, evbs2);
}
struct UDPReader : public folly::AsyncUDPSocket::ReadCallback {
struct UDPReader : public QuicAsyncUDPSocketWrapper::ReadCallback {
UDPReader() {
bufPromise_ =
std::make_unique<folly::Promise<std::unique_ptr<folly::IOBuf>>>();
@@ -2620,7 +2620,7 @@ struct UDPReader : public folly::AsyncUDPSocket::ReadCallback {
void start(EventBase* evb, SocketAddress addr) {
evb_ = evb;
evb_->runInEventBaseThreadAndWait([&] {
client = std::make_unique<folly::AsyncUDPSocket>(evb_);
client = std::make_unique<QuicAsyncUDPSocketType>(evb_);
client->bind(addr);
client->resumeRead(this);
});
@@ -2680,7 +2680,7 @@ struct UDPReader : public folly::AsyncUDPSocket::ReadCallback {
std::unique_ptr<folly::IOBuf> buf_;
std::mutex bufLock_;
std::unique_ptr<folly::Promise<std::unique_ptr<folly::IOBuf>>> bufPromise_;
std::unique_ptr<folly::AsyncUDPSocket> client;
std::unique_ptr<QuicAsyncUDPSocketType> client;
EventBase* evb_;
};
@@ -2975,7 +2975,7 @@ TEST_F(QuicServerTest, ZeroRttPacketRoute) {
auto makeTransport =
[&](folly::EventBase* eventBase,
std::unique_ptr<folly::AsyncUDPSocket>& socket,
std::unique_ptr<QuicAsyncUDPSocketType>& socket,
const folly::SocketAddress&,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept {
transport = std::make_shared<MockQuicTransport>(
@@ -3071,7 +3071,7 @@ TEST_F(QuicServerTest, ZeroRttBeforeInitial) {
std::vector<Buf> receivedData;
auto makeTransport =
[&](folly::EventBase* eventBase,
std::unique_ptr<folly::AsyncUDPSocket>& socket,
std::unique_ptr<QuicAsyncUDPSocketType>& socket,
const folly::SocketAddress&,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept {
transport = std::make_shared<MockQuicTransport>(

View File

@@ -15,6 +15,7 @@
#include <quic/api/test/Mocks.h>
#include <quic/codec/DefaultConnectionIdAlgo.h>
#include <quic/codec/Types.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/common/TransportKnobs.h>
#include <quic/common/test/TestUtils.h>
#include <quic/congestion_control/ServerCongestionControllerFactory.h>
@@ -30,7 +31,7 @@ class TestingQuicServerTransport : public QuicServerTransport {
public:
TestingQuicServerTransport(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
ConnectionSetupCallback* connSetupCb,
ConnectionCallback* connCb,
std::shared_ptr<const fizz::server::FizzServerContext> ctx)
@@ -53,7 +54,7 @@ class TestingQuicServerTransport : public QuicServerTransport {
return *dynamic_cast<QuicServerConnectionState*>(conn_.get());
}
folly::AsyncUDPSocket& getSocket() {
QuicAsyncUDPSocketType& getSocket() {
return *socket_;
}

View File

@@ -33,9 +33,9 @@
#include <folly/Optional.h>
#include <folly/io/IOBuf.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <folly/io/async/DelayedDestruction.h>
#include <folly/io/async/HHWheelTimer.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <chrono>
#include <list>

View File

@@ -10,7 +10,7 @@
namespace quic {
TperfDSRSender::TperfDSRSender(Buf sendBuf, folly::AsyncUDPSocket& sock)
TperfDSRSender::TperfDSRSender(Buf sendBuf, QuicAsyncUDPSocketType& sock)
: sock_(sock), buf_(std::move(sendBuf)) {}
bool TperfDSRSender::addSendInstruction(const SendInstruction& instruction) {

View File

@@ -6,7 +6,7 @@
*/
#include <folly/SocketAddress.h>
#include <folly/io/async/AsyncUDPSocket.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/dsr/DSRPacketizationRequestSender.h>
#include <quic/dsr/Types.h>
#include <quic/dsr/backend/DSRPacketizer.h>
@@ -29,7 +29,7 @@ namespace quic {
*/
class TperfDSRSender : public DSRPacketizationRequestSender {
public:
TperfDSRSender(Buf sendBuf, folly::AsyncUDPSocket& sock);
TperfDSRSender(Buf sendBuf, QuicAsyncUDPSocketType& sock);
bool addSendInstruction(const SendInstruction&) override;
@@ -41,7 +41,7 @@ class TperfDSRSender : public DSRPacketizationRequestSender {
private:
std::vector<SendInstruction> instructions_;
folly::AsyncUDPSocket& sock_;
QuicAsyncUDPSocketType& sock_;
CipherPair cipherPair_;
Buf buf_;
};

View File

@@ -184,7 +184,7 @@ class ServerStreamHandler : public quic::QuicSocket::ConnectionSetupCallback,
uint64_t blockSize,
uint32_t numStreams,
uint64_t maxBytesPerStream,
folly::AsyncUDPSocket& sock,
QuicAsyncUDPSocketType& sock,
bool dsrEnabled)
: evb_(evbIn),
blockSize_(blockSize),
@@ -357,7 +357,7 @@ class ServerStreamHandler : public quic::QuicSocket::ConnectionSetupCallback,
uint64_t maxBytesPerStream_;
std::unordered_map<quic::StreamId, uint64_t> bytesPerStream_;
std::set<quic::StreamId> streamsHavingDSRSender_;
folly::AsyncUDPSocket& udpSock_;
QuicAsyncUDPSocketType& udpSock_;
bool dsrEnabled_;
};
@@ -377,7 +377,7 @@ class TPerfServerTransportFactory : public quic::QuicServerTransportFactory {
quic::QuicServerTransport::Ptr make(
folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock,
std::unique_ptr<QuicAsyncUDPSocketType> sock,
const folly::SocketAddress&,
QuicVersion,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept
@@ -647,7 +647,7 @@ class TPerfClient : public quic::QuicSocket::ConnectionSetupCallback,
void start() {
folly::SocketAddress addr(host_.c_str(), port_);
auto sock = std::make_unique<folly::AsyncUDPSocket>(&eventBase_);
auto sock = std::make_unique<QuicAsyncUDPSocketType>(&eventBase_);
auto fizzClientContext =
FizzClientQuicHandshakeContext::Builder()
.setCertificateVerifier(test::createTestCertificateVerifier())