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( IOBufQuicBatch::IOBufQuicBatch(
BatchWriterPtr&& batchWriter, BatchWriterPtr&& batchWriter,
bool threadLocal, bool threadLocal,
folly::AsyncUDPSocket& sock, QuicAsyncUDPSocketType& sock,
const folly::SocketAddress& peerAddress, const folly::SocketAddress& peerAddress,
QuicTransportStatsCallback* statsCallback, QuicTransportStatsCallback* statsCallback,
QuicClientConnectionState::HappyEyeballsState* happyEyeballsState) QuicClientConnectionState::HappyEyeballsState* happyEyeballsState)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,6 +8,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <quic/client/connector/QuicConnector.h> #include <quic/client/connector/QuicConnector.h>
#include <quic/client/test/Mocks.h> #include <quic/client/test/Mocks.h>
#include <quic/common/QuicAsyncUDPSocketWrapper.h>
#include <quic/common/test/TestClientUtils.h> #include <quic/common/test/TestClientUtils.h>
#include <quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h> #include <quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h>
@@ -31,7 +32,7 @@ class QuicConnectorTest : public Test {
auto verifier = createTestCertificateVerifier(); auto verifier = createTestCertificateVerifier();
auto clientCtx = std::make_shared<fizz::client::FizzClientContext>(); auto clientCtx = std::make_shared<fizz::client::FizzClientContext>();
auto pskCache = std::make_shared<BasicQuicPskCache>(); 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() auto fizzClientContext = FizzClientQuicHandshakeContext::Builder()
.setFizzClientContext(clientCtx) .setFizzClientContext(clientCtx)
.setCertificateVerifier(verifier) .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> #include <quic/common/SocketUtil.h>
using folly::AsyncUDPSocket;
namespace quic { namespace quic {
bool isNetworkUnreachable(int err) { bool isNetworkUnreachable(int err) {
@@ -16,7 +14,7 @@ bool isNetworkUnreachable(int err) {
} }
void applySocketOptions( void applySocketOptions(
AsyncUDPSocket& sock, QuicAsyncUDPSocketType& sock,
const folly::SocketOptionMap& options, const folly::SocketOptionMap& options,
sa_family_t family, sa_family_t family,
folly::SocketOptionKey::ApplyPos pos) noexcept { folly::SocketOptionKey::ApplyPos pos) noexcept {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -45,7 +45,7 @@ class EchoServerTransportFactory : public quic::QuicServerTransportFactory {
quic::QuicServerTransport::Ptr make( quic::QuicServerTransport::Ptr make(
folly::EventBase* evb, folly::EventBase* evb,
std::unique_ptr<folly::AsyncUDPSocket> sock, std::unique_ptr<QuicAsyncUDPSocketType> sock,
const folly::SocketAddress&, const folly::SocketAddress&,
QuicVersion, QuicVersion,
std::shared_ptr<const fizz::server::FizzServerContext> ctx) noexcept 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) QuicReusePortUDPSocketFactory(bool reusePort = true, bool reuseAddr = false)
: reusePort_(reusePort), reuseAddr_(reuseAddr) {} : reusePort_(reusePort), reuseAddr_(reuseAddr) {}
std::unique_ptr<folly::AsyncUDPSocket> make(folly::EventBase* evb, int) std::unique_ptr<QuicAsyncUDPSocketType> make(folly::EventBase* evb, int)
override { override {
auto sock = std::make_unique<folly::AsyncUDPSocket>(evb); auto sock = std::make_unique<QuicAsyncUDPSocketType>(evb);
sock->setReusePort(reusePort_); sock->setReusePort(reusePort_);
sock->setReuseAddr(reuseAddr_); sock->setReuseAddr(reuseAddr_);
return sock; return sock;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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