diff --git a/quic/BUCK b/quic/BUCK index 25ca14404..48b29761b 100644 --- a/quic/BUCK +++ b/quic/BUCK @@ -33,8 +33,8 @@ mvfst_cpp_library( ], exported_deps = [ ":constants", - "//folly:optional", "//folly:range", + "//quic/common:optional", "//quic/common:variant", ], external_deps = [ diff --git a/quic/QuicException.h b/quic/QuicException.h index e89813973..7860d0ab5 100644 --- a/quic/QuicException.h +++ b/quic/QuicException.h @@ -7,9 +7,9 @@ #pragma once -#include #include #include +#include #include #include @@ -59,13 +59,13 @@ class QuicTransportException : public std::runtime_error { return errCode_; } - folly::Optional frameType() const noexcept { + Optional frameType() const noexcept { return frameType_; } private: TransportErrorCode errCode_; - folly::Optional frameType_; + Optional frameType_; }; class QuicInternalException : public std::runtime_error { diff --git a/quic/api/BUCK b/quic/api/BUCK index c8de55e82..2d2d4b649 100644 --- a/quic/api/BUCK +++ b/quic/api/BUCK @@ -62,7 +62,6 @@ mvfst_cpp_library( "//folly:exception_wrapper", "//folly:expected", "//folly:maybe_managed_ptr", - "//folly:optional", "//folly:portability", "//folly/io:iobuf", "//folly/io/async:async_transport_certificate", @@ -76,6 +75,7 @@ mvfst_cpp_library( "//quic/codec:types", "//quic/common:looper", "//quic/common:network_data", + "//quic/common:optional", "//quic/common:small_collections", "//quic/common/events:eventbase", "//quic/common/events:quic_timer", diff --git a/quic/api/IoBufQuicBatch.cpp b/quic/api/IoBufQuicBatch.cpp index 2a24710b6..2996ff992 100644 --- a/quic/api/IoBufQuicBatch.cpp +++ b/quic/api/IoBufQuicBatch.cpp @@ -66,7 +66,7 @@ bool IOBufQuicBatch::flushInternal() { } bool written = false; - folly::Optional firstSocketErrno; + Optional firstSocketErrno; if (!happyEyeballsState_ || happyEyeballsState_->shouldWriteToFirstSocket) { auto consumed = batchWriter_->write(sock_, peerAddress_); if (consumed < 0) { @@ -92,7 +92,7 @@ bool IOBufQuicBatch::flushInternal() { happyEyeballsState_->connAttemptDelayTimeout->timeoutExpired(); } - folly::Optional secondSocketErrno; + Optional secondSocketErrno; if (happyEyeballsState_ && happyEyeballsState_->shouldWriteToSecondSocket) { auto consumed = batchWriter_->write( *happyEyeballsState_->secondSocket, diff --git a/quic/api/QuicPacketScheduler.cpp b/quic/api/QuicPacketScheduler.cpp index 3a8d040e4..ed6b8acf1 100644 --- a/quic/api/QuicPacketScheduler.cpp +++ b/quic/api/QuicPacketScheduler.cpp @@ -113,7 +113,7 @@ class MiddleStartingIterationWrapper { namespace quic { bool hasAcksToSchedule(const AckState& ackState) { - folly::Optional largestAckSend = largestAckToSend(ackState); + Optional largestAckSend = largestAckToSend(ackState); if (!largestAckSend) { return false; } @@ -124,9 +124,9 @@ bool hasAcksToSchedule(const AckState& ackState) { return *largestAckSend > *(ackState.largestAckScheduled); } -folly::Optional largestAckToSend(const AckState& ackState) { +Optional largestAckToSend(const AckState& ackState) { if (ackState.acks.empty()) { - return folly::none; + return none; } return ackState.acks.back().end; } @@ -329,7 +329,7 @@ SchedulingResult FrameScheduler::scheduleFramesForPacket( } return SchedulingResult( - folly::none, std::move(builder).buildPacket(), shortHeaderPadding); + none, std::move(builder).buildPacket(), shortHeaderPadding); } void FrameScheduler::writeNextAcks(PacketBuilderInterface& builder) { @@ -379,7 +379,7 @@ bool StreamFrameScheduler::writeStreamLossBuffers( bufferLen, // writeBufferLen -- only the len of the single buffer. bufferLen, // flowControlLen -- not relevant, already flow controlled. buffer->eof, - folly::none /* skipLenHint */, + none /* skipLenHint */, stream.groupId); if (dataLen) { wroteStreamFrame = true; @@ -549,7 +549,7 @@ bool StreamFrameScheduler::writeStreamFrame( bufferLen, flowControlLen, canWriteFin, - folly::none /* skipLenHint */, + none /* skipLenHint */, stream.groupId); if (!dataLen) { return false; @@ -569,7 +569,7 @@ AckScheduler::AckScheduler( const AckState& ackState) : conn_(conn), ackState_(ackState) {} -folly::Optional AckScheduler::writeNextAcks( +Optional AckScheduler::writeNextAcks( PacketBuilderInterface& builder) { // Use default ack delay for long headers. Usually long headers are sent // before crypto negotiation, so the peer might not know about the ack delay @@ -597,7 +597,7 @@ folly::Optional AckScheduler::writeNextAcks( conn_.connectionTime, /* connect timestamp */ }; - folly::Optional ackWriteResult; + Optional ackWriteResult; bool isAckReceiveTimestampsSupported = conn_.transportSettings.maybeAckReceiveTimestampsConfigSentToPeer && @@ -630,7 +630,7 @@ folly::Optional AckScheduler::writeNextAcks( ackWriteResult = writeAckFrame(meta, builder, FrameType::ACK); } if (!ackWriteResult) { - return folly::none; + return none; } return largestAckedPacketNum; } @@ -973,7 +973,7 @@ SchedulingResult CloningScheduler::scheduleFramesForPacket( buf->trimEnd(buf->length() - prevSize); } } - return SchedulingResult(folly::none, folly::none, 0); + return SchedulingResult(none, none, 0); } folly::StringPiece CloningScheduler::name() const { diff --git a/quic/api/QuicPacketScheduler.h b/quic/api/QuicPacketScheduler.h index d11bd5e4b..4e4bd649e 100644 --- a/quic/api/QuicPacketScheduler.h +++ b/quic/api/QuicPacketScheduler.h @@ -23,13 +23,13 @@ namespace quic { struct SchedulingResult { - folly::Optional packetEvent; - folly::Optional packet; + Optional packetEvent; + Optional packet; size_t shortHeaderPadding; explicit SchedulingResult( - folly::Optional packetEventIn, - folly::Optional packetIn, + Optional packetEventIn, + Optional packetIn, size_t shortHeaderPaddingIn = 0) : packetEvent(std::move(packetEventIn)), packet(std::move(packetIn)), @@ -129,7 +129,7 @@ class AckScheduler { public: AckScheduler(const QuicConnectionStateBase& conn, const AckState& ackState); - folly::Optional writeNextAcks(PacketBuilderInterface& builder); + Optional writeNextAcks(PacketBuilderInterface& builder); bool hasPendingAcks() const; @@ -147,7 +147,7 @@ bool hasAcksToSchedule(const AckState& ackState); /** * Returns the largest packet received which needs to be acked. */ -folly::Optional largestAckToSend(const AckState& ackState); +Optional largestAckToSend(const AckState& ackState); class RstStreamScheduler { public: @@ -323,16 +323,16 @@ class FrameScheduler : public QuicPacketScheduler { void writeNextAcks(PacketBuilderInterface& builder); private: - folly::Optional streamFrameScheduler_; - folly::Optional ackScheduler_; - folly::Optional rstScheduler_; - folly::Optional windowUpdateScheduler_; - folly::Optional blockedScheduler_; - folly::Optional cryptoStreamScheduler_; - folly::Optional simpleFrameScheduler_; - folly::Optional pingFrameScheduler_; - folly::Optional datagramFrameScheduler_; - folly::Optional immediateAckFrameScheduler_; + Optional streamFrameScheduler_; + Optional ackScheduler_; + Optional rstScheduler_; + Optional windowUpdateScheduler_; + Optional blockedScheduler_; + Optional cryptoStreamScheduler_; + Optional simpleFrameScheduler_; + Optional pingFrameScheduler_; + Optional datagramFrameScheduler_; + Optional immediateAckFrameScheduler_; folly::StringPiece name_; QuicConnectionStateBase& conn_; }; diff --git a/quic/api/QuicSocket.h b/quic/api/QuicSocket.h index 667862757..751512e17 100644 --- a/quic/api/QuicSocket.h +++ b/quic/api/QuicSocket.h @@ -9,11 +9,11 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -196,10 +196,10 @@ class QuicSocket { std::chrono::microseconds srtt{0us}; std::chrono::microseconds rttvar{0us}; std::chrono::microseconds lrtt{0us}; - folly::Optional maybeLrtt; - folly::Optional maybeLrttAckDelay; - folly::Optional maybeMinRtt; - folly::Optional maybeMinRttNoAckDelay; + Optional maybeLrtt; + Optional maybeLrttAckDelay; + Optional maybeMinRtt; + Optional maybeMinRttNoAckDelay; uint64_t mss{kDefaultUDPSendPacketLen}; CongestionControlType congestionControlType{CongestionControlType::None}; uint64_t writableBytes{0}; @@ -237,11 +237,11 @@ class QuicSocket { uint64_t totalNewStreamBytesSent{0}; uint32_t ptoCount{0}; uint32_t totalPTOCount{0}; - folly::Optional largestPacketAckedByPeer; - folly::Optional largestPacketSent; + Optional largestPacketAckedByPeer; + Optional largestPacketSent; bool usedZeroRtt{false}; // State from congestion control module, if one is installed. - folly::Optional maybeCCState; + Optional maybeCCState; }; /** @@ -267,21 +267,21 @@ class QuicSocket { // Total number of 'new' stream bytes sent on this stream. // Does not include retransmissions of stream bytes. - folly::Optional streamBytesSent{0}; + Optional streamBytesSent{0}; // Total number of stream bytes received on this stream. - folly::Optional streamBytesReceived{0}; + Optional streamBytesReceived{0}; // Stream read error (if one occured) - folly::Optional streamReadError; + Optional streamReadError; // Stream write error (if one occured) - folly::Optional streamWriteError; + Optional streamWriteError; }; - // Returns folly::none before the handshake is complete, otherwise is always + // Returns none before the handshake is complete, otherwise is always // non-empty. - virtual folly::Optional> - getPeerTransportParams() const = 0; + virtual Optional> getPeerTransportParams() + const = 0; /** * Sets connection setup callback. This callback must be set before using the @@ -342,8 +342,8 @@ class QuicSocket { */ virtual void setEarlyDataAppParamsFunctions( folly::Function< - bool(const folly::Optional& alpn, const Buf& appParams) - const> validator, + bool(const Optional& alpn, const Buf& appParams) const> + validator, folly::Function getter) = 0; virtual ~QuicSocket() = default; @@ -355,17 +355,17 @@ class QuicSocket { /** * Get the QUIC Client Connection ID */ - virtual folly::Optional getClientConnectionId() const = 0; + virtual Optional getClientConnectionId() const = 0; /** * Get the QUIC Server Connection ID */ - virtual folly::Optional getServerConnectionId() const = 0; + virtual Optional getServerConnectionId() const = 0; /** * Get the original Quic Server Connection ID chosen by client */ - FOLLY_NODISCARD virtual folly::Optional + FOLLY_NODISCARD virtual Optional getClientChosenDestConnectionId() const = 0; /** @@ -405,9 +405,9 @@ class QuicSocket { * Derive exported key material (RFC5705) from the transport's TLS layer, if * the transport is capable. */ - virtual folly::Optional> getExportedKeyingMaterial( + virtual Optional> getExportedKeyingMaterial( const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength) const = 0; /** @@ -428,7 +428,7 @@ class QuicSocket { * Close this socket with a drain period. If closing with an error, it may be * specified. */ - virtual void close(folly::Optional errorCode) = 0; + virtual void close(Optional errorCode) = 0; /** * Close this socket gracefully, by waiting for all the streams to be idle @@ -440,7 +440,7 @@ class QuicSocket { * Close this socket without a drain period. If closing with an error, it may * be specified. */ - virtual void closeNow(folly::Optional errorCode) = 0; + virtual void closeNow(Optional errorCode) = 0; /** * Returns the event base associated with this socket @@ -475,9 +475,9 @@ class QuicSocket { /** * Get the negotiated ALPN. If called before the transport is ready - * returns folly::none + * returns none */ - virtual folly::Optional getAppProtocol() const = 0; + virtual Optional getAppProtocol() const = 0; /** * Sets the size of the given stream's receive window, or the connection @@ -674,7 +674,7 @@ class QuicSocket { * StopSending. By default when cb is nullptr this function will cause the * transport to send a StopSending frame with * GenericApplicationErrorCode::NO_ERROR. If err is specified to be - * folly::none, no StopSending will be sent. + * none, no StopSending will be sent. * * Users should remove the callback via setReadCallback(id, nullptr) after * reading an error or eof to allow streams to be reaped by the transport. @@ -682,7 +682,7 @@ class QuicSocket { virtual folly::Expected setReadCallback( StreamId id, ReadCallback* cb, - folly::Optional err = + Optional err = GenericApplicationErrorCode::NO_ERROR) = 0; /** @@ -839,10 +839,9 @@ class QuicSocket { * will return an EAGAIN-like error code. * */ - virtual folly::Expected< - folly::Unit, - std::pair>> - consume(StreamId id, uint64_t offset, size_t amount) = 0; + virtual folly:: + Expected>> + consume(StreamId id, uint64_t offset, size_t amount) = 0; /** * Equivalent of calling consume(id, stream->currentReadOffset, amount); @@ -1135,7 +1134,7 @@ class QuicSocket { */ virtual void cancelByteEventCallbacksForStream( const StreamId id, - const folly::Optional& offset = folly::none) = 0; + const Optional& offset = none) = 0; /** * Cancel byte event callbacks for given type and stream. @@ -1146,7 +1145,7 @@ class QuicSocket { virtual void cancelByteEventCallbacksForStream( const ByteEvent::Type type, const StreamId id, - const folly::Optional& offset = folly::none) = 0; + const Optional& offset = none) = 0; /** * Cancel all byte event callbacks of all streams. @@ -1223,7 +1222,7 @@ class QuicSocket { /** * Close the stream for writing. Equivalent to writeChain(id, nullptr, true). */ - virtual folly::Optional shutdownWrite(StreamId id) = 0; + virtual Optional shutdownWrite(StreamId id) = 0; /** * Cancel the given stream @@ -1316,7 +1315,7 @@ class QuicSocket { * Applications should declare all their control streams after either calling * createStream() or receiving onNewBidirectionalStream() */ - virtual folly::Optional setControlStream(StreamId id) = 0; + virtual Optional setControlStream(StreamId id) = 0; /** * Set congestion control type. diff --git a/quic/api/QuicStreamAsyncTransport.h b/quic/api/QuicStreamAsyncTransport.h index 7fe0e8071..8e2fdce6f 100644 --- a/quic/api/QuicStreamAsyncTransport.h +++ b/quic/api/QuicStreamAsyncTransport.h @@ -159,13 +159,13 @@ class QuicStreamAsyncTransport : public folly::AsyncTransport, enum class CloseState { OPEN, CLOSING, CLOSED }; CloseState state_{CloseState::OPEN}; std::shared_ptr sock_; - folly::Optional id_; + Optional id_; enum class EOFState { NOT_SEEN, QUEUED, DELIVERED }; EOFState readEOF_{EOFState::NOT_SEEN}; EOFState writeEOF_{EOFState::NOT_SEEN}; AsyncTransport::ReadCallback* readCb_{nullptr}; folly::IOBufQueue writeBuf_{folly::IOBufQueue::cacheChainLength()}; std::deque> writeCallbacks_; - folly::Optional ex_; + Optional ex_; }; } // namespace quic diff --git a/quic/api/QuicTransportBase.cpp b/quic/api/QuicTransportBase.cpp index f6739562e..f7c50cdf6 100644 --- a/quic/api/QuicTransportBase.cpp +++ b/quic/api/QuicTransportBase.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -34,7 +35,7 @@ namespace { */ constexpr auto APP_NO_ERROR = quic::GenericApplicationErrorCode::NO_ERROR; quic::QuicError maybeSetGenericAppError( - folly::Optional&& error) { + quic::Optional&& error) { return std::move(error).value_or( quic::QuicError{APP_NO_ERROR, quic::toString(APP_NO_ERROR)}); } @@ -76,7 +77,7 @@ QuicTransportBase::QuicTransportBase( return 0us; }); if (socket_) { - folly::Function()> func = [&]() { + folly::Function()> func = [&]() { return getAdditionalCmsgsForAsyncUDPSocket(); }; socket_->setAdditionalCmsgsFunc(std::move(func)); @@ -152,16 +153,16 @@ void QuicTransportBase::setQLogger(std::shared_ptr qLogger) { } } -folly::Optional QuicTransportBase::getClientConnectionId() const { +Optional QuicTransportBase::getClientConnectionId() const { return conn_->clientConnectionId; } -folly::Optional QuicTransportBase::getServerConnectionId() const { +Optional QuicTransportBase::getServerConnectionId() const { return conn_->serverConnectionId; } -folly::Optional -QuicTransportBase::getClientChosenDestConnectionId() const { +Optional QuicTransportBase::getClientChosenDestConnectionId() + const { return conn_->clientChosenDestConnectionId; } @@ -201,7 +202,7 @@ bool QuicTransportBase::error() const { return conn_->localConnectionError.has_value(); } -void QuicTransportBase::close(folly::Optional errorCode) { +void QuicTransportBase::close(Optional errorCode) { [[maybe_unused]] auto self = sharedGuard(); // The caller probably doesn't need a conn callback any more because they // explicitly called close. @@ -213,7 +214,7 @@ void QuicTransportBase::close(folly::Optional errorCode) { closeImpl(std::move(errorCode), true); } -void QuicTransportBase::closeNow(folly::Optional errorCode) { +void QuicTransportBase::closeNow(Optional errorCode) { DCHECK(getEventBase() && getEventBase()->isInEventBaseThread()); [[maybe_unused]] auto self = sharedGuard(); VLOG(4) << __func__ << " " << *this; @@ -249,14 +250,14 @@ void QuicTransportBase::closeGracefully() { QuicError(QuicErrorCode(LocalErrorCode::NO_ERROR), "Graceful Close")); // All streams are closed, close the transport for realz. if (conn_->streamManager->streamCount() == 0) { - closeImpl(folly::none); + closeImpl(none); } } // TODO: t64691045 change the closeImpl API to include both the sanitized and // unsanited error message, remove exceptionCloseWhat_. void QuicTransportBase::closeImpl( - folly::Optional errorCode, + Optional errorCode, bool drainConnection, bool sendCloseImmediately) { if (closeState_ == CloseState::CLOSED) { @@ -582,7 +583,7 @@ QuicSocket::TransportInfo QuicTransportBase::getTransportInfo() const { CongestionControlType congestionControlType = CongestionControlType::None; uint64_t writableBytes = std::numeric_limits::max(); uint64_t congestionWindow = std::numeric_limits::max(); - folly::Optional maybeCCState; + Optional maybeCCState; uint64_t burstSize = 0; std::chrono::microseconds pacingInterval = 0ms; if (conn_->congestionController) { @@ -647,7 +648,7 @@ QuicSocket::TransportInfo QuicTransportBase::getTransportInfo() const { return transportInfo; } -folly::Optional QuicTransportBase::getAppProtocol() const { +Optional QuicTransportBase::getAppProtocol() const { return conn_->handshakeLayer->getApplicationProtocol(); } @@ -730,7 +731,7 @@ QuicTransportBase::setStreamFlowControlWindow( folly::Expected QuicTransportBase::setReadCallback( StreamId id, ReadCallback* cb, - folly::Optional err) { + Optional err) { if (isSendingStream(conn_->nodeType, id)) { return folly::makeUnexpected(LocalErrorCode::INVALID_OPERATION); } @@ -766,7 +767,7 @@ folly::Expected QuicTransportBase::setReadCallbackInternal( StreamId id, ReadCallback* cb, - folly::Optional err) noexcept { + Optional err) noexcept { VLOG(4) << "Setting setReadCallback for stream=" << id << " cb=" << cb << " " << *this; auto readCbIt = readCallbacks_.find(id); @@ -1164,7 +1165,7 @@ void QuicTransportBase::cancelDeliveryCallbacksForStream( void QuicTransportBase::cancelByteEventCallbacksForStream( const StreamId id, - const folly::Optional& offset) { + const Optional& offset) { invokeForEachByteEventType(([this, id, &offset](const ByteEvent::Type type) { cancelByteEventCallbacksForStream(type, id, offset); })); @@ -1173,7 +1174,7 @@ void QuicTransportBase::cancelByteEventCallbacksForStream( void QuicTransportBase::cancelByteEventCallbacksForStream( const ByteEvent::Type type, const StreamId id, - const folly::Optional& offset) { + const Optional& offset) { if (isReceivingStream(conn_->nodeType, id)) { return; } @@ -1367,13 +1368,12 @@ folly::Expected QuicTransportBase::consume( return folly::makeExpected(result.value()); } -folly:: - Expected>> - QuicTransportBase::consume(StreamId id, uint64_t offset, size_t amount) { - using ConsumeError = std::pair>; +folly::Expected>> +QuicTransportBase::consume(StreamId id, uint64_t offset, size_t amount) { + using ConsumeError = std::pair>; if (closeState_ != CloseState::OPEN) { return folly::makeUnexpected( - ConsumeError{LocalErrorCode::CONNECTION_CLOSED, folly::none}); + ConsumeError{LocalErrorCode::CONNECTION_CLOSED, none}); } [[maybe_unused]] auto self = sharedGuard(); SCOPE_EXIT { @@ -1381,7 +1381,7 @@ folly:: updateReadLooper(); // consume may affect "read" API updateWriteLooper(true); }; - folly::Optional readOffset; + Optional readOffset; try { // Need to check that the stream exists first so that we don't // accidentally let the API create a peer stream that was not @@ -1400,11 +1400,11 @@ folly:: if (stream->streamReadError) { switch (stream->streamReadError->type()) { case QuicErrorCode::Type::LocalErrorCode: - return folly::makeUnexpected(ConsumeError{ - *stream->streamReadError->asLocalErrorCode(), folly::none}); + return folly::makeUnexpected( + ConsumeError{*stream->streamReadError->asLocalErrorCode(), none}); default: return folly::makeUnexpected( - ConsumeError{LocalErrorCode::INTERNAL_ERROR, folly::none}); + ConsumeError{LocalErrorCode::INTERNAL_ERROR, none}); } } @@ -1473,16 +1473,16 @@ void QuicTransportBase::processCallbacksAfterWriteData() { // lambda to help get the next callback to call for this stream auto getNextTxCallbackForStreamAndCleanup = [this, &largestOffsetTxed]( - const auto& streamId) -> folly::Optional { + const auto& streamId) -> Optional { auto txCallbacksForStreamIt = txCallbacks_.find(streamId); if (txCallbacksForStreamIt == txCallbacks_.end() || txCallbacksForStreamIt->second.empty()) { - return folly::none; + return none; } auto& txCallbacksForStream = txCallbacksForStreamIt->second; if (txCallbacksForStream.front().offset > *largestOffsetTxed) { - return folly::none; + return none; } // extract the callback, pop from the queue, then check for cleanup @@ -1494,7 +1494,7 @@ void QuicTransportBase::processCallbacksAfterWriteData() { return result; }; - folly::Optional nextOffsetAndCallback; + Optional nextOffsetAndCallback; while ( (nextOffsetAndCallback = getNextTxCallbackForStreamAndCleanup(streamId))) { @@ -1995,7 +1995,7 @@ uint64_t QuicTransportBase::getNumOpenableUnidirectionalStreams() const { folly::Expected QuicTransportBase::createStreamInternal( bool bidirectional, - const folly::Optional& streamGroupId) { + const Optional& streamGroupId) { if (closeState_ != CloseState::OPEN) { return folly::makeUnexpected(LocalErrorCode::CONNECTION_CLOSED); } @@ -2435,7 +2435,7 @@ QuicTransportBase::registerByteEventCallback( // if the callback is already ready, we still insert, but schedule to // process - folly::Optional maxOffsetReady; + Optional maxOffsetReady; switch (type) { case ByteEvent::Type::ACK: maxOffsetReady = getLargestDeliverableOffset(*stream); @@ -2481,11 +2481,11 @@ QuicTransportBase::registerByteEventCallback( return folly::unit; } -folly::Optional QuicTransportBase::shutdownWrite(StreamId id) { +Optional QuicTransportBase::shutdownWrite(StreamId id) { if (isReceivingStream(conn_->nodeType, id)) { return LocalErrorCode::INVALID_OPERATION; } - return folly::none; + return none; } folly::Expected QuicTransportBase::resetStream( @@ -2624,7 +2624,7 @@ void QuicTransportBase::checkForClosedStream() { if (closeState_ == CloseState::GRACEFUL_CLOSING && conn_->streamManager->streamCount() == 0) { - closeImpl(folly::none); + closeImpl(none); } } @@ -2858,7 +2858,7 @@ void QuicTransportBase::setConnectionCallback( } void QuicTransportBase::setEarlyDataAppParamsFunctions( - folly::Function&, const Buf&) const> + folly::Function&, const Buf&) const> validator, folly::Function getter) { conn_->earlyDataAppParamsValidator = std::move(validator); @@ -3546,14 +3546,13 @@ void QuicTransportBase::detachEventBase() { evb_ = nullptr; } -folly::Optional QuicTransportBase::setControlStream( - StreamId id) { +Optional QuicTransportBase::setControlStream(StreamId id) { if (!conn_->streamManager->streamExists(id)) { return LocalErrorCode::STREAM_NOT_EXISTS; } auto stream = CHECK_NOTNULL(conn_->streamManager->getStream(id)); conn_->streamManager->setStreamAsControl(*stream); - return folly::none; + return none; } void QuicTransportBase::runOnEvbAsync( @@ -3816,24 +3815,23 @@ void QuicTransportBase::notifyStartWritingFromAppRateLimited() { getSocketObserverContainer() ->invokeInterfaceMethod< SocketObserverInterface::Events::appRateLimitedEvents>( - [event = SocketObserverInterface::AppLimitedEvent::Builder() - .setOutstandingPackets(conn_->outstandings.packets) - .setWriteCount(conn_->writeCount) - .setLastPacketSentTime( - conn_->lossState.maybeLastPacketSentTime) - .setCwndInBytes( - conn_->congestionController - ? folly::Optional( - conn_->congestionController - ->getCongestionWindow()) - : folly::none) - .setWritableBytes( - conn_->congestionController - ? folly::Optional( - conn_->congestionController - ->getWritableBytes()) - : folly::none) - .build()](auto observer, auto observed) { + [event = + SocketObserverInterface::AppLimitedEvent::Builder() + .setOutstandingPackets(conn_->outstandings.packets) + .setWriteCount(conn_->writeCount) + .setLastPacketSentTime( + conn_->lossState.maybeLastPacketSentTime) + .setCwndInBytes( + conn_->congestionController + ? Optional(conn_->congestionController + ->getCongestionWindow()) + : none) + .setWritableBytes( + conn_->congestionController + ? Optional(conn_->congestionController + ->getWritableBytes()) + : none) + .build()](auto observer, auto observed) { observer->startWritingFromAppLimited(observed, event); }); } @@ -3850,28 +3848,27 @@ void QuicTransportBase::notifyPacketsWritten( getSocketObserverContainer() ->invokeInterfaceMethod< SocketObserverInterface::Events::packetsWrittenEvents>( - [event = SocketObserverInterface::PacketsWrittenEvent::Builder() - .setOutstandingPackets(conn_->outstandings.packets) - .setWriteCount(conn_->writeCount) - .setLastPacketSentTime( - conn_->lossState.maybeLastPacketSentTime) - .setCwndInBytes( - conn_->congestionController - ? folly::Optional( - conn_->congestionController - ->getCongestionWindow()) - : folly::none) - .setWritableBytes( - conn_->congestionController - ? folly::Optional( - conn_->congestionController - ->getWritableBytes()) - : folly::none) - .setNumPacketsWritten(numPacketsWritten) - .setNumAckElicitingPacketsWritten( - numAckElicitingPacketsWritten) - .setNumBytesWritten(numBytesWritten) - .build()](auto observer, auto observed) { + [event = + SocketObserverInterface::PacketsWrittenEvent::Builder() + .setOutstandingPackets(conn_->outstandings.packets) + .setWriteCount(conn_->writeCount) + .setLastPacketSentTime( + conn_->lossState.maybeLastPacketSentTime) + .setCwndInBytes( + conn_->congestionController + ? Optional(conn_->congestionController + ->getCongestionWindow()) + : none) + .setWritableBytes( + conn_->congestionController + ? Optional(conn_->congestionController + ->getWritableBytes()) + : none) + .setNumPacketsWritten(numPacketsWritten) + .setNumAckElicitingPacketsWritten( + numAckElicitingPacketsWritten) + .setNumBytesWritten(numBytesWritten) + .build()](auto observer, auto observed) { observer->packetsWritten(observed, event); }); } @@ -3885,24 +3882,23 @@ void QuicTransportBase::notifyAppRateLimited() { getSocketObserverContainer() ->invokeInterfaceMethod< SocketObserverInterface::Events::appRateLimitedEvents>( - [event = SocketObserverInterface::AppLimitedEvent::Builder() - .setOutstandingPackets(conn_->outstandings.packets) - .setWriteCount(conn_->writeCount) - .setLastPacketSentTime( - conn_->lossState.maybeLastPacketSentTime) - .setCwndInBytes( - conn_->congestionController - ? folly::Optional( - conn_->congestionController - ->getCongestionWindow()) - : folly::none) - .setWritableBytes( - conn_->congestionController - ? folly::Optional( - conn_->congestionController - ->getWritableBytes()) - : folly::none) - .build()](auto observer, auto observed) { + [event = + SocketObserverInterface::AppLimitedEvent::Builder() + .setOutstandingPackets(conn_->outstandings.packets) + .setWriteCount(conn_->writeCount) + .setLastPacketSentTime( + conn_->lossState.maybeLastPacketSentTime) + .setCwndInBytes( + conn_->congestionController + ? Optional(conn_->congestionController + ->getCongestionWindow()) + : none) + .setWritableBytes( + conn_->congestionController + ? Optional(conn_->congestionController + ->getWritableBytes()) + : none) + .build()](auto observer, auto observed) { observer->appRateLimited(observed, event); }); } @@ -4088,14 +4084,14 @@ void QuicTransportBase::validateECNState() { } } -folly::Optional +Optional QuicTransportBase::getAdditionalCmsgsForAsyncUDPSocket() { if (conn_->socketCmsgsState.additionalCmsgs) { // This callback should be happening for the target write DCHECK(conn_->writeCount == conn_->socketCmsgsState.targetWriteCount); return conn_->socketCmsgsState.additionalCmsgs; } - return folly::none; + return none; } WriteQuicDataResult QuicTransportBase::handleInitialWriteDataCommon( diff --git a/quic/api/QuicTransportBase.h b/quic/api/QuicTransportBase.h index 42ea20d21..077145624 100644 --- a/quic/api/QuicTransportBase.h +++ b/quic/api/QuicTransportBase.h @@ -55,12 +55,11 @@ class QuicTransportBase : public QuicSocket, [[nodiscard]] std::shared_ptr getEventBase() const override; - folly::Optional getClientConnectionId() const override; + Optional getClientConnectionId() const override; - folly::Optional getServerConnectionId() const override; + Optional getServerConnectionId() const override; - folly::Optional getClientChosenDestConnectionId() - const override; + Optional getClientChosenDestConnectionId() const override; const folly::SocketAddress& getPeerAddress() const override; @@ -77,11 +76,11 @@ class QuicTransportBase : public QuicSocket, bool error() const override; - void close(folly::Optional error) override; + void close(Optional error) override; void closeGracefully() override; - void closeNow(folly::Optional error) override; + void closeNow(Optional error) override; folly::Expected getStreamReadOffset( StreamId id) const override; @@ -95,7 +94,7 @@ class QuicTransportBase : public QuicSocket, folly::Expected getStreamTransportInfo( StreamId id) const override; - folly::Optional getAppProtocol() const override; + Optional getAppProtocol() const override; void setReceiveWindow(StreamId, size_t /*recvWindowSize*/) override {} @@ -127,7 +126,7 @@ class QuicTransportBase : public QuicSocket, folly::Expected setReadCallback( StreamId id, ReadCallback* cb, - folly::Optional err = + Optional err = GenericApplicationErrorCode::NO_ERROR) override; void unsetAllReadCallbacks() override; void unsetAllPeekCallbacks() override; @@ -158,9 +157,7 @@ class QuicTransportBase : public QuicSocket, StreamId id, size_t amount) override; - folly::Expected< - folly::Unit, - std::pair>> + folly::Expected>> consume(StreamId id, uint64_t offset, size_t amount) override; folly::Expected createBidirectionalStream( @@ -218,7 +215,7 @@ class QuicTransportBase : public QuicSocket, uint64_t offset, ByteEventCallback* cb) override; - folly::Optional shutdownWrite(StreamId id) override; + Optional shutdownWrite(StreamId id) override; folly::Expected resetStream( StreamId id, @@ -254,8 +251,8 @@ class QuicTransportBase : public QuicSocket, folly::MaybeManagedPtr callback) final; void setEarlyDataAppParamsFunctions( - folly::Function&, const Buf&) - const> validator, + folly::Function&, const Buf&) const> + validator, folly::Function getter) final; bool isDetachable() override; @@ -264,7 +261,7 @@ class QuicTransportBase : public QuicSocket, void attachEventBase(std::shared_ptr evb) override; - folly::Optional setControlStream(StreamId id) override; + Optional setControlStream(StreamId id) override; /** * Set the initial flow control window for the connection. @@ -399,7 +396,7 @@ class QuicTransportBase : public QuicSocket, */ void cancelByteEventCallbacksForStream( const StreamId id, - const folly::Optional& offset = folly::none) override; + const Optional& offset = none) override; /** * Cancel byte event callbacks for given type and stream. @@ -410,7 +407,7 @@ class QuicTransportBase : public QuicSocket, void cancelByteEventCallbacksForStream( const ByteEvent::Type type, const StreamId id, - const folly::Optional& offset = folly::none) override; + const Optional& offset = none) override; /** * Cancel all byte event callbacks of all streams. @@ -746,7 +743,7 @@ class QuicTransportBase : public QuicSocket, folly::Function)> func); void closeImpl( - folly::Optional error, + Optional error, bool drainConnection = true, bool sendCloseImmediately = true); void closeUdpSocket(); @@ -760,13 +757,13 @@ class QuicTransportBase : public QuicSocket, folly::Expected setReadCallbackInternal( StreamId id, ReadCallback* cb, - folly::Optional err) noexcept; + Optional err) noexcept; folly::Expected setPeekCallbackInternal( StreamId id, PeekCallback* cb) noexcept; folly::Expected createStreamInternal( bool bidirectional, - const folly::Optional& streamGroupId = folly::none); + const Optional& streamGroupId = none); /** * write data to socket @@ -875,7 +872,7 @@ class QuicTransportBase : public QuicSocket, * The callback function for AsyncUDPSocket to provide the additional cmsgs * required by this QuicSocket's packet processors. */ - folly::Optional getAdditionalCmsgsForAsyncUDPSocket(); + Optional getAdditionalCmsgsForAsyncUDPSocket(); std::shared_ptr evb_; std::unique_ptr socket_; @@ -934,7 +931,7 @@ class QuicTransportBase : public QuicSocket, // Uninitialied local address as a fallback answer when socket isn't bound. folly::SocketAddress localFallbackAddress; - folly::Optional exceptionCloseWhat_; + Optional exceptionCloseWhat_; uint64_t qlogRefcnt_{0}; @@ -942,8 +939,8 @@ class QuicTransportBase : public QuicSocket, // If all streams have equal or lower priority to the threshold // (value >= threshold), the connection is considered to be in background // mode. - folly::Optional backgroundPriorityThreshold_; - folly::Optional backgroundUtilizationFactor_; + Optional backgroundPriorityThreshold_; + Optional backgroundUtilizationFactor_; /** * Container for use in QuicTransportBase implementations. diff --git a/quic/api/QuicTransportFunctions.cpp b/quic/api/QuicTransportFunctions.cpp index e9cafc5ea..b085b837a 100644 --- a/quic/api/QuicTransportFunctions.cpp +++ b/quic/api/QuicTransportFunctions.cpp @@ -39,8 +39,7 @@ bool cryptoHasWritableData(const quic::QuicConnectionStateBase& conn) { !conn.cryptoState->oneRttStream.lossBuffer.empty())); } -std::string optionalToString( - const folly::Optional& packetNum) { +std::string optionalToString(const quic::Optional& packetNum) { if (!packetNum) { return "-"; } @@ -54,12 +53,12 @@ std::string largestAckScheduledToString( optionalToString( conn.ackStates.initialAckState ? conn.ackStates.initialAckState->largestAckScheduled - : folly::none), + : quic::none), ",", optionalToString( conn.ackStates.handshakeAckState ? conn.ackStates.handshakeAckState->largestAckScheduled - : folly::none), + : quic::none), ",", optionalToString(conn.ackStates.appDataAckState.largestAckScheduled), "]"); @@ -72,12 +71,12 @@ std::string largestAckToSendToString( optionalToString( conn.ackStates.initialAckState ? largestAckToSend(*conn.ackStates.initialAckState) - : folly::none), + : quic::none), ",", optionalToString( conn.ackStates.handshakeAckState ? largestAckToSend(*conn.ackStates.handshakeAckState) - : folly::none), + : quic::none), ",", optionalToString(largestAckToSend(conn.ackStates.appDataAckState)), "]"); @@ -614,7 +613,7 @@ bool handleStreamBufMetaWritten( void updateConnection( QuicConnectionStateBase& conn, - folly::Optional packetEvent, + Optional packetEvent, RegularQuicWritePacket packet, TimePoint sentTime, uint32_t encodedSize, @@ -1198,7 +1197,7 @@ void writeCloseCommon( QuicAsyncUDPSocket& sock, QuicConnectionStateBase& connection, PacketHeader&& header, - folly::Optional closeDetails, + Optional closeDetails, const Aead& aead, const PacketNumberCipher& headerCipher) { // close is special, we're going to bypass all the packet sent logic for all @@ -1303,7 +1302,7 @@ void writeLongClose( const ConnectionId& srcConnId, const ConnectionId& dstConnId, LongHeader::Types headerType, - folly::Optional closeDetails, + Optional closeDetails, const Aead& aead, const PacketNumberCipher& headerCipher, QuicVersion version) { @@ -1332,7 +1331,7 @@ void writeShortClose( QuicAsyncUDPSocket& sock, QuicConnectionStateBase& connection, const ConnectionId& connId, - folly::Optional closeDetails, + Optional closeDetails, const Aead& aead, const PacketNumberCipher& headerCipher) { auto header = ShortHeader( diff --git a/quic/api/QuicTransportFunctions.h b/quic/api/QuicTransportFunctions.h index 209487c8d..2d177065e 100644 --- a/quic/api/QuicTransportFunctions.h +++ b/quic/api/QuicTransportFunctions.h @@ -24,7 +24,7 @@ namespace quic { struct DataPathResult { bool buildSuccess{false}; bool writeSuccess{false}; - folly::Optional result; + Optional result; uint64_t encodedSize{0}; uint64_t encodedBodySize{0}; @@ -202,7 +202,7 @@ bool handleStreamBufMetaWritten( */ void updateConnection( QuicConnectionStateBase& conn, - folly::Optional packetEvent, + Optional packetEvent, RegularQuicWritePacket packet, TimePoint time, uint32_t encodedSize, @@ -229,7 +229,7 @@ void writeCloseCommon( QuicAsyncUDPSocket& sock, QuicConnectionStateBase& connection, PacketHeader&& header, - folly::Optional closeDetails, + Optional closeDetails, const Aead& aead, const PacketNumberCipher& headerCipher); @@ -243,7 +243,7 @@ void writeLongClose( const ConnectionId& srcConnId, const ConnectionId& dstConnId, LongHeader::Types headerType, - folly::Optional closeDetails, + Optional closeDetails, const Aead& aead, const PacketNumberCipher& headerCipher, QuicVersion); @@ -256,7 +256,7 @@ void writeShortClose( QuicAsyncUDPSocket& sock, QuicConnectionStateBase& connection, const ConnectionId& connId, - folly::Optional closeDetails, + Optional closeDetails, const Aead& aead, const PacketNumberCipher& headerCipher); diff --git a/quic/api/test/MockQuicSocket.h b/quic/api/test/MockQuicSocket.h index bbbbc4f98..8bbc2a853 100644 --- a/quic/api/test/MockQuicSocket.h +++ b/quic/api/test/MockQuicSocket.h @@ -29,22 +29,14 @@ class MockQuicSocket : public QuicSocket { MOCK_METHOD(bool, good, (), (const)); MOCK_METHOD(bool, replaySafe, (), (const)); MOCK_METHOD(bool, error, (), (const)); - MOCK_METHOD(void, close, (folly::Optional)); + MOCK_METHOD(void, close, (Optional)); MOCK_METHOD(void, closeGracefully, ()); - MOCK_METHOD(void, closeNow, (folly::Optional)); - MOCK_METHOD( - folly::Optional, - getClientConnectionId, - (), - (const)); + MOCK_METHOD(void, closeNow, (Optional)); + MOCK_METHOD(Optional, getClientConnectionId, (), (const)); MOCK_METHOD(const TransportSettings&, getTransportSettings, (), (const)); + MOCK_METHOD(Optional, getServerConnectionId, (), (const)); MOCK_METHOD( - folly::Optional, - getServerConnectionId, - (), - (const)); - MOCK_METHOD( - folly::Optional, + Optional, getClientChosenDestConnectionId, (), (const)); @@ -52,14 +44,14 @@ class MockQuicSocket : public QuicSocket { MOCK_METHOD(const folly::SocketAddress&, getOriginalPeerAddress, (), (const)); MOCK_METHOD(const folly::SocketAddress&, getLocalAddress, (), (const)); MOCK_METHOD( - folly::Optional>, + Optional>, getPeerTransportParams, (), (const)); MOCK_METHOD( - (folly::Optional>), + (Optional>), getExportedKeyingMaterial, - (const std::string&, const folly::Optional&, uint16_t), + (const std::string&, const Optional&, uint16_t), (const)); MOCK_METHOD(std::shared_ptr, getEventBase, (), (const)); MOCK_METHOD( @@ -83,7 +75,7 @@ class MockQuicSocket : public QuicSocket { getStreamTransportInfo, (StreamId), (const)); - MOCK_METHOD(folly::Optional, getAppProtocol, (), (const)); + MOCK_METHOD(Optional, getAppProtocol, (), (const)); MOCK_METHOD(void, setReceiveWindow, (StreamId, size_t)); MOCK_METHOD(void, setSendBuffer, (StreamId, size_t, size_t)); MOCK_METHOD(uint64_t, getConnectionBufferAvailable, (), (const)); @@ -144,7 +136,7 @@ class MockQuicSocket : public QuicSocket { MOCK_METHOD( (folly::Expected), setReadCallback, - (StreamId, ReadCallback*, folly::Optional err)); + (StreamId, ReadCallback*, Optional err)); MOCK_METHOD( void, setConnectionSetupCallback, @@ -154,8 +146,8 @@ class MockQuicSocket : public QuicSocket { setConnectionCallback, (folly::MaybeManagedPtr)); void setEarlyDataAppParamsFunctions( - folly::Function&, const Buf&) - const> validator, + folly::Function&, const Buf&) const> + validator, folly::Function getter) override { earlyDataAppParamsValidator_ = std::move(validator); earlyDataAppParamsGetter_ = std::move(getter); @@ -231,13 +223,13 @@ class MockQuicSocket : public QuicSocket { MOCK_METHOD( void, cancelByteEventCallbacksForStream, - (const StreamId id, const folly::Optional& offset)); + (const StreamId id, const Optional& offset)); MOCK_METHOD( void, cancelByteEventCallbacksForStream, (const ByteEvent::Type, const StreamId id, - const folly::Optional& offset)); + const Optional& offset)); MOCK_METHOD(void, cancelAllByteEventCallbacks, ()); MOCK_METHOD(void, cancelByteEventCallbacks, (const ByteEvent::Type)); MOCK_METHOD( @@ -271,7 +263,7 @@ class MockQuicSocket : public QuicSocket { (folly::Expected), registerDeliveryCallback, (StreamId, uint64_t, ByteEventCallback*)); - MOCK_METHOD(folly::Optional, shutdownWrite, (StreamId)); + MOCK_METHOD(Optional, shutdownWrite, (StreamId)); MOCK_METHOD( (folly::Expected), resetStream, @@ -289,7 +281,7 @@ class MockQuicSocket : public QuicSocket { MOCK_METHOD(bool, isDetachable, ()); MOCK_METHOD(void, attachEventBase, (std::shared_ptr)); MOCK_METHOD(void, detachEventBase, ()); - MOCK_METHOD(folly::Optional, setControlStream, (StreamId)); + MOCK_METHOD(Optional, setControlStream, (StreamId)); MOCK_METHOD( (folly::Expected), @@ -315,7 +307,7 @@ class MockQuicSocket : public QuicSocket { MOCK_METHOD( (folly::Expected< folly::Unit, - std::pair>>), + std::pair>>), consume, (StreamId, uint64_t, size_t)); MOCK_METHOD( @@ -335,7 +327,7 @@ class MockQuicSocket : public QuicSocket { ConnectionSetupCallback* setupCb_{nullptr}; ConnectionCallback* connCb_{nullptr}; - folly::Function&, const Buf&)> + folly::Function&, const Buf&)> earlyDataAppParamsValidator_; folly::Function earlyDataAppParamsGetter_; diff --git a/quic/api/test/Mocks.h b/quic/api/test/Mocks.h index f8f8d9344..ea351666a 100644 --- a/quic/api/test/Mocks.h +++ b/quic/api/test/Mocks.h @@ -257,16 +257,12 @@ class MockQuicTransport : public QuicServerTransport { setServerConnectionIdParams, (ServerConnectionIdParams), (noexcept)); - MOCK_METHOD((void), close, (folly::Optional), (noexcept)); - MOCK_METHOD((void), closeNow, (folly::Optional), (noexcept)); + MOCK_METHOD((void), close, (Optional), (noexcept)); + MOCK_METHOD((void), closeNow, (Optional), (noexcept)); MOCK_METHOD((bool), hasShutdown, (), (const)); + MOCK_METHOD((Optional), getClientConnectionId, (), (const)); MOCK_METHOD( - (folly::Optional), - getClientConnectionId, - (), - (const)); - MOCK_METHOD( - (folly::Optional), + (Optional), getClientChosenDestConnectionId, (), (const)); diff --git a/quic/api/test/QuicPacketSchedulerTest.cpp b/quic/api/test/QuicPacketSchedulerTest.cpp index 35caa6ef4..109840c19 100644 --- a/quic/api/test/QuicPacketSchedulerTest.cpp +++ b/quic/api/test/QuicPacketSchedulerTest.cpp @@ -800,7 +800,7 @@ TEST_F(QuicPacketSchedulerTest, CloneSchedulerUseNormalSchedulerFirst) { folly::IOBuf( folly::IOBuf::CopyBufferOp::COPY_BUFFER, "I'm out of the game")); - return SchedulingResult(folly::none, std::move(builtPacket)); + return SchedulingResult(none, std::move(builtPacket)); })); RegularQuicPacketBuilder builder( conn.udpSendPacketLen, @@ -808,7 +808,7 @@ TEST_F(QuicPacketSchedulerTest, CloneSchedulerUseNormalSchedulerFirst) { conn.ackStates.appDataAckState.largestAckedByPeer.value_or(0)); auto result = cloningScheduler.scheduleFramesForPacket( std::move(builder), kDefaultUDPSendPacketLen); - EXPECT_EQ(folly::none, result.packetEvent); + EXPECT_EQ(none, result.packetEvent); EXPECT_EQ(result.packet->packet.header.getHeaderForm(), HeaderForm::Short); ShortHeader& shortHeader = *result.packet->packet.header.asShort(); EXPECT_EQ(ProtectionType::KeyPhaseOne, shortHeader.getProtectionType()); @@ -989,7 +989,7 @@ TEST_F(QuicPacketSchedulerTest, CloningSchedulerWithInplaceBuilderFullPacket) { EXPECT_EQ(conn.udpSendPacketLen, bufferLength); updateConnection( conn, - folly::none, + none, result.packet->packet, Clock::now(), bufferLength, @@ -1061,7 +1061,7 @@ TEST_F(QuicPacketSchedulerTest, CloneLargerThanOriginalPacket) { EXPECT_EQ(encodedSize, conn.udpSendPacketLen); updateConnection( conn, - folly::none, + none, packetResult.packet->packet, Clock::now(), encodedSize, @@ -1103,7 +1103,7 @@ TEST_F(QuicPacketSchedulerTest, AckStateHasAcksToSchedule) { conn.ackStates.handshakeAckState->largestAckScheduled = 200; EXPECT_FALSE(hasAcksToSchedule(*conn.ackStates.handshakeAckState)); - conn.ackStates.handshakeAckState->largestAckScheduled = folly::none; + conn.ackStates.handshakeAckState->largestAckScheduled = none; EXPECT_TRUE(hasAcksToSchedule(*conn.ackStates.handshakeAckState)); } @@ -1127,16 +1127,16 @@ TEST_F(QuicPacketSchedulerTest, AckSchedulerHasAcksToSchedule) { conn.ackStates.handshakeAckState->largestAckScheduled = 200; EXPECT_FALSE(handshakeAckScheduler.hasPendingAcks()); - conn.ackStates.handshakeAckState->largestAckScheduled = folly::none; + conn.ackStates.handshakeAckState->largestAckScheduled = none; EXPECT_TRUE(handshakeAckScheduler.hasPendingAcks()); } TEST_F(QuicPacketSchedulerTest, LargestAckToSend) { QuicClientConnectionState conn( FizzClientQuicHandshakeContext::Builder().build()); - EXPECT_EQ(folly::none, largestAckToSend(*conn.ackStates.initialAckState)); - EXPECT_EQ(folly::none, largestAckToSend(*conn.ackStates.handshakeAckState)); - EXPECT_EQ(folly::none, largestAckToSend(conn.ackStates.appDataAckState)); + EXPECT_EQ(none, largestAckToSend(*conn.ackStates.initialAckState)); + EXPECT_EQ(none, largestAckToSend(*conn.ackStates.handshakeAckState)); + EXPECT_EQ(none, largestAckToSend(conn.ackStates.appDataAckState)); conn.ackStates.initialAckState->acks.insert(0, 50); conn.ackStates.handshakeAckState->acks.insert(0, 50); @@ -1144,7 +1144,7 @@ TEST_F(QuicPacketSchedulerTest, LargestAckToSend) { EXPECT_EQ(50, *largestAckToSend(*conn.ackStates.initialAckState)); EXPECT_EQ(150, *largestAckToSend(*conn.ackStates.handshakeAckState)); - EXPECT_EQ(folly::none, largestAckToSend(conn.ackStates.appDataAckState)); + EXPECT_EQ(none, largestAckToSend(conn.ackStates.appDataAckState)); } TEST_F(QuicPacketSchedulerTest, NeedsToSendAckWithoutAcksAvailable) { @@ -1172,7 +1172,7 @@ TEST_F(QuicPacketSchedulerTest, NeedsToSendAckWithoutAcksAvailable) { conn.ackStates.handshakeAckState->largestAckScheduled = 200; EXPECT_FALSE(handshakeAckScheduler.hasPendingAcks()); - conn.ackStates.handshakeAckState->largestAckScheduled = folly::none; + conn.ackStates.handshakeAckState->largestAckScheduled = none; EXPECT_TRUE(handshakeAckScheduler.hasPendingAcks()); } @@ -1964,7 +1964,7 @@ TEST_F(QuicPacketSchedulerTest, WriteLossWithoutFlowControl) { scheduler.writeStreams(builder1); auto packet1 = std::move(builder1).buildPacket().packet; updateConnection( - conn, folly::none, packet1, Clock::now(), 1000, 0, false /* isDSR */); + conn, none, packet1, Clock::now(), 1000, 0, false /* isDSR */); EXPECT_EQ(1, packet1.frames.size()); auto& writeStreamFrame1 = *packet1.frames[0].asWriteStreamFrame(); EXPECT_EQ(streamId, writeStreamFrame1.streamId); @@ -1992,7 +1992,7 @@ TEST_F(QuicPacketSchedulerTest, WriteLossWithoutFlowControl) { scheduler.writeStreams(builder2); auto packet2 = std::move(builder2).buildPacket().packet; updateConnection( - conn, folly::none, packet2, Clock::now(), 1000, 0, false /* isDSR */); + conn, none, packet2, Clock::now(), 1000, 0, false /* isDSR */); EXPECT_EQ(1, packet2.frames.size()); auto& writeStreamFrame2 = *packet2.frames[0].asWriteStreamFrame(); EXPECT_EQ(streamId, writeStreamFrame2.streamId); @@ -2036,7 +2036,7 @@ TEST_F(QuicPacketSchedulerTest, WriteLossWithoutFlowControlIgnoreDSR) { scheduler.writeStreams(builder1); auto packet1 = std::move(builder1).buildPacket().packet; updateConnection( - conn, folly::none, packet1, Clock::now(), 1000, 0, false /* isDSR */); + conn, none, packet1, Clock::now(), 1000, 0, false /* isDSR */); EXPECT_EQ(1, packet1.frames.size()); auto& writeStreamFrame1 = *packet1.frames[0].asWriteStreamFrame(); EXPECT_EQ(streamId, writeStreamFrame1.streamId); @@ -2076,7 +2076,7 @@ TEST_F(QuicPacketSchedulerTest, WriteLossWithoutFlowControlSequential) { scheduler.writeStreams(builder1); auto packet1 = std::move(builder1).buildPacket().packet; updateConnection( - conn, folly::none, packet1, Clock::now(), 1000, 0, false /* isDSR */); + conn, none, packet1, Clock::now(), 1000, 0, false /* isDSR */); EXPECT_EQ(1, packet1.frames.size()); auto& writeStreamFrame1 = *packet1.frames[0].asWriteStreamFrame(); EXPECT_EQ(streamId, writeStreamFrame1.streamId); @@ -2104,7 +2104,7 @@ TEST_F(QuicPacketSchedulerTest, WriteLossWithoutFlowControlSequential) { scheduler.writeStreams(builder2); auto packet2 = std::move(builder2).buildPacket().packet; updateConnection( - conn, folly::none, packet2, Clock::now(), 1000, 0, false /* isDSR */); + conn, none, packet2, Clock::now(), 1000, 0, false /* isDSR */); EXPECT_EQ(1, packet2.frames.size()); auto& writeStreamFrame2 = *packet2.frames[0].asWriteStreamFrame(); EXPECT_EQ(streamId, writeStreamFrame2.streamId); @@ -2149,7 +2149,7 @@ TEST_F(QuicPacketSchedulerTest, RunOutFlowControlDuringStreamWrite) { scheduler.writeStreams(builder1); auto packet1 = std::move(builder1).buildPacket().packet; updateConnection( - conn, folly::none, packet1, Clock::now(), 1200, 0, false /* isDSR */); + conn, none, packet1, Clock::now(), 1200, 0, false /* isDSR */); ASSERT_EQ(2, packet1.frames.size()); auto& writeStreamFrame1 = *packet1.frames[0].asWriteStreamFrame(); EXPECT_EQ(streamId1, writeStreamFrame1.streamId); diff --git a/quic/api/test/QuicStreamAsyncTransportTest.cpp b/quic/api/test/QuicStreamAsyncTransportTest.cpp index bb9127b90..bd6f57359 100644 --- a/quic/api/test/QuicStreamAsyncTransportTest.cpp +++ b/quic/api/test/QuicStreamAsyncTransportTest.cpp @@ -178,7 +178,7 @@ class QuicStreamAsyncTransportTest : public Test { void TearDown() override { if (client_) { - client_->close(folly::none); + client_->close(none); } clientEvb_.loop(); server_->shutdown(); diff --git a/quic/api/test/QuicTransportBaseTest.cpp b/quic/api/test/QuicTransportBaseTest.cpp index bb88263a3..92dab361b 100644 --- a/quic/api/test/QuicTransportBaseTest.cpp +++ b/quic/api/test/QuicTransportBaseTest.cpp @@ -52,7 +52,7 @@ enum class TestFrameType : uint8_t { Buf encodeStreamBuffer( StreamId id, StreamBuffer data, - folly::Optional groupId = folly::none) { + Optional groupId = none) { auto buf = IOBuf::create(10); folly::io::Appender appender(buf.get(), 10); if (!groupId) { @@ -262,9 +262,9 @@ class TestQuicTransport closeUdpSocket(); } - folly::Optional> getPeerTransportParams() + Optional> getPeerTransportParams() const override { - return folly::none; + return none; } std::chrono::milliseconds getLossTimeoutRemainingTime() { @@ -406,7 +406,7 @@ class TestQuicTransport void addDataToStream( StreamId id, StreamBuffer data, - folly::Optional groupId = folly::none) { + Optional groupId = none) { auto buf = encodeStreamBuffer(id, std::move(data), std::move(groupId)); SocketAddress addr("127.0.0.1", 1000); onNetworkData(addr, NetworkData(std::move(buf), Clock::now(), 0)); @@ -509,7 +509,7 @@ class TestQuicTransport } void closeWithoutWrite() { - closeImpl(folly::none, false, false); + closeImpl(none, false, false); } void invokeWriteSocketData() { @@ -559,11 +559,11 @@ class TestQuicTransport return observerContainer_.get(); } - folly::Optional> getExportedKeyingMaterial( + Optional> getExportedKeyingMaterial( const std::string&, - const folly::Optional&, + const Optional&, uint16_t) const override { - return folly::none; + return none; } void updateWriteLooper(bool thisIteration) { @@ -1813,7 +1813,7 @@ TEST_P(QuicTransportImplTestBase, CloseStreamAfterReadFin) { TEST_P(QuicTransportImplTestBase, CloseTransportCleansupOutstandingCounters) { transport->transportConn->outstandings .packetCount[PacketNumberSpace::Handshake] = 200; - transport->closeNow(folly::none); + transport->closeNow(none); EXPECT_EQ( 0, transport->transportConn->outstandings @@ -1837,7 +1837,7 @@ TEST_P(QuicTransportImplTestBase, DeliveryCallbackUnsetAll) { EXPECT_CALL(dcb1, onCanceled(_, _)).Times(0); EXPECT_CALL(dcb2, onCanceled(_, _)).Times(0); - transport->close(folly::none); + transport->close(none); } TEST_P(QuicTransportImplTestBase, DeliveryCallbackUnsetOne) { @@ -1857,7 +1857,7 @@ TEST_P(QuicTransportImplTestBase, DeliveryCallbackUnsetOne) { EXPECT_CALL(dcb1, onCanceled(_, _)).Times(0); EXPECT_CALL(dcb2, onCanceled(_, _)); - transport->close(folly::none); + transport->close(none); } TEST_P(QuicTransportImplTestBase, ByteEventCallbacksManagementSingleStream) { @@ -2049,7 +2049,7 @@ TEST_P(QuicTransportImplTestBase, RegisterTxDeliveryCallbackLowerThanExpected) { EXPECT_CALL(txcb2, onByteEventCanceled(getTxMatcher(stream, 20))); EXPECT_CALL(dcb1, onCanceled(_, _)); EXPECT_CALL(dcb2, onCanceled(_, _)); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(&txcb1); Mock::VerifyAndClearExpectations(&txcb2); Mock::VerifyAndClearExpectations(&txcb3); @@ -2072,7 +2072,7 @@ TEST_F( EXPECT_CALL(dcb, onCanceled(_, _)); transport->registerTxCallback(stream, 2, &txcb); transport->registerDeliveryCallback(stream, 2, &dcb); - transport->close(folly::none); + transport->close(none); qEvb->loopOnce(); Mock::VerifyAndClearExpectations(&txcb); Mock::VerifyAndClearExpectations(&dcb); @@ -2269,7 +2269,7 @@ TEST_P(QuicTransportImplTestBase, RegisterDeliveryCallbackAsyncDeliveryTx) { Mock::VerifyAndClearExpectations(&txcb2); EXPECT_CALL(txcb2, onByteEventCanceled(getTxMatcher(stream, 10))); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(&txcb2); } @@ -2315,7 +2315,7 @@ TEST_P(QuicTransportImplTestBase, RegisterDeliveryCallbackAsyncDeliveryAck) { Mock::VerifyAndClearExpectations(&txcb2); EXPECT_CALL(txcb2, onByteEventCanceled(getAckMatcher(stream, 10))); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(&txcb2); } @@ -2389,7 +2389,7 @@ TEST_P(QuicTransportImplTestBase, CancelAllByteEventCallbacks) { EXPECT_CALL(dcb1, onCanceled(_, _)).Times(0); EXPECT_CALL(dcb2, onCanceled(_, _)).Times(0); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(&txcb1); Mock::VerifyAndClearExpectations(&txcb2); Mock::VerifyAndClearExpectations(&dcb1); @@ -2465,7 +2465,7 @@ TEST_P(QuicTransportImplTestBase, CancelByteEventCallbacksForStream) { EXPECT_CALL(dcb1, onCanceled(stream1, _)).Times(0); EXPECT_CALL(dcb2, onCanceled(_, 20)); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(&txcb1); Mock::VerifyAndClearExpectations(&txcb2); Mock::VerifyAndClearExpectations(&dcb1); @@ -2624,7 +2624,7 @@ TEST_P(QuicTransportImplTestBase, CancelByteEventCallbacksForStreamWithOffset) { EXPECT_CALL(dcb2, onCanceled(stream2, 15)); EXPECT_CALL(dcb2, onCanceled(stream2, 20)); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(&txcb1); Mock::VerifyAndClearExpectations(&txcb2); Mock::VerifyAndClearExpectations(&dcb1); @@ -2725,7 +2725,7 @@ TEST_P(QuicTransportImplTestBase, CancelByteEventCallbacksTx) { EXPECT_CALL(dcb2, onCanceled(stream2, 10)); EXPECT_CALL(dcb2, onCanceled(stream2, 15)); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(&txcb1); Mock::VerifyAndClearExpectations(&txcb2); Mock::VerifyAndClearExpectations(&dcb1); @@ -2807,7 +2807,7 @@ TEST_P(QuicTransportImplTestBase, CancelByteEventCallbacksDelivery) { EXPECT_CALL(txcb2, onByteEventCanceled(getTxMatcher(stream2, 10))); EXPECT_CALL(txcb2, onByteEventCanceled(getTxMatcher(stream2, 15))); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(&txcb1); Mock::VerifyAndClearExpectations(&txcb2); Mock::VerifyAndClearExpectations(&dcb1); @@ -2822,7 +2822,7 @@ TEST_P( wcb, onConnectionWriteError(IsError(GenericApplicationErrorCode::NO_ERROR))); transport->notifyPendingWriteOnConnection(&wcb); - transport->close(folly::none); + transport->close(none); qEvb->loopOnce(); } @@ -2838,7 +2838,7 @@ TEST_P(QuicTransportImplTestClose, TestNotifyPendingConnWriteOnCloseWithError) { QuicErrorCode(GenericApplicationErrorCode::UNKNOWN), std::string("Bye"))); } else { - transport->close(folly::none); + transport->close(none); } qEvb->loopOnce(); } @@ -2862,7 +2862,7 @@ TEST_P(QuicTransportImplTestBase, TestNotifyPendingWriteOnCloseWithoutError) { onStreamWriteError( stream, IsError(GenericApplicationErrorCode::NO_ERROR))); transport->notifyPendingWriteOnStream(stream, &wcb); - transport->close(folly::none); + transport->close(none); qEvb->loopOnce(); } @@ -2879,7 +2879,7 @@ TEST_P(QuicTransportImplTestClose, TestNotifyPendingWriteOnCloseWithError) { QuicErrorCode(GenericApplicationErrorCode::UNKNOWN), std::string("Bye"))); } else { - transport->close(folly::none); + transport->close(none); } qEvb->loopOnce(); } @@ -2985,7 +2985,7 @@ TEST_P(QuicTransportImplTestBase, TestGracefulCloseWithNoActiveStream) { transport->transportConn->streamManager->addTx(stream); transport->transportConn->streamManager->addDeliverable(stream); transport->closeStream(stream); - transport->close(folly::none); + transport->close(none); ASSERT_TRUE(transport->transportClosed); EXPECT_FALSE(transport->createBidirectionalStream()); @@ -3879,7 +3879,7 @@ TEST_P(QuicTransportImplTestBase, StreamWriteCallbackUnregister) { EXPECT_TRUE(transport->unregisterStreamWriteCallback(stream)); wcb.reset(); })); - transport->close(folly::none); + transport->close(none); qEvb->loopOnce(); } @@ -3991,7 +3991,7 @@ TEST_P(QuicTransportImplTestBase, ObserverDetachAfterClose) { EXPECT_CALL(*cb, closeStarted(transport.get(), _)); EXPECT_CALL(*cb, closing(transport.get(), _)); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(cb.get()); EXPECT_CALL(*cb, observerDetach(transport.get())); diff --git a/quic/api/test/QuicTransportFunctionsTest.cpp b/quic/api/test/QuicTransportFunctionsTest.cpp index 2586aab50..cd0081d0c 100644 --- a/quic/api/test/QuicTransportFunctionsTest.cpp +++ b/quic/api/test/QuicTransportFunctionsTest.cpp @@ -104,7 +104,7 @@ auto buildEmptyPacket( QuicServerConnectionState& conn, PacketNumberSpace pnSpace, bool shortHeader = false) { - folly::Optional header; + Optional header; if (shortHeader) { header = ShortHeader( ProtectionType::KeyPhaseZero, @@ -211,13 +211,7 @@ TEST_F(QuicTransportFunctionsTest, PingPacketGoesToOPList) { packet.packet.frames.push_back(PingFrame()); EXPECT_EQ(0, conn->outstandings.packets.size()); updateConnection( - *conn, - folly::none, - packet.packet, - Clock::now(), - 50, - 0, - false /* isDSRPacket */); + *conn, none, packet.packet, Clock::now(), 50, 0, false /* isDSRPacket */); EXPECT_EQ(1, conn->outstandings.packets.size()); // But it won't set loss detection alarm EXPECT_FALSE(conn->pendingEvents.setLossDetectionAlarm); @@ -262,7 +256,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) { .WillOnce(Return(true)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint{}, getEncodedSize(packet), @@ -324,7 +318,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnection) { .WillOnce(Return(false)); updateConnection( *conn, - folly::none, + none, packet2.packet, TimePoint(), getEncodedSize(packet2), @@ -443,7 +437,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketRetrans) { .WillOnce(Return(true)); updateConnection( *conn, - folly::none, + none, packet1.packet, TimePoint{}, getEncodedSize(packet1), @@ -505,7 +499,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketRetrans) { .WillOnce(Return(false)); updateConnection( *conn, - folly::none, + none, packet2.packet, TimePoint(), getEncodedSize(packet2), @@ -611,7 +605,7 @@ TEST_F( .WillOnce(Return(true)); updateConnection( *conn, - folly::none, + none, packet1.packet, TimePoint{}, getEncodedSize(packet1), @@ -694,7 +688,7 @@ TEST_F( .WillOnce(Return(false)); updateConnection( *conn, - folly::none, + none, packet2.packet, TimePoint(), getEncodedSize(packet2), @@ -761,7 +755,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketSorting) { updateConnection( *conn, - folly::none, + none, handshakePacket.packet, TimePoint{}, getEncodedSize(handshakePacket), @@ -769,7 +763,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketSorting) { false /* isDSRPacket */); updateConnection( *conn, - folly::none, + none, initialPacket.packet, TimePoint{}, getEncodedSize(initialPacket), @@ -777,7 +771,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPacketSorting) { false /* isDSRPacket */); updateConnection( *conn, - folly::none, + none, appDataPacket.packet, TimePoint{}, getEncodedSize(appDataPacket), @@ -829,7 +823,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionFinOnly) { packet.packet.frames.push_back(WriteStreamFrame(stream1->id, 0, 0, true)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -880,7 +874,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionAllBytesExceptFin) { WriteStreamFrame(stream1->id, 0, buf->computeChainDataLength(), false)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -930,7 +924,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionEmptyAckWriteResult) { conn->ackStates.handshakeAckState->largestAckScheduled; updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -968,7 +962,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPureAckCounter) { packet.packet.frames.push_back(std::move(ackFrame)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -987,7 +981,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionPureAckCounter) { updateConnection( *conn, - folly::none, + none, packet2.packet, TimePoint(), getEncodedSize(packet), @@ -1020,7 +1014,7 @@ TEST_F(QuicTransportFunctionsTest, TestPaddingPureAckPacketIsStillPureAck) { packet.packet.frames.push_back(PaddingFrame()); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1057,7 +1051,7 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) { initialStream->writeBuffer.append(data->clone()); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1077,7 +1071,7 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) { initialStream->writeBuffer.append(data->clone()); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1108,7 +1102,7 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) { handshakeStream->writeBuffer.append(data->clone()); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1125,7 +1119,7 @@ TEST_F(QuicTransportFunctionsTest, TestImplicitAck) { handshakeStream->writeBuffer.append(data->clone()); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1183,7 +1177,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) { packet.packet.frames.push_back(WriteCryptoFrame(0, 0)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1205,7 +1199,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) { WriteStreamFrame(stream1->id, 0, 0, true)); updateConnection( *conn, - folly::none, + none, nonHandshake.packet, TimePoint(), getEncodedSize(packet), @@ -1259,7 +1253,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionForOneRttCryptoData) { packet.packet.frames.push_back(WriteCryptoFrame(0, 0)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1277,7 +1271,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionForOneRttCryptoData) { WriteStreamFrame(stream1->id, 0, 0, true)); updateConnection( *conn, - folly::none, + none, nonHandshake.packet, TimePoint(), getEncodedSize(packet), @@ -1341,7 +1335,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithPureAck) { EXPECT_CALL(*rawPacer, onPacketSent()).Times(0); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1391,7 +1385,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithBytesStats) { conn->lossState.totalAckElicitingPacketsSent = 15; updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), 555, @@ -1478,7 +1472,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionWithAppLimitedStats) { // record the packet as having been sent updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), 555, @@ -1536,7 +1530,7 @@ TEST_F( // record the packet as having been sent updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), 555, @@ -1628,7 +1622,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionStreamWindowUpdate) { packet.packet.frames.push_back(std::move(streamWindowUpdate)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1664,7 +1658,7 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionConnWindowUpdate) { packet.packet.frames.push_back(std::move(connWindowUpdate)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1694,7 +1688,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsEmptyPacket) { auto packet = buildEmptyPacket(*conn, PacketNumberSpace::AppData); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1714,7 +1708,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsNoStreamsInPacket) { packet.packet.frames.push_back(PingFrame()); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1742,7 +1736,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStream) { packet.packet.frames.push_back(writeStreamFrame); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1756,7 +1750,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStream) { testing::Field(&PacketStreamDetails::newStreamBytesSent, frameLen), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(frameOffset)), + Optional(frameOffset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -1784,7 +1778,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamMultipleFrames) { packet.packet.frames.push_back(writeStreamFrame2); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1798,7 +1792,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamMultipleFrames) { testing::Field(&PacketStreamDetails::newStreamBytesSent, 15), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(0)), + Optional(0)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval(0, 14))))); @@ -1824,7 +1818,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamRetransmit) { packet.packet.frames.push_back(frame1); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1842,7 +1836,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamRetransmit) { testing::Field(&PacketStreamDetails::newStreamBytesSent, frame1Len), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(frame1Offset)), + Optional(frame1Offset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -1861,7 +1855,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamRetransmit) { packet.packet.frames.push_back(frame1); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1879,7 +1873,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamRetransmit) { testing::Field(&PacketStreamDetails::newStreamBytesSent, 0), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(/* empty */)), + Optional(/* empty */)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -1904,7 +1898,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamRetransmit) { packet.packet.frames.push_back(frame2); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1923,7 +1917,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamRetransmit) { testing::Field(&PacketStreamDetails::newStreamBytesSent, frame2Len), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(frame2Offset)), + Optional(frame2Offset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -1943,7 +1937,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamRetransmit) { packet.packet.frames.push_back(frame2); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -1962,7 +1956,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamRetransmit) { testing::Field(&PacketStreamDetails::newStreamBytesSent, 0), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(/* empty */)), + Optional(/* empty */)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -1992,7 +1986,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamFinWithRetransmit) { packet1.packet.frames.push_back(frame1); updateConnection( *conn, - folly::none, + none, packet1.packet, TimePoint(), getEncodedSize(packet1), @@ -2006,7 +2000,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamFinWithRetransmit) { packet2.packet.frames.push_back(frame2); updateConnection( *conn, - folly::none, + none, packet2.packet, TimePoint(), getEncodedSize(packet2), @@ -2025,7 +2019,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamFinWithRetransmit) { &PacketStreamDetails::newStreamBytesSent, frameLen), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(frameOffset)), + Optional(frameOffset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -2056,7 +2050,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamFinWithRetransmit) { packet3.packet.frames.push_back(frame2); updateConnection( *conn, - folly::none, + none, packet3.packet, TimePoint(), getEncodedSize(packet3), @@ -2075,7 +2069,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsSingleStreamFinWithRetransmit) { testing::Field(&PacketStreamDetails::newStreamBytesSent, 0), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(/* empty */)), + Optional(/* empty */)), testing::Field( &PacketStreamDetails::streamIntervals, // contains frame1 and frame2 @@ -2108,7 +2102,7 @@ TEST_F( packet1.packet.frames.push_back(frame1); updateConnection( *conn, - folly::none, + none, packet1.packet, TimePoint(), getEncodedSize(packet1), @@ -2123,7 +2117,7 @@ TEST_F( packet2.packet.frames.push_back(frame2); updateConnection( *conn, - folly::none, + none, packet2.packet, TimePoint(), getEncodedSize(packet2), @@ -2138,7 +2132,7 @@ TEST_F( packet3.packet.frames.push_back(frame3); updateConnection( *conn, - folly::none, + none, packet3.packet, TimePoint(), getEncodedSize(packet3), @@ -2157,7 +2151,7 @@ TEST_F( &PacketStreamDetails::newStreamBytesSent, frameLen), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(frameOffset)), + Optional(frameOffset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -2197,7 +2191,7 @@ TEST_F( packet4.packet.frames.push_back(frame3); updateConnection( *conn, - folly::none, + none, packet4.packet, TimePoint(), getEncodedSize(packet4), @@ -2214,7 +2208,7 @@ TEST_F( testing::Field(&PacketStreamDetails::newStreamBytesSent, 0), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(/* empty */)), + Optional(/* empty */)), testing::Field( &PacketStreamDetails::streamIntervals, // contains frame1 and frame 3 @@ -2250,7 +2244,7 @@ TEST_F( packet1.packet.frames.push_back(frame1); updateConnection( *conn, - folly::none, + none, packet1.packet, TimePoint(), getEncodedSize(packet1), @@ -2266,7 +2260,7 @@ TEST_F( packet2.packet.frames.push_back(frame2); updateConnection( *conn, - folly::none, + none, packet2.packet, TimePoint(), getEncodedSize(packet2), @@ -2282,7 +2276,7 @@ TEST_F( packet3.packet.frames.push_back(frame3); updateConnection( *conn, - folly::none, + none, packet3.packet, TimePoint(), getEncodedSize(packet3), @@ -2301,7 +2295,7 @@ TEST_F( &PacketStreamDetails::newStreamBytesSent, frameLen), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(frameOffset)), + Optional(frameOffset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -2341,7 +2335,7 @@ TEST_F( packet4.packet.frames.push_back(frame3); updateConnection( *conn, - folly::none, + none, packet4.packet, TimePoint(), getEncodedSize(packet4), @@ -2358,7 +2352,7 @@ TEST_F( testing::Field(&PacketStreamDetails::newStreamBytesSent, 0), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(/* empty */)), + Optional(/* empty */)), testing::Field( &PacketStreamDetails::streamIntervals, // contains frame1 and frame 3 @@ -2418,7 +2412,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsMultipleStreams) { updateConnection( *conn, - folly::none, + none, packet1.packet, TimePoint(), getEncodedSize(packet1), @@ -2435,7 +2429,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsMultipleStreams) { &PacketStreamDetails::newStreamBytesSent, stream1Len), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(stream1Offset)), + Optional(stream1Offset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -2449,7 +2443,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsMultipleStreams) { &PacketStreamDetails::newStreamBytesSent, stream2Len), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(stream2Offset)), + Optional(stream2Offset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -2462,7 +2456,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsMultipleStreams) { &PacketStreamDetails::newStreamBytesSent, stream3Len), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(stream3Offset)), + Optional(stream3Offset)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -2488,7 +2482,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsMultipleStreams) { updateConnection( *conn, - folly::none, + none, packet2.packet, TimePoint(), getEncodedSize(packet1), @@ -2505,7 +2499,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsMultipleStreams) { testing::Field(&PacketStreamDetails::newStreamBytesSent, 0), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(/* empty */)), + Optional(/* empty */)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -2517,7 +2511,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsMultipleStreams) { testing::Field(&PacketStreamDetails::newStreamBytesSent, 0), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(/* empty */)), + Optional(/* empty */)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -2529,7 +2523,7 @@ TEST_F(QuicTransportFunctionsTest, StreamDetailsMultipleStreams) { testing::Field(&PacketStreamDetails::newStreamBytesSent, 0), testing::Field( &PacketStreamDetails::maybeFirstNewStreamByteOffset, - folly::Optional(/* empty */)), + Optional(/* empty */)), testing::Field( &PacketStreamDetails::streamIntervals, testing::ElementsAre(Interval( @@ -3804,7 +3798,7 @@ TEST_F(QuicTransportFunctionsTest, ClearBlockedFromPendingEvents) { conn->streamManager->queueBlocked(stream->id, 1000); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -3850,7 +3844,7 @@ TEST_F(QuicTransportFunctionsTest, TwoConnWindowUpdateWillCrash) { EXPECT_DEATH( updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -3869,7 +3863,7 @@ TEST_F(QuicTransportFunctionsTest, WriteStreamFrameIsNotPureAck) { packet.packet.frames.push_back(std::move(writeStreamFrame)); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -3888,7 +3882,7 @@ TEST_F(QuicTransportFunctionsTest, ClearRstFromPendingEvents) { conn->pendingEvents.resets.emplace(stream->id, rstStreamFrame); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -3930,7 +3924,7 @@ TEST_F(QuicTransportFunctionsTest, TotalBytesSentUpdate) { auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint{}, 4321, @@ -3947,7 +3941,7 @@ TEST_F(QuicTransportFunctionsTest, TotalPacketsSentUpdate) { auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint{}, 4321, @@ -4529,7 +4523,7 @@ TEST_F(QuicTransportFunctionsTest, UpdateConnectionWithBufferMeta) { updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -4558,7 +4552,7 @@ TEST_F(QuicTransportFunctionsTest, UpdateConnectionWithBufferMeta) { retxPacket.packet.frames.push_back(writeStreamFrame); updateConnection( *conn, - folly::none, + none, retxPacket.packet, TimePoint(), getEncodedSize(retxPacket), @@ -4586,7 +4580,7 @@ TEST_F(QuicTransportFunctionsTest, MissingStreamFrameBytes) { packet.packet.frames.push_back(writeStreamFrame); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -4602,7 +4596,7 @@ TEST_F(QuicTransportFunctionsTest, MissingStreamFrameBytes) { packet.packet.frames.push_back(writeStreamFrame); EXPECT_ANY_THROW(updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -4625,7 +4619,7 @@ TEST_F(QuicTransportFunctionsTest, MissingStreamFrameBytesEof) { packet.packet.frames.push_back(writeStreamFrame); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -4646,7 +4640,7 @@ TEST_F(QuicTransportFunctionsTest, MissingStreamFrameBytesEof) { packet.packet.frames.push_back(writeStreamFrame); EXPECT_ANY_THROW(updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -4669,7 +4663,7 @@ TEST_F(QuicTransportFunctionsTest, MissingStreamFrameBytesSingleByteWrite) { packet.packet.frames.push_back(writeStreamFrame); updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), @@ -4685,7 +4679,7 @@ TEST_F(QuicTransportFunctionsTest, MissingStreamFrameBytesSingleByteWrite) { packet.packet.frames.push_back(writeStreamFrame); EXPECT_ANY_THROW(updateConnection( *conn, - folly::none, + none, packet.packet, TimePoint(), getEncodedSize(packet), diff --git a/quic/api/test/QuicTransportTest.cpp b/quic/api/test/QuicTransportTest.cpp index 4be670707..3fdaf04ec 100644 --- a/quic/api/test/QuicTransportTest.cpp +++ b/quic/api/test/QuicTransportTest.cpp @@ -51,12 +51,12 @@ class TransportClosingDeliveryCallback : public QuicSocket::DeliveryCallback { void onDeliveryAck(StreamId, uint64_t offset, std::chrono::microseconds) override { if (offset >= targetOffset_) { - transport_->close(folly::none); + transport_->close(none); } } void onCanceled(StreamId, uint64_t) override { - transport_->close(folly::none); + transport_->close(none); } private: @@ -275,7 +275,7 @@ TEST_F(QuicTransportTest, WriteDataWithProbing) { })); transport_->writeChain(streamId, buf->clone(), true); loopForWrites(); - transport_->close(folly::none); + transport_->close(none); } TEST_F(QuicTransportTest, NotAppLimitedWithLoss) { @@ -304,7 +304,7 @@ TEST_F(QuicTransportTest, NotAppLimitedWithLoss) { EXPECT_CALL(*rawCongestionController, setAppLimited()).Times(0); EXPECT_CALL(connCallback_, onAppRateLimited()).Times(0); loopForWrites(); - transport_->close(folly::none); + transport_->close(none); } TEST_F(QuicTransportTest, NotAppLimitedWithNoWritableBytes) { @@ -327,7 +327,7 @@ TEST_F(QuicTransportTest, NotAppLimitedWithNoWritableBytes) { EXPECT_CALL(*rawCongestionController, setAppLimited()).Times(0); EXPECT_CALL(connCallback_, onAppRateLimited()).Times(0); loopForWrites(); - transport_->close(folly::none); + transport_->close(none); } TEST_F(QuicTransportTest, NotAppLimitedWithLargeBuffer) { @@ -345,7 +345,7 @@ TEST_F(QuicTransportTest, NotAppLimitedWithLargeBuffer) { EXPECT_CALL(*rawCongestionController, setAppLimited()).Times(0); EXPECT_CALL(connCallback_, onAppRateLimited()).Times(0); loopForWrites(); - transport_->close(folly::none); + transport_->close(none); } TEST_F(QuicTransportTest, AppLimited) { @@ -364,7 +364,7 @@ TEST_F(QuicTransportTest, AppLimited) { EXPECT_CALL(*rawCongestionController, setAppLimited()).Times(1); EXPECT_CALL(connCallback_, onAppRateLimited()).Times(1); loopForWrites(); - transport_->close(folly::none); + transport_->close(none); } TEST_F(QuicTransportTest, ObserverNotAppLimitedWithNoWritableBytes) { @@ -417,7 +417,7 @@ TEST_F(QuicTransportTest, ObserverNotAppLimitedWithNoWritableBytes) { EXPECT_CALL(*cb1, destroy(transport_.get())); EXPECT_CALL(*cb2, destroy(transport_.get())); EXPECT_CALL(*cb3, destroy(transport_.get())); - transport_->close(folly::none); + transport_->close(none); transport_ = nullptr; } @@ -466,7 +466,7 @@ TEST_F(QuicTransportTest, ObserverNotAppLimitedWithLargeBuffer) { EXPECT_CALL(*cb1, destroy(transport_.get())); EXPECT_CALL(*cb2, destroy(transport_.get())); EXPECT_CALL(*cb3, destroy(transport_.get())); - transport_->close(folly::none); + transport_->close(none); transport_ = nullptr; } @@ -517,7 +517,7 @@ TEST_F(QuicTransportTest, ObserverAppLimited) { EXPECT_CALL(*cb1, destroy(transport_.get())); EXPECT_CALL(*cb2, destroy(transport_.get())); EXPECT_CALL(*cb3, destroy(transport_.get())); - transport_->close(folly::none); + transport_->close(none); transport_ = nullptr; } @@ -905,7 +905,7 @@ TEST_F(QuicTransportTest, ObserverPacketsWrittenCycleCheckDetails) { invokeForAllObservers(([this](MockLegacyObserver& observer) { EXPECT_CALL(observer, destroy(transport_.get())); })); - transport_->close(folly::none); + transport_->close(none); transport_ = nullptr; } @@ -1120,7 +1120,7 @@ TEST_F(QuicTransportTest, ObserverPacketsWrittenCheckBytesSent) { invokeForAllObservers(([this](MockLegacyObserver& observer) { EXPECT_CALL(observer, destroy(transport_.get())); })); - transport_->close(folly::none); + transport_->close(none); transport_ = nullptr; } @@ -1180,10 +1180,10 @@ TEST_F(QuicTransportTest, ObserverWriteEventsCheckCwndPacketsWritable) { testing::Eq(writeNum)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Eq(folly::Optional(cwndInBytes)))); + testing::Eq(Optional(cwndInBytes)))); // matcher for event from packetsWritten const auto packetsWrittenMatcher = AllOf( @@ -1195,10 +1195,10 @@ TEST_F(QuicTransportTest, ObserverWriteEventsCheckCwndPacketsWritable) { testing::Eq(writeNum)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check below &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt(folly::Optional( + testing::Lt(Optional( upperBoundCurrentBytesWritable - bytesToWrite))), testing::Field( &SocketObserverInterface::PacketsWrittenEvent::numPacketsWritten, @@ -1221,10 +1221,10 @@ TEST_F(QuicTransportTest, ObserverWriteEventsCheckCwndPacketsWritable) { testing::Eq(writeNum)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check below &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt(folly::Optional( + testing::Lt(Optional( upperBoundCurrentBytesWritable - bytesToWrite)))); invokeForEachObserverWithTestEvents( @@ -1296,11 +1296,10 @@ TEST_F(QuicTransportTest, ObserverWriteEventsCheckCwndPacketsWritable) { testing::Eq(writeNum)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt( - folly::Optional(upperBoundCurrentBytesWritable)))); + testing::Lt(Optional(upperBoundCurrentBytesWritable)))); // matcher for event from packetsWritten const auto packetsWrittenMatcher = AllOf( @@ -1312,10 +1311,10 @@ TEST_F(QuicTransportTest, ObserverWriteEventsCheckCwndPacketsWritable) { testing::Eq(writeNum)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check below &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt(folly::Optional( + testing::Lt(Optional( upperBoundCurrentBytesWritable - bytesToWrite))), testing::Field( &SocketObserverInterface::PacketsWrittenEvent::numPacketsWritten, @@ -1338,10 +1337,10 @@ TEST_F(QuicTransportTest, ObserverWriteEventsCheckCwndPacketsWritable) { testing::Eq(writeNum)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check below &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt(folly::Optional( + testing::Lt(Optional( upperBoundCurrentBytesWritable - bytesToWrite)))); invokeForEachObserverWithTestEvents( @@ -1404,7 +1403,7 @@ TEST_F(QuicTransportTest, ObserverWriteEventsCheckCwndPacketsWritable) { invokeForAllObservers(([this](MockLegacyObserver& observer) { EXPECT_CALL(observer, destroy(transport_.get())); })); - transport_->close(folly::none); + transport_->close(none); transport_ = nullptr; } @@ -2060,11 +2059,11 @@ TEST_F(QuicTransportTest, NoWritePendingAckIfHavingData) { ackFound = true; } EXPECT_FALSE(ackFound); - EXPECT_EQ(conn.ackStates.appDataAckState.largestAckScheduled, folly::none); + EXPECT_EQ(conn.ackStates.appDataAckState.largestAckScheduled, none); auto pnSpace = packet.header.getPacketNumberSpace(); auto ackState = getAckState(conn, pnSpace); - EXPECT_EQ(ackState.largestAckScheduled, folly::none); + EXPECT_EQ(ackState.largestAckScheduled, none); EXPECT_FALSE(ackState.needsToSendAckImmediately); EXPECT_EQ(3, ackState.numNonRxPacketsRecvd); } @@ -2198,7 +2197,7 @@ TEST_F(QuicTransportTest, StopSendingReadCallbackNone) { auto streamId = transport_->createBidirectionalStream().value(); NiceMock readCb; transport_->setReadCallback(streamId, &readCb); - transport_->setReadCallback(streamId, nullptr, folly::none); + transport_->setReadCallback(streamId, nullptr, none); loopForWrites(); EXPECT_EQ(0, transport_->getConnectionState().outstandings.packets.size()); } @@ -2209,7 +2208,7 @@ TEST_F(QuicTransportTest, NoStopSendingReadCallback) { transport_->setReadCallback(streamId, &readCb); loopForWrites(); EXPECT_EQ(0, transport_->getConnectionState().outstandings.packets.size()); - transport_->setReadCallback(streamId, nullptr, folly::none); + transport_->setReadCallback(streamId, nullptr, none); } TEST_F(QuicTransportTest, SendPathChallenge) { @@ -2311,7 +2310,7 @@ TEST_F(QuicTransportTest, SendPathValidationWhileThereIsOutstandingOne) { PathChallengeFrame pathChallenge2(456); transport_->getPathValidationTimeout().cancelTimerCallback(); conn.pendingEvents.schedulePathValidationTimeout = false; - conn.outstandingPathValidation = folly::none; + conn.outstandingPathValidation = none; conn.pendingEvents.pathChallenge = pathChallenge2; EXPECT_EQ(conn.pendingEvents.pathChallenge, pathChallenge2); EXPECT_FALSE(conn.pendingEvents.schedulePathValidationTimeout); @@ -2384,7 +2383,7 @@ TEST_F(QuicTransportTest, OnlyClonePathValidationIfOutstanding) { // Reset outstandingPathValidation // This could happen when an endpoint migrates to an unvalidated address, and // then migrates back to a validated address before timer expires - conn.outstandingPathValidation = folly::none; + conn.outstandingPathValidation = none; // Force a timeout with no data so that it clones the packet transport_->lossTimeout().timeoutExpired(); @@ -2674,7 +2673,7 @@ TEST_F(QuicTransportTest, BusyWriteLoopDetection) { EXPECT_EQ(1, conn.outstandings.packets.size()); EXPECT_EQ(1, conn.writeDebugState.currentEmptyLoopCount); - transport_->close(folly::none); + transport_->close(none); } TEST_F(QuicTransportTest, ResendNewConnectionIdOnLoss) { @@ -3085,7 +3084,7 @@ TEST_F(QuicTransportTest, DeliveryCallbackClosesClosedTransport) { EXPECT_CALL(*socket_, write(_, _)).WillRepeatedly(Invoke(bufLength)); transport_->writeChain(stream1, buf1->clone(), true, &dc); loopForWrites(); - transport_->close(folly::none); + transport_->close(none); } TEST_F(QuicTransportTest, DeliveryCallbackClosesTransportOnDelivered) { @@ -3350,7 +3349,7 @@ TEST_F(QuicTransportTest, InvokeDeliveryCallbacksSingleByte) { // unsentByteDeliveryCb::onByteEvent will never get called // cancel gets called instead EXPECT_CALL(unsentByteDeliveryCb, onCanceled(stream, 1)).Times(1); - transport_->close(folly::none); + transport_->close(none); Mock::VerifyAndClearExpectations(&unsentByteDeliveryCb); } @@ -3408,7 +3407,7 @@ TEST_F(QuicTransportTest, InvokeDeliveryCallbacksSingleByteWithDSR) { // unsentByteDeliveryCb::onByteEvent will never get called // cancel gets called instead EXPECT_CALL(unsentByteDeliveryCb, onCanceled(stream, 2)).Times(1); - transport_->close(folly::none); + transport_->close(none); Mock::VerifyAndClearExpectations(&unsentByteDeliveryCb); } @@ -3465,7 +3464,7 @@ TEST_F(QuicTransportTest, InvokeDeliveryCallbacksSingleByteWithFin) { // unsentByteDeliveryCb::onByteEvent will never get called // cancel gets called instead EXPECT_CALL(unsentByteDeliveryCb, onCanceled(stream, 2)).Times(1); - transport_->close(folly::none); + transport_->close(none); Mock::VerifyAndClearExpectations(&unsentByteDeliveryCb); } @@ -3528,7 +3527,7 @@ TEST_F(QuicTransportTest, InvokeTxCallbacksSingleByte) { // an error. So, onByteEventCanceled should be called only once. EXPECT_CALL(pastlastByteTxCb, onByteEventCanceled(getTxMatcher(stream, 1))) .Times(1); - transport_->close(folly::none); + transport_->close(none); Mock::VerifyAndClearExpectations(&pastlastByteTxCb); } @@ -3613,7 +3612,7 @@ TEST_F(QuicTransportTest, InvokeTxCallbacksSingleByteDSR) { // an error. So, onByteEventCanceled should be called only once. EXPECT_CALL(pastlastByteTxCb, onByteEventCanceled(getTxMatcher(stream, 2))) .Times(1); - transport_->close(folly::none); + transport_->close(none); Mock::VerifyAndClearExpectations(&pastlastByteTxCb); } @@ -3674,7 +3673,7 @@ TEST_F(QuicTransportTest, InvokeTxCallbacksSingleByteWithFin) { // cancel gets called instead EXPECT_CALL(pastlastByteTxCb, onByteEventCanceled(getTxMatcher(stream, 2))) .Times(1); - transport_->close(folly::none); + transport_->close(none); Mock::VerifyAndClearExpectations(&pastlastByteTxCb); } @@ -3737,7 +3736,7 @@ TEST_F(QuicTransportTest, InvokeTxCallbacksMultipleBytes) { EXPECT_CALL( pastlastByteTxCb, onByteEventCanceled(getTxMatcher(stream, lastByte + 1))) .Times(1); - transport_->close(folly::none); + transport_->close(none); Mock::VerifyAndClearExpectations(&pastlastByteTxCb); } @@ -3809,7 +3808,7 @@ TEST_F(QuicTransportTest, InvokeTxCallbacksMultipleBytesWriteRateLimited) { EXPECT_CALL( pastlastByteTxCb, onByteEventCanceled(getTxMatcher(stream, lastByte + 1))) .Times(1); - transport_->close(folly::none); + transport_->close(none); Mock::VerifyAndClearExpectations(&pastlastByteTxCb); } @@ -4288,7 +4287,7 @@ TEST_F(QuicTransportTest, NotifyPendingWriteConnDuringClose) { } else { EXPECT_CALL(writeCallback_, onStreamWriteError(streamId, _)); } - transport_->close(folly::none); + transport_->close(none); })); PacketNum num = 10; // Give the conn some headroom. @@ -4324,7 +4323,7 @@ TEST_F(QuicTransportTest, NotifyPendingWriteStreamDuringClose) { EXPECT_CALL(connCallback_, onFlowControlUpdate(stream->id)); EXPECT_CALL(writeCallback_, onStreamWriteError(streamId2, _)); EXPECT_CALL(writeCallback_, onStreamWriteReady(stream->id, _)) - .WillOnce(Invoke([&](auto, auto) { transport_->close(folly::none); })); + .WillOnce(Invoke([&](auto, auto) { transport_->close(none); })); transport_->onNetworkData( SocketAddress("::1", 10000), NetworkData(ReceivedUdpPacket(IOBuf::copyBuffer("fake data")))); @@ -4427,7 +4426,7 @@ TEST_F(QuicTransportTest, WriteStreamFromMiddleOfMap) { const WriteStreamFrame* streamFrame4 = frame4.asWriteStreamFrame(); EXPECT_TRUE(streamFrame4); EXPECT_EQ(streamFrame4->streamId, s1); - transport_->close(folly::none); + transport_->close(none); } TEST_F(QuicTransportTest, NoStream) { @@ -4536,7 +4535,7 @@ TEST_F(QuicTransportTest, CloseTransportCancelsAckTimeout) { transport_->scheduleLossTimeout(500ms); EXPECT_TRUE(transport_->isLossTimeoutScheduled()); - transport_->closeNow(folly::none); + transport_->closeNow(none); EXPECT_FALSE(transport_->getAckTimeout()->isTimerCallbackScheduled()); EXPECT_FALSE(transport_->isLossTimeoutScheduled()); } @@ -4550,7 +4549,7 @@ TEST_F(QuicTransportTest, DrainTimeoutExpired) { TEST_F(QuicTransportTest, CloseWithDrainWillKeepSocketAround) { EXPECT_CALL(*socket_, pauseRead()).Times(0); EXPECT_CALL(*socket_, close()).Times(0); - transport_->close(folly::none); + transport_->close(none); // Manual shut it, otherwise transport_'s dtor will shut the socket and mess // up the EXPECT_CALLs above @@ -4872,7 +4871,7 @@ TEST_F(QuicTransportTest, PrioritySetAndGet) { auto nonExistStreamPri = transport_->getStreamPriority(stream + 4); EXPECT_TRUE(nonExistStreamPri.hasError()); EXPECT_EQ(LocalErrorCode::STREAM_NOT_EXISTS, nonExistStreamPri.error()); - transport_->close(folly::none); + transport_->close(none); auto closedConnStreamPri = transport_->getStreamPriority(stream); EXPECT_TRUE(closedConnStreamPri.hasError()); EXPECT_EQ(LocalErrorCode::CONNECTION_CLOSED, closedConnStreamPri.error()); diff --git a/quic/api/test/QuicTypedTransportTest.cpp b/quic/api/test/QuicTypedTransportTest.cpp index 9c8b3a78c..c401ae8e9 100644 --- a/quic/api/test/QuicTypedTransportTest.cpp +++ b/quic/api/test/QuicTypedTransportTest.cpp @@ -126,10 +126,9 @@ TYPED_TEST(QuicTypedTransportAfterStartTest, TransportInfoRttSignals) { }; // minRTT should not be available in any form - EXPECT_EQ(folly::none, this->getTransport()->getTransportInfo().maybeMinRtt); + EXPECT_EQ(none, this->getTransport()->getTransportInfo().maybeMinRtt); EXPECT_EQ( - folly::none, - this->getTransport()->getTransportInfo().maybeMinRttNoAckDelay); + none, this->getTransport()->getTransportInfo().maybeMinRttNoAckDelay); // clear any outstanding packets this->getNonConstConn().outstandings.reset(); @@ -327,10 +326,9 @@ TYPED_TEST(QuicTypedTransportAfterStartTest, RttSampleAckDelayEqual) { }; // minRTT should not be available in any form - EXPECT_EQ(folly::none, this->getTransport()->getTransportInfo().maybeMinRtt); + EXPECT_EQ(none, this->getTransport()->getTransportInfo().maybeMinRtt); EXPECT_EQ( - folly::none, - this->getTransport()->getTransportInfo().maybeMinRttNoAckDelay); + none, this->getTransport()->getTransportInfo().maybeMinRttNoAckDelay); // clear any outstanding packets this->getNonConstConn().outstandings.reset(); @@ -388,10 +386,9 @@ TYPED_TEST(QuicTypedTransportAfterStartTest, RttSampleAckDelayGreater) { }; // minRTT should not be available in any form - EXPECT_EQ(folly::none, this->getTransport()->getTransportInfo().maybeMinRtt); + EXPECT_EQ(none, this->getTransport()->getTransportInfo().maybeMinRtt); EXPECT_EQ( - folly::none, - this->getTransport()->getTransportInfo().maybeMinRttNoAckDelay); + none, this->getTransport()->getTransportInfo().maybeMinRttNoAckDelay); // clear any outstanding packets this->getNonConstConn().outstandings.reset(); @@ -399,7 +396,7 @@ TYPED_TEST(QuicTypedTransportAfterStartTest, RttSampleAckDelayGreater) { // || [ Value Expected ] | // Case | RTT (delay) | RTT w/o delay || mRTT | w/o ACK delay | Updated // -----|-------------|---------------||------- |----------------|---------- - // 1 | 25ms (26 ms)| 25ms || 25 | folly::none | (1) + // 1 | 25ms (26 ms)| 25ms || 25 | none | (1) { const auto rtt = 25ms; const auto ackDelay = 26ms; @@ -414,7 +411,7 @@ TYPED_TEST(QuicTypedTransportAfterStartTest, RttSampleAckDelayGreater) { EXPECT_EQ(rtt, tInfo.maybeLrtt); EXPECT_EQ(ackDelay, tInfo.maybeLrttAckDelay); EXPECT_EQ(expectedMinRtt, tInfo.maybeMinRtt); - EXPECT_EQ(folly::none, tInfo.maybeMinRttNoAckDelay); // unavailable + EXPECT_EQ(none, tInfo.maybeMinRttNoAckDelay); // unavailable } else { FAIL(); // unhandled typed test } @@ -451,10 +448,9 @@ TYPED_TEST(QuicTypedTransportAfterStartTest, RttSampleZeroTime) { }; // minRTT should not be available in any form - EXPECT_EQ(folly::none, this->getTransport()->getTransportInfo().maybeMinRtt); + EXPECT_EQ(none, this->getTransport()->getTransportInfo().maybeMinRtt); EXPECT_EQ( - folly::none, - this->getTransport()->getTransportInfo().maybeMinRttNoAckDelay); + none, this->getTransport()->getTransportInfo().maybeMinRttNoAckDelay); // clear any outstanding packets this->getNonConstConn().outstandings.reset(); @@ -724,8 +720,7 @@ TYPED_TEST( // deliver an ACK for all of the outstanding packets this->deliverPacket(this->buildAckPacketForSentAppDataPackets( - std::vector< - folly::Optional>{ + std::vector>{ maybeWrittenPackets1, maybeWrittenPackets2})); this->destroyTransport(); } @@ -1012,7 +1007,7 @@ TYPED_TEST( { // Send two packets with no marking EXPECT_CALL(*rawPacketProcessor, prewrite()).Times(1).WillOnce([]() { - return folly::none; + return none; }); auto streamId = this->getTransport()->createBidirectionalStream().value(); const auto bufLength = 1700; // Two packets @@ -1095,8 +1090,7 @@ TYPED_TEST( // deliver an ACK for all of the outstanding packets this->deliverPacket(this->buildAckPacketForSentAppDataPackets( - std::vector< - folly::Optional>{ + std::vector>{ maybeWrittenPackets1, maybeWrittenPackets2})); auto stream = this->getNonConstConn().streamManager->getStream(streamId); ASSERT_TRUE(stream); @@ -1246,7 +1240,7 @@ TYPED_TEST(QuicTypedTransportAfterStartTest, HandleIncomingKeyUpdate) { // // the following technically ignores lost ACK packets from peer, but // // should meet the needs of the majority of tests... // getConn().ackStates.appDataAckState.largestAckedByPeer.value_or(0), - folly::none /* longHeaderOverride */, + none /* longHeaderOverride */, false /* eof */, ProtectionType::KeyPhaseZero)); pktBuf->coalesce(); @@ -1529,7 +1523,7 @@ struct AckEventMatcherBuilder { return std::move(*this); } Builder&& setExpectedAckedIntervals( - std::vector::NewOutstandingPacketInterval>> expectedAckedIntervalsOpt) { std::vector< @@ -1563,13 +1557,13 @@ struct AckEventMatcherBuilder { maybeLargestNewlyAckedPacket = largestNewlyAckedPacketIn; return std::move(*this); } - Builder&& setRtt(const folly::Optional& rttIn) { + Builder&& setRtt(const Optional& rttIn) { maybeRtt = rttIn; CHECK(!noRtt); return std::move(*this); } Builder&& setRttNoAckDelay( - const folly::Optional& rttNoAckDelayIn) { + const Optional& rttNoAckDelayIn) { maybeRttNoAckDelay = rttNoAckDelayIn; CHECK(!noRtt); CHECK(!noRttWithNoAckDelay); @@ -1680,16 +1674,16 @@ struct AckEventMatcherBuilder { } explicit AckEventMatcherBuilder() = default; - folly::Optional::NewOutstandingPacketInterval>> maybeExpectedAckedIntervals; - folly::Optional maybeExpectedNumAckedPackets; - folly::Optional maybeAckTime; - folly::Optional maybeAckDelay; - folly::Optional maybeLargestAckedPacket; - folly::Optional maybeLargestNewlyAckedPacket; - folly::Optional maybeRtt; - folly::Optional maybeRttNoAckDelay; + Optional maybeExpectedNumAckedPackets; + Optional maybeAckTime; + Optional maybeAckDelay; + Optional maybeLargestAckedPacket; + Optional maybeLargestNewlyAckedPacket; + Optional maybeRtt; + Optional maybeRttNoAckDelay; bool noRtt{false}; bool noRttWithNoAckDelay{false}; }; @@ -1752,9 +1746,9 @@ struct ReceivedUdpPacketMatcherBuilder { } explicit ReceivedUdpPacketMatcherBuilder() = default; - folly::Optional maybeExpectedPacketReceiveTime; - folly::Optional maybeExpectedPacketNumBytes; - folly::Optional maybeExpectedTosValue; + Optional maybeExpectedPacketReceiveTime; + Optional maybeExpectedPacketNumBytes; + Optional maybeExpectedTosValue; }; template @@ -1851,13 +1845,12 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne( - SocketObserverInterface::CloseStartedEvent{folly::none}), + testing::Ne(SocketObserverInterface::CloseStartedEvent{none}), // should be equal to a populated event with default error testing::Eq( SocketObserverInterface::CloseStartedEvent{defaultError})))); EXPECT_CALL(*observer, closing(transport, _)); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(observer.get()); EXPECT_CALL(*observer, destroyed(transport, IsNull())); this->destroyTransport(); @@ -1891,12 +1884,11 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne( - SocketObserverInterface::CloseStartedEvent{folly::none}), + testing::Ne(SocketObserverInterface::CloseStartedEvent{none}), // should be equal to a populated event with default error testing::Eq( SocketObserverInterface::CloseStartedEvent{defaultError})))); - transport->close(folly::none); + transport->close(none); // wait for the drain EXPECT_CALL(*observer, closing(transport, _)); @@ -1941,12 +1933,11 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne( - SocketObserverInterface::CloseStartedEvent{folly::none}), + testing::Ne(SocketObserverInterface::CloseStartedEvent{none}), // should be equal to a populated event with default error testing::Eq( SocketObserverInterface::CloseStartedEvent{defaultError})))); - transport->close(folly::none); + transport->close(none); Mock::VerifyAndClearExpectations(observer.get()); // destroy transport without waiting for drain @@ -1982,8 +1973,7 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne( - SocketObserverInterface::CloseStartedEvent{folly::none}), + testing::Ne(SocketObserverInterface::CloseStartedEvent{none}), // should be equal to a populated event with default error testing::Eq( SocketObserverInterface::CloseStartedEvent{testError})))); @@ -2024,8 +2014,7 @@ TYPED_TEST( transport, AllOf( // should not be equal to an empty event - testing::Ne( - SocketObserverInterface::CloseStartedEvent{folly::none}), + testing::Ne(SocketObserverInterface::CloseStartedEvent{none}), // should be equal to a populated event with default error testing::Eq( SocketObserverInterface::CloseStartedEvent{testError})))); @@ -3003,10 +2992,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Eq(folly::Optional(cwndInBytes)))); + testing::Eq(Optional(cwndInBytes)))); EXPECT_CALL(*obs1, startWritingFromAppLimited(_, _)).Times(0); EXPECT_CALL( *obs2, @@ -3027,10 +3016,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check in WillOnce() &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt(folly::Optional(cwndInBytes - strLength))), + testing::Lt(Optional(cwndInBytes - strLength))), testing::Field( &SocketObserverInterface::PacketsWrittenEvent::numPacketsWritten, testing::Eq(1)), @@ -3049,7 +3038,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); EXPECT_EQ(bytesWritten, event.numBytesWritten); @@ -3061,7 +3050,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); EXPECT_EQ(bytesWritten, event.numBytesWritten); @@ -3077,10 +3066,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check below &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt(folly::Optional(cwndInBytes - strLength)))); + testing::Lt(Optional(cwndInBytes - strLength)))); EXPECT_CALL(*obs1, appRateLimited(_, _)).Times(0); EXPECT_CALL(*obs2, appRateLimited(transport, appRateLimitedMatcher)) @@ -3090,7 +3079,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); }); @@ -3101,7 +3090,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); }); @@ -3452,10 +3441,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Eq(folly::Optional(cwndInBytes)))); + testing::Eq(Optional(cwndInBytes)))); EXPECT_CALL(*obs1, startWritingFromAppLimited(_, _)).Times(0); EXPECT_CALL( *obs2, @@ -3476,10 +3465,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check in WillOnce() &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Eq(folly::Optional(0))), + testing::Eq(Optional(0))), testing::Field( &SocketObserverInterface::PacketsWrittenEvent::numPacketsWritten, testing::Eq(1)), @@ -3498,7 +3487,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); EXPECT_EQ(bytesWritten, event.numBytesWritten); @@ -3510,7 +3499,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); EXPECT_EQ(bytesWritten, event.numBytesWritten); @@ -3598,10 +3587,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Eq(folly::Optional(cwndInBytes)))); + testing::Eq(Optional(cwndInBytes)))); EXPECT_CALL(*obs1, startWritingFromAppLimited(_, _)).Times(0); EXPECT_CALL( *obs2, @@ -3622,10 +3611,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check in WillOnce() &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Eq(folly::Optional(0))), // CWND exhausted + testing::Eq(Optional(0))), // CWND exhausted testing::Field( &SocketObserverInterface::PacketsWrittenEvent::numPacketsWritten, testing::Eq(packetsExpectedWritten)), @@ -3644,7 +3633,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); EXPECT_EQ(bytesWritten, event.numBytesWritten); @@ -3656,7 +3645,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); EXPECT_EQ(bytesWritten, event.numBytesWritten); @@ -3691,10 +3680,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check in WillOnce() &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt(folly::Optional(cwndInBytes))), + testing::Lt(Optional(cwndInBytes))), testing::Field( &SocketObserverInterface::PacketsWrittenEvent::numPacketsWritten, testing::Eq(packetsExpectedWritten)), @@ -3713,7 +3702,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); EXPECT_EQ(bytesWritten, event.numBytesWritten); @@ -3725,7 +3714,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); EXPECT_EQ(bytesWritten, event.numBytesWritten); @@ -3741,10 +3730,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(cwndInBytes))), + testing::Eq(Optional(cwndInBytes))), testing::Field( // precise check in WillOnce() &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Lt(folly::Optional(cwndInBytes)))); + testing::Lt(Optional(cwndInBytes)))); EXPECT_CALL(*obs1, appRateLimited(_, _)).Times(0); EXPECT_CALL(*obs2, appRateLimited(transport, appRateLimitedMatcher)) .WillOnce([oldTInfo = this->getTransport()->getTransportInfo(), @@ -3753,7 +3742,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); }); @@ -3764,7 +3753,7 @@ TYPED_TEST( const auto bytesWritten = socket->getTransportInfo().bytesSent - oldTInfo.bytesSent; EXPECT_EQ( - folly::Optional(std::max( + Optional(std::max( int64_t(cwndInBytes) - int64_t(bytesWritten), int64_t(0))), event.maybeWritableBytes); }); @@ -3841,10 +3830,10 @@ TYPED_TEST( testing::Eq(writeCount)), testing::Field( &SocketObserverInterface::WriteEvent::maybeCwndInBytes, - testing::Eq(folly::Optional(folly::none))), + testing::Eq(Optional(none))), testing::Field( &SocketObserverInterface::WriteEvent::maybeWritableBytes, - testing::Eq(folly::Optional(folly::none))), + testing::Eq(Optional(none))), testing::Field( &SocketObserverInterface::PacketsWrittenEvent::numPacketsWritten, testing::Eq(1)), @@ -4105,7 +4094,7 @@ TYPED_TEST( testing::ElementsAre(testing::AllOf(testing::Field( &quic::AckEvent::rttSampleNoAckDelay, testing::AnyOf( - testing::Eq(0ms), testing::Eq(folly::none))))))))); + testing::Eq(0ms), testing::Eq(none))))))))); EXPECT_CALL( *observerWithAcks2, acksProcessed( @@ -4118,7 +4107,7 @@ TYPED_TEST( testing::ElementsAre(testing::AllOf(testing::Field( &quic::AckEvent::rttSampleNoAckDelay, testing::AnyOf( - testing::Eq(0ms), testing::Eq(folly::none))))))))); + testing::Eq(0ms), testing::Eq(none))))))))); const quic::AckBlocks ackBlocks = {{firstPacketNum, lastPacketNum}}; auto buf = quic::test::packetToBuf( @@ -4201,7 +4190,7 @@ TYPED_TEST( getAckEvents, testing::ElementsAre(testing::AllOf(testing::Field( &quic::AckEvent::rttSampleNoAckDelay, - testing::Eq(folly::none)))))))); + testing::Eq(none)))))))); EXPECT_CALL( *observerWithAcks2, acksProcessed( @@ -4213,7 +4202,7 @@ TYPED_TEST( getAckEvents, testing::ElementsAre(testing::AllOf(testing::Field( &quic::AckEvent::rttSampleNoAckDelay, - testing::Eq(folly::none)))))))); + testing::Eq(none)))))))); const quic::AckBlocks ackBlocks = {{firstPacketNum, lastPacketNum}}; auto buf = quic::test::packetToBuf( diff --git a/quic/api/test/QuicTypedTransportTestUtil.h b/quic/api/test/QuicTypedTransportTestUtil.h index db41adf8f..1e5992de3 100644 --- a/quic/api/test/QuicTypedTransportTestUtil.h +++ b/quic/api/test/QuicTypedTransportTestUtil.h @@ -54,7 +54,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { * * @return Interval of newly written AppData packet numbers, or none. */ - folly::Optional loopForWrites() { + Optional loopForWrites() { // store the next packet number const auto preSendNextAppDataPacketNum = getNextPacketNum(getConn(), PacketNumberSpace::AppData); @@ -72,7 +72,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { true /* includeDeclaredLost */); if (it == getConn().outstandings.packets.rend()) { - return folly::none; + return none; } const auto& packet = it->packet; const auto& metadata = it->metadata; @@ -82,7 +82,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { // if packet number of last AppData packet < nextAppDataPacketNum, then // we sent nothing new and we have nothing to do... if (lastAppDataPacketNum < preSendNextAppDataPacketNum) { - return folly::none; + return none; } // we sent new AppData packets @@ -235,8 +235,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { quic::Buf buildPeerPacketWithStreamData( const quic::StreamId streamId, Buf data, - folly::Optional shortHeaderProtectionOverride = - folly::none) { + Optional shortHeaderProtectionOverride = none) { auto buf = quic::test::packetToBuf(createStreamPacket( getSrcConnectionId(), getDstConnectionId(), @@ -248,7 +247,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { // // the following technically ignores lost ACK packets from peer, but // // should meet the needs of the majority of tests... // getConn().ackStates.appDataAckState.largestAckedByPeer.value_or(0), - folly::none /* longHeaderOverride */, + none /* longHeaderOverride */, false /* eof */, shortHeaderProtectionOverride)); buf->coalesce(); @@ -269,7 +268,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { *data /* stream data */, 0 /* cipherOverhead */, 0 /* largest acked */, - folly::none /* longHeaderOverride */, + none /* longHeaderOverride */, true /* eof */)); buf->coalesce(); @@ -389,7 +388,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { * Build a packet with ACK frame for previously sent AppData packets. */ quic::Buf buildAckPacketForSentAppDataPackets( - folly::Optional maybeWriteInterval, + Optional maybeWriteInterval, std::chrono::microseconds ackDelay = 0us) { CHECK(maybeWriteInterval.has_value()); return buildAckPacketForSentAppDataPackets( @@ -413,8 +412,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { * Build a packet with ACK frame for previously sent AppData packets. */ quic::Buf buildAckPacketForSentAppDataPackets( - std::vector> - maybeWriteIntervals, + std::vector> maybeWriteIntervals, std::chrono::microseconds ackDelay = 0us) { std::vector writeIntervals; for (const auto& maybeWriteInterval : maybeWriteIntervals) { @@ -462,13 +460,13 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { * Returns the first outstanding packet with containing frame of type T. */ template - folly::Optional getFirstOutstandingPacketWithFrame() { + Optional getFirstOutstandingPacketWithFrame() { auto packetItr = std::find_if( getNonConstConn().outstandings.packets.begin(), getNonConstConn().outstandings.packets.end(), findFrameInPacketFunc()); if (packetItr == getNonConstConn().outstandings.packets.end()) { - return folly::none; + return none; } return packetItr->packet.header.getPacketSequenceNum(); } @@ -535,8 +533,8 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { private: QuicTypedTransportTestBase* const testObj; - folly::Optional maybeStreamId; - folly::Optional> maybePacketNums; + Optional maybeStreamId; + Optional> maybePacketNums; }; auto getNewStreamBytesInPackets() { @@ -699,7 +697,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { * Return the number of packets written in the write interval. */ static uint64_t getNumPacketsWritten( - const folly::Optional& maybeWriteInterval) { + const Optional& maybeWriteInterval) { if (!maybeWriteInterval.has_value()) { return 0; } @@ -710,7 +708,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { * Return the number of packets written in the write interval. */ static uint64_t getNumPacketsWritten( - const std::vector>& + const std::vector>& maybeWriteIntervals) { uint64_t sum = 0; for (const auto& maybeWriteInterval : maybeWriteIntervals) { @@ -738,7 +736,7 @@ class QuicTypedTransportTestBase : protected QuicTransportTestClass { * Returns a vector of packet numbers written in one or more intervals. */ static std::vector getPacketNumsFromIntervals( - const std::vector>& + const std::vector>& maybeWriteIntervals) { std::vector writeIntervals; for (const auto& maybeWriteInterval : maybeWriteIntervals) { diff --git a/quic/api/test/TestQuicTransport.h b/quic/api/test/TestQuicTransport.h index 20d482887..6370cb05b 100644 --- a/quic/api/test/TestQuicTransport.h +++ b/quic/api/test/TestQuicTransport.h @@ -50,9 +50,9 @@ class TestQuicTransport closeUdpSocket(); } - folly::Optional> getPeerTransportParams() + Optional> getPeerTransportParams() const override { - return folly::none; + return none; } QuicVersion getVersion() { @@ -179,11 +179,11 @@ class TestQuicTransport return observerContainer_.get(); } - folly::Optional> getExportedKeyingMaterial( + Optional> getExportedKeyingMaterial( const std::string&, - const folly::Optional&, + const Optional&, uint16_t) const override { - return folly::none; + return none; } void validateECN() { diff --git a/quic/client/QuicClientTransport.cpp b/quic/client/QuicClientTransport.cpp index f993f72fd..bf003f262 100644 --- a/quic/client/QuicClientTransport.cpp +++ b/quic/client/QuicClientTransport.cpp @@ -1131,7 +1131,7 @@ void QuicClientTransport::recvMsg( uint64_t readBufferSize, int numPackets, NetworkData& networkData, - folly::Optional& server, + Optional& server, size_t& totalData) { for (int packetNum = 0; packetNum < numPackets; ++packetNum) { // We create 1 buffer per packet so that it is not shared, this enables @@ -1263,7 +1263,7 @@ void QuicClientTransport::recvMmsg( uint64_t readBufferSize, uint16_t numPackets, NetworkData& networkData, - folly::Optional& server, + Optional& server, size_t& totalData) { auto& msgs = recvmmsgStorage_.msgs; int flags = 0; @@ -1420,7 +1420,7 @@ void QuicClientTransport::onNotifyDataAvailable( NetworkData networkData; networkData.reserve(numPackets); size_t totalData = 0; - folly::Optional server; + Optional server; if (conn_->transportSettings.shouldUseWrapperRecvmmsgForBatchRecv) { const auto result = sock.recvmmsgNetworkData( @@ -1728,7 +1728,7 @@ void QuicClientTransport::maybeSendTransportKnobs() { } } -folly::Optional> +Optional> QuicClientTransport::getPeerTransportParams() const { if (clientConn_ && clientConn_->clientHandshakeLayer) { auto maybeParams = @@ -1737,7 +1737,7 @@ QuicClientTransport::getPeerTransportParams() const { return maybeParams->parameters; } } - return folly::none; + return none; } void QuicClientTransport::setCongestionControl(CongestionControlType type) { diff --git a/quic/client/QuicClientTransport.h b/quic/client/QuicClientTransport.h index a882af66d..34fbe8fcf 100644 --- a/quic/client/QuicClientTransport.h +++ b/quic/client/QuicClientTransport.h @@ -111,9 +111,9 @@ class QuicClientTransport * context is the context value argument for the TLS exporter. * keyLength is the length of the exported key. */ - folly::Optional> getExportedKeyingMaterial( + Optional> getExportedKeyingMaterial( const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength) const override { return clientConn_->clientHandshakeLayer->getExportedKeyingMaterial( label, context, keyLength); @@ -203,7 +203,7 @@ class QuicClientTransport conn_->bufAccessor = bufAccessor_.get(); } - folly::Optional> getPeerTransportParams() + Optional> getPeerTransportParams() const override; class HappyEyeballsConnAttemptDelayTimeout : public QuicTimerCallback { @@ -243,14 +243,14 @@ class QuicClientTransport uint64_t readBufferSize, int numPackets, NetworkData& networkData, - folly::Optional& server, + Optional& server, size_t& totalData); void recvMmsg( QuicAsyncUDPSocket& sock, uint64_t readBufferSize, uint16_t numPackets, NetworkData& networkData, - folly::Optional& server, + Optional& server, size_t& totalData); /** @@ -298,7 +298,7 @@ class QuicClientTransport const QuicWriteFrame& packetFrame, const ReadAckFrame&); - folly::Optional hostname_; + Optional hostname_; HappyEyeballsConnAttemptDelayTimeout happyEyeballsConnAttemptDelayTimeout_; private: diff --git a/quic/client/connector/QuicConnector.cpp b/quic/client/connector/QuicConnector.cpp index a3ea51990..e741ca7a8 100644 --- a/quic/client/connector/QuicConnector.cpp +++ b/quic/client/connector/QuicConnector.cpp @@ -40,7 +40,7 @@ void QuicConnector::onReplaySafe() noexcept { void QuicConnector::connect( folly::EventBase* eventBase, - folly::Optional localAddr, + Optional localAddr, const folly::SocketAddress& connectAddr, std::shared_ptr fizzContext, std::shared_ptr verifier, @@ -49,7 +49,7 @@ void QuicConnector::connect( const std::vector& supportedQuicVersions, std::chrono::milliseconds connectTimeout, const folly::SocketOptionMap& socketOptions, - const folly::Optional& sni, + const Optional& sni, std::shared_ptr qLogger, std::shared_ptr quicLoopDetectorCallback, std::shared_ptr diff --git a/quic/client/connector/QuicConnector.h b/quic/client/connector/QuicConnector.h index 62da66ea4..0c98e8d74 100644 --- a/quic/client/connector/QuicConnector.h +++ b/quic/client/connector/QuicConnector.h @@ -46,7 +46,7 @@ class QuicConnector : private quic::QuicSocket::ConnectionSetupCallback, void connect( folly::EventBase* eventBase, - folly::Optional localAddr, + Optional localAddr, const folly::SocketAddress& connectAddr, std::shared_ptr fizzContext, std::shared_ptr verifier, @@ -56,7 +56,7 @@ class QuicConnector : private quic::QuicSocket::ConnectionSetupCallback, std::chrono::milliseconds connectTimeout = std::chrono::milliseconds(1000), const folly::SocketOptionMap& socketOptions = folly::emptySocketOptionMap, - const folly::Optional& sni = folly::none, + const Optional& sni = none, std::shared_ptr qLogger = nullptr, std::shared_ptr quicLoopDetectorCallback = nullptr, diff --git a/quic/client/handshake/ClientHandshake.cpp b/quic/client/handshake/ClientHandshake.cpp index 914887992..46ddfabec 100644 --- a/quic/client/handshake/ClientHandshake.cpp +++ b/quic/client/handshake/ClientHandshake.cpp @@ -18,11 +18,11 @@ ClientHandshake::ClientHandshake(QuicClientConnectionState* conn) : conn_(conn) {} void ClientHandshake::connect( - folly::Optional hostname, + Optional hostname, std::shared_ptr transportParams) { transportParams_ = std::move(transportParams); - folly::Optional cachedServerTransportParams = + Optional cachedServerTransportParams = connectImpl(std::move(hostname)); throwOnError(); @@ -109,16 +109,16 @@ ClientHandshake::Phase ClientHandshake::getPhase() const { return phase_; } -const folly::Optional& +const Optional& ClientHandshake::getServerTransportParams() { return transportParams_->getServerTransportParams(); } -folly::Optional ClientHandshake::getZeroRttRejected() { +Optional ClientHandshake::getZeroRttRejected() { return zeroRttRejected_; } -folly::Optional ClientHandshake::getCanResendZeroRtt() const { +Optional ClientHandshake::getCanResendZeroRtt() const { return canResendZeroRtt_; } diff --git a/quic/client/handshake/ClientHandshake.h b/quic/client/handshake/ClientHandshake.h index f02e0ef66..244d51da1 100644 --- a/quic/client/handshake/ClientHandshake.h +++ b/quic/client/handshake/ClientHandshake.h @@ -34,7 +34,7 @@ class ClientHandshake : public Handshake { * Initiate the handshake with the supplied parameters. */ void connect( - folly::Optional hostname, + Optional hostname, std::shared_ptr transportParams); /** @@ -50,7 +50,7 @@ class ClientHandshake : public Handshake { * Provides facilities to get, put and remove a PSK from the cache in case the * handshake supports a PSK cache. */ - virtual void removePsk(const folly::Optional& /* hostname */) {} + virtual void removePsk(const Optional& /* hostname */) {} /** * Returns a reference to the CryptoFactory used internally. @@ -85,16 +85,16 @@ class ClientHandshake : public Handshake { /** * Edge triggered api to obtain whether or not zero rtt data was rejected. - * If zero rtt was never attempted, then this will return folly::none. Once + * If zero rtt was never attempted, then this will return none. Once * the result is obtained, the result is cleared out. */ - folly::Optional getZeroRttRejected(); + Optional getZeroRttRejected(); /** * If zero-rtt is rejected, this will indicate whether zero-rtt data can be * resent on the connection or the connection has to be closed. */ - folly::Optional getCanResendZeroRtt() const; + Optional getCanResendZeroRtt() const; /** * API used to verify that the integrity token present in the retry packet @@ -107,8 +107,7 @@ class ClientHandshake : public Handshake { /** * Returns the negotiated transport parameters chosen by the server */ - virtual const folly::Optional& - getServerTransportParams(); + virtual const Optional& getServerTransportParams(); ~ClientHandshake() override = default; @@ -159,8 +158,8 @@ class ClientHandshake : public Handshake { Buf writeTrafficSecret_; private: - virtual folly::Optional connectImpl( - folly::Optional hostname) = 0; + virtual Optional connectImpl( + Optional hostname) = 0; virtual EncryptionLevel getReadRecordLayerEncryptionLevel() = 0; virtual void processSocketData(folly::IOBufQueue& queue) = 0; @@ -178,8 +177,8 @@ class ClientHandshake : public Handshake { QuicClientConnectionState* conn_; std::shared_ptr transportParams_; - folly::Optional zeroRttRejected_; - folly::Optional canResendZeroRtt_; + Optional zeroRttRejected_; + Optional canResendZeroRtt_; bool waitForData_{false}; bool earlyDataAttempted_{false}; diff --git a/quic/client/handshake/ClientTransportParametersExtension.h b/quic/client/handshake/ClientTransportParametersExtension.h index 850b7ae80..2e8a7cd0c 100644 --- a/quic/client/handshake/ClientTransportParametersExtension.h +++ b/quic/client/handshake/ClientTransportParametersExtension.h @@ -41,7 +41,7 @@ struct ClientTransportParametersExtension { initialSourceCid_(initialSourceCid), customTransportParameters_(std::move(customTransportParameters)) {} - const folly::Optional& getServerTransportParams() { + const Optional& getServerTransportParams() { return serverTransportParameters_; } @@ -101,6 +101,6 @@ struct ClientTransportParametersExtension { const uint64_t activeConnectionLimit_; const ConnectionId initialSourceCid_; const std::vector customTransportParameters_; - folly::Optional serverTransportParameters_; + Optional serverTransportParameters_; }; } // namespace quic diff --git a/quic/client/state/ClientStateMachine.h b/quic/client/state/ClientStateMachine.h index a39021dc4..68d7ec2dd 100644 --- a/quic/client/state/ClientStateMachine.h +++ b/quic/client/state/ClientStateMachine.h @@ -38,7 +38,7 @@ struct QuicClientConnectionState : public QuicConnectionStateBase { std::unique_ptr zeroRttWriteCipher; // The stateless reset token sent by the server. - folly::Optional statelessResetToken; + Optional statelessResetToken; // The retry token sent by the server. std::string retryToken; @@ -49,18 +49,18 @@ struct QuicClientConnectionState : public QuicConnectionStateBase { // This is the destination connection id that will be sent in the outgoing // client initial packet. It is modified in the event of a retry. - folly::Optional initialDestinationConnectionId; + Optional initialDestinationConnectionId; // This is the original destination connection id. It is the same as the // initialDestinationConnectionId when there is no retry involved. When // there is retry involved, this is the value of the destination connection // id sent in the very first initial packet. - folly::Optional originalDestinationConnectionId; + Optional originalDestinationConnectionId; std::shared_ptr handshakeFactory; ClientHandshake* clientHandshakeLayer; - folly::Optional lastCloseSentTime; + Optional lastCloseSentTime; // Save the server transport params here so that client can access the value // when it wants to write the values to psk cache @@ -110,7 +110,7 @@ struct QuicClientConnectionState : public QuicConnectionStateBase { // Whether 0-rtt has been rejected in this connection. // The value should be set after the handshake if 0-rtt was attempted - folly::Optional zeroRttRejected; + Optional zeroRttRejected; explicit QuicClientConnectionState( std::shared_ptr handshakeFactoryIn) diff --git a/quic/client/test/ClientStateMachineTest.cpp b/quic/client/test/ClientStateMachineTest.cpp index f57e8acde..7334a0dff 100644 --- a/quic/client/test/ClientStateMachineTest.cpp +++ b/quic/client/test/ClientStateMachineTest.cpp @@ -220,7 +220,7 @@ TEST_F(ClientStateMachineTest, TestProcessKnobFramesSupportedParamDisabled) { struct maxStreamGroupsAdvertizedtestStruct { uint64_t peerMaxGroupsIn; - folly::Optional expectedTransportSettingVal; + Optional expectedTransportSettingVal; }; class ClientStateMachineMaxStreamGroupsAdvertizedParamTest : public ClientStateMachineTest, @@ -252,7 +252,7 @@ INSTANTIATE_TEST_SUITE_P( ClientStateMachineMaxStreamGroupsAdvertizedParamTest, ClientStateMachineMaxStreamGroupsAdvertizedParamTest, ::testing::Values( - maxStreamGroupsAdvertizedtestStruct{0, folly::none}, + maxStreamGroupsAdvertizedtestStruct{0, none}, maxStreamGroupsAdvertizedtestStruct{16, 16})); } // namespace quic::test diff --git a/quic/client/test/Mocks.h b/quic/client/test/Mocks.h index 21044369f..139a3d68e 100644 --- a/quic/client/test/Mocks.h +++ b/quic/client/test/Mocks.h @@ -52,27 +52,27 @@ class MockClientHandshake : public ClientHandshake { bool, verifyRetryIntegrityTag, (const ConnectionId&, const RetryPacket&)); - MOCK_METHOD(void, removePsk, (const folly::Optional&)); + MOCK_METHOD(void, removePsk, (const Optional&)); MOCK_METHOD(const CryptoFactory&, getCryptoFactory, (), (const)); MOCK_METHOD(bool, isTLSResumed, (), (const)); MOCK_METHOD( - folly::Optional>, + Optional>, getExportedKeyingMaterial, (const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength), ()); - MOCK_METHOD(folly::Optional, getZeroRttRejected, ()); + MOCK_METHOD(Optional, getZeroRttRejected, ()); MOCK_METHOD( - const folly::Optional&, + const Optional&, getServerTransportParams, ()); MOCK_METHOD(void, destroy, ()); MOCK_METHOD( - folly::Optional, + Optional, connectImpl, - (folly::Optional)); + (Optional)); MOCK_METHOD(EncryptionLevel, getReadRecordLayerEncryptionLevel, ()); MOCK_METHOD(void, processSocketData, (folly::IOBufQueue & queue)); MOCK_METHOD(bool, matchEarlyParameters, ()); @@ -86,7 +86,7 @@ class MockClientHandshake : public ClientHandshake { (folly::ByteRange secret)); MOCK_METHOD(Buf, getNextTrafficSecret, (folly::ByteRange secret), (const)); MOCK_METHOD( - const folly::Optional&, + const Optional&, getApplicationProtocol, (), (const)); diff --git a/quic/client/test/QuicClientTransportMock.h b/quic/client/test/QuicClientTransportMock.h index bee22c6f0..f3f88a15a 100644 --- a/quic/client/test/QuicClientTransportMock.h +++ b/quic/client/test/QuicClientTransportMock.h @@ -46,7 +46,7 @@ class QuicClientTransportMock : public QuicClientTransport { setReadCallback, (StreamId, quic::QuicSocket::ReadCallback*, - folly::Optional)); + Optional)); MOCK_METHOD( (folly::Expected), getStreamTransportInfo, @@ -54,8 +54,8 @@ class QuicClientTransportMock : public QuicClientTransport { (const)); MOCK_METHOD((bool), isTLSResumed, (), (const)); MOCK_METHOD((ZeroRttAttemptState), getZeroRttState, ()); - MOCK_METHOD((void), closeImpl, (folly::Optional, bool, bool)); - MOCK_METHOD((void), close, (folly::Optional)); + MOCK_METHOD((void), closeImpl, (Optional, bool, bool)); + MOCK_METHOD((void), close, (Optional)); MOCK_METHOD((void), writeData, ()); MOCK_METHOD((void), closeSecondSocket, ()); MOCK_METHOD((void), setHappyEyeballsEnabled, (bool)); diff --git a/quic/codec/BUCK b/quic/codec/BUCK index b5cdeb103..a4c00a81a 100644 --- a/quic/codec/BUCK +++ b/quic/codec/BUCK @@ -25,7 +25,6 @@ mvfst_cpp_library( "//folly:conv", "//folly:expected", "//folly:network_address", - "//folly:optional", "//folly:string", "//folly/hash:hash", "//folly/io:iobuf", @@ -36,6 +35,7 @@ mvfst_cpp_library( "//quic/common:circular_deque", "//quic/common:interval_set", "//quic/common:network_data", + "//quic/common:optional", "//quic/common:small_collections", "//quic/common:variant", ], @@ -73,9 +73,9 @@ mvfst_cpp_library( ":types", ], exported_deps = [ - "//folly:optional", "//folly/io:iobuf", "//quic/common:buf_util", + "//quic/common:optional", ], ) @@ -163,7 +163,7 @@ mvfst_cpp_library( exported_deps = [ ":packet_number", ":types", - "//folly:optional", + "//quic/common:optional", ], ) @@ -187,11 +187,11 @@ mvfst_cpp_library( ":packet_number_cipher", ":pktbuilder", ":types", - "//folly:optional", "//quic:constants", "//quic/common:buf_util", "//quic/common:circular_deque", "//quic/common:interval_set", + "//quic/common:optional", "//quic/handshake:aead", "//quic/state:ack_states", "//quic/state:stats_callback", diff --git a/quic/codec/Decode.cpp b/quic/codec/Decode.cpp index e9192c31c..b1884020f 100644 --- a/quic/codec/Decode.cpp +++ b/quic/codec/Decode.cpp @@ -473,7 +473,7 @@ ReadStreamFrame decodeStreamFrame( frameType); } - folly::Optional groupId; + Optional groupId; if (isGroupFrame) { auto gId = decodeQuicInteger(cursor); if (!gId) { @@ -497,7 +497,7 @@ ReadStreamFrame decodeStreamFrame( offset = optionalOffset->first; } auto fin = frameTypeField.hasFin(); - folly::Optional> dataLength; + Optional> dataLength; if (frameTypeField.hasDataLength()) { dataLength = decodeQuicInteger(cursor); if (!dataLength) { @@ -982,7 +982,7 @@ RegularQuicPacket decodeRegularPacket( return packet; } -folly::Optional decodeVersionNegotiation( +Optional decodeVersionNegotiation( const ParsedLongHeaderInvariant& longHeaderInvariant, folly::io::Cursor& cursor) { auto cursorLength = cursor.totalLength(); @@ -990,7 +990,7 @@ folly::Optional decodeVersionNegotiation( if (cursorLength < sizeof(QuicVersionType) || cursorLength % sizeof(QuicVersionType)) { VLOG(4) << "Version negotiation packet invalid"; - return folly::none; + return none; } VersionNegotiationPacket packet( @@ -1008,7 +1008,7 @@ folly::Optional decodeVersionNegotiation( ParsedLongHeaderResult::ParsedLongHeaderResult( bool isVersionNegotiationIn, - folly::Optional parsedLongHeaderIn) + Optional parsedLongHeaderIn) : isVersionNegotiation(isVersionNegotiationIn), parsedLongHeader(std::move(parsedLongHeaderIn)) { CHECK(isVersionNegotiation || parsedLongHeader); @@ -1126,7 +1126,7 @@ folly::Expected parseLongHeader( auto version = parsedLongHeaderInvariant->invariant.version; if (version == QuicVersion::VERSION_NEGOTIATION) { - return ParsedLongHeaderResult(true, folly::none); + return ParsedLongHeaderResult(true, none); } auto parsedHeader = parseLongHeaderVariants( type, std::move(*parsedLongHeaderInvariant), cursor); diff --git a/quic/codec/Decode.h b/quic/codec/Decode.h index 62cd5811d..4e79aeb0d 100644 --- a/quic/codec/Decode.h +++ b/quic/codec/Decode.h @@ -23,16 +23,14 @@ struct CodecParameters { // This must not be set to zero. uint8_t peerAckDelayExponent{kDefaultAckDelayExponent}; QuicVersion version{QuicVersion::MVFST}; - folly::Optional maybeAckReceiveTimestampsConfig = - folly::none; + Optional maybeAckReceiveTimestampsConfig = none; CodecParameters() = default; CodecParameters( uint8_t peerAckDelayExponentIn, QuicVersion versionIn, - folly::Optional - maybeAckReceiveTimestampsConfigIn) + Optional maybeAckReceiveTimestampsConfigIn) : peerAckDelayExponent(peerAckDelayExponentIn), version(versionIn), maybeAckReceiveTimestampsConfig(maybeAckReceiveTimestampsConfigIn) {} @@ -52,10 +50,10 @@ struct ParsedLongHeaderInvariant { }; /** - * Decodes a version negotiation packet. Returns a folly::none, if it cannot + * Decodes a version negotiation packet. Returns a none, if it cannot * decode the packet. */ -folly::Optional decodeVersionNegotiation( +Optional decodeVersionNegotiation( const ParsedLongHeaderInvariant& longHeaderInvariant, folly::io::Cursor& cursor); @@ -188,11 +186,11 @@ struct ParsedLongHeader { struct ParsedLongHeaderResult { bool isVersionNegotiation; - folly::Optional parsedLongHeader; + Optional parsedLongHeader; ParsedLongHeaderResult( bool isVersionNegotiationIn, - folly::Optional parsedLongHeaderIn); + Optional parsedLongHeaderIn); }; // Functions that operate on the initial byte diff --git a/quic/codec/PacketNumberCipher.h b/quic/codec/PacketNumberCipher.h index 82468fd2c..e2be213e8 100644 --- a/quic/codec/PacketNumberCipher.h +++ b/quic/codec/PacketNumberCipher.h @@ -7,9 +7,9 @@ #pragma once -#include #include #include +#include namespace quic { diff --git a/quic/codec/QuicConnectionId.h b/quic/codec/QuicConnectionId.h index 42fbe7d6c..2526ad44d 100644 --- a/quic/codec/QuicConnectionId.h +++ b/quic/codec/QuicConnectionId.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -94,7 +94,7 @@ struct ConnectionIdData { ConnectionId connId; uint64_t sequenceNumber; - folly::Optional token; + Optional token; }; /** diff --git a/quic/codec/QuicHeaderCodec.cpp b/quic/codec/QuicHeaderCodec.cpp index 0d4a6143a..de7ca167e 100644 --- a/quic/codec/QuicHeaderCodec.cpp +++ b/quic/codec/QuicHeaderCodec.cpp @@ -13,7 +13,7 @@ namespace quic { ParsedHeaderResult::ParsedHeaderResult( bool isVersionNegotiationIn, - folly::Optional parsedHeaderIn) + Optional parsedHeaderIn) : isVersionNegotiation(isVersionNegotiationIn), parsedHeader(std::move(parsedHeaderIn)) { CHECK(isVersionNegotiation || parsedHeader); @@ -30,7 +30,7 @@ folly::Expected parseHeader( return parseLongHeader(initialByte, cursor) .then([](ParsedLongHeaderResult&& parsedLongHeaderResult) { if (parsedLongHeaderResult.isVersionNegotiation) { - return ParsedHeaderResult(true, folly::none); + return ParsedHeaderResult(true, none); } // We compensate for the type byte length by adding it back. DCHECK(parsedLongHeaderResult.parsedLongHeader); diff --git a/quic/codec/QuicHeaderCodec.h b/quic/codec/QuicHeaderCodec.h index 2ce524304..79cac89cc 100644 --- a/quic/codec/QuicHeaderCodec.h +++ b/quic/codec/QuicHeaderCodec.h @@ -7,19 +7,19 @@ #pragma once -#include #include #include +#include namespace quic { struct ParsedHeaderResult { bool isVersionNegotiation; - folly::Optional parsedHeader; + Optional parsedHeader; ParsedHeaderResult( bool isVersionNegotiationIn, - folly::Optional parsedHeaderIn); + Optional parsedHeaderIn); }; folly::Expected parseHeader( diff --git a/quic/codec/QuicInteger.cpp b/quic/codec/QuicInteger.cpp index 04ad22ec4..c1a94c456 100644 --- a/quic/codec/QuicInteger.cpp +++ b/quic/codec/QuicInteger.cpp @@ -43,14 +43,14 @@ uint8_t decodeQuicIntegerLength(uint8_t firstByte) { return (1 << ((firstByte >> 6) & 0x03)); } -folly::Optional> decodeQuicInteger( +Optional> decodeQuicInteger( folly::io::Cursor& cursor, uint64_t atMost) { // checks if (atMost == 0 || !cursor.canAdvance(1)) { VLOG(10) << "Not enough bytes to decode integer, cursor len=" << cursor.totalLength(); - return folly::none; + return none; } // get 2 msb of first byte that determines variable-length size expected @@ -67,7 +67,7 @@ folly::Optional> decodeQuicInteger( // not enough bytes to decode, undo cursor if (!cursor.canAdvance(bytesExpected) || atMost < bytesExpected) { VLOG(10) << "Could not decode integer numBytes=" << bytesExpected; - return folly::none; + return none; } // result storage uint64_t result{0}; diff --git a/quic/codec/QuicInteger.h b/quic/codec/QuicInteger.h index 5ccbca669..78ef8a418 100644 --- a/quic/codec/QuicInteger.h +++ b/quic/codec/QuicInteger.h @@ -8,12 +8,12 @@ #pragma once #include -#include #include #include #include #include #include +#include namespace quic { @@ -97,10 +97,10 @@ encodeQuicInteger(uint64_t value, BufOp bufop, int outputSize) { /** * Reads an integer out of the cursor and returns a pair with the integer and - * the numbers of bytes read, or folly::none if there are not enough bytes to + * the numbers of bytes read, or none if there are not enough bytes to * read the int. It only advances the cursor in case of success. */ -folly::Optional> decodeQuicInteger( +Optional> decodeQuicInteger( folly::io::Cursor& cursor, uint64_t atMost = sizeof(uint64_t)); diff --git a/quic/codec/QuicPacketBuilder.cpp b/quic/codec/QuicPacketBuilder.cpp index 828d38b4d..86715e7b5 100644 --- a/quic/codec/QuicPacketBuilder.cpp +++ b/quic/codec/QuicPacketBuilder.cpp @@ -94,7 +94,7 @@ PacketNumEncodingResult encodeLongHeaderHelper( } template -folly::Optional encodeShortHeaderHelper( +Optional encodeShortHeaderHelper( const ShortHeader& shortHeader, BufOp& bufop, uint32_t& spaceCounter, @@ -104,7 +104,7 @@ folly::Optional encodeShortHeaderHelper( if (spaceCounter < 1U + packetNumberEncoding.length + shortHeader.getConnectionId().size()) { spaceCounter = 0; - return folly::none; + return none; } uint8_t initialByte = ShortHeader::kFixedBitMask | (packetNumberEncoding.length - 1); diff --git a/quic/codec/QuicPacketBuilder.h b/quic/codec/QuicPacketBuilder.h index 1733527de..a4faf9aa6 100644 --- a/quic/codec/QuicPacketBuilder.h +++ b/quic/codec/QuicPacketBuilder.h @@ -176,7 +176,7 @@ class InplaceQuicPacketBuilder final : public PacketBuilderInterface { PacketNum largestAckedPacketNum_; RegularQuicWritePacket packet_; uint32_t cipherOverhead_{0}; - folly::Optional packetNumberEncoding_; + Optional packetNumberEncoding_; // The offset in the IOBuf writable area to write Packet Length. size_t packetLenOffset_{0}; // The offset in the IOBuf writable area to write Packet Number. @@ -263,7 +263,7 @@ class RegularQuicPacketBuilder final : public PacketBuilderInterface { BufAppender bodyAppender_; uint32_t cipherOverhead_{0}; - folly::Optional packetNumberEncoding_; + Optional packetNumberEncoding_; }; /** diff --git a/quic/codec/QuicPacketRebuilder.cpp b/quic/codec/QuicPacketRebuilder.cpp index 5f3a71dac..b9841ccda 100644 --- a/quic/codec/QuicPacketRebuilder.cpp +++ b/quic/codec/QuicPacketRebuilder.cpp @@ -43,7 +43,7 @@ PacketEvent PacketRebuilder::cloneOutstandingPacket( return *packet.associatedEvent; } -folly::Optional PacketRebuilder::rebuildFromPacket( +Optional PacketRebuilder::rebuildFromPacket( OutstandingPacketWrapper& packet) { // TODO: if PMTU changes between the transmission of the original packet and // now, then we cannot clone everything in the packet. @@ -193,7 +193,7 @@ folly::Optional PacketRebuilder::rebuildFromPacket( case QuicWriteFrame::Type::DatagramFrame: // Do not clone Datagram frames. If datagram frame is the only frame in // the packet, notPureAck will be false, and the function will return - // folly::none correctly. + // none correctly. writeSuccess = true; break; default: { @@ -204,7 +204,7 @@ folly::Optional PacketRebuilder::rebuildFromPacket( } } if (!writeSuccess) { - return folly::none; + return none; } } // If this packet had a WriteAckFrame, build a new one it with @@ -237,7 +237,7 @@ folly::Optional PacketRebuilder::rebuildFromPacket( conn_.connectionTime, /* connect timestamp */ }; - folly::Optional ackWriteResult; + Optional ackWriteResult; uint64_t peerRequestedTimestampsCount = conn_.maybePeerAckReceiveTimestampsConfig.has_value() @@ -266,7 +266,7 @@ folly::Optional PacketRebuilder::rebuildFromPacket( // (2) we should write window update, but didn't, and wrote nothing else. if (!notPureAck || (shouldWriteWindowUpdate && !windowUpdateWritten && !writeSuccess)) { - return folly::none; + return none; } if (encryptionLevel == EncryptionLevel::Initial) { diff --git a/quic/codec/QuicPacketRebuilder.h b/quic/codec/QuicPacketRebuilder.h index ab03a4761..56619b102 100644 --- a/quic/codec/QuicPacketRebuilder.h +++ b/quic/codec/QuicPacketRebuilder.h @@ -27,8 +27,7 @@ class PacketRebuilder { PacketBuilderInterface& regularBuilder, QuicConnectionStateBase& conn); - folly::Optional rebuildFromPacket( - OutstandingPacketWrapper& packet); + Optional rebuildFromPacket(OutstandingPacketWrapper& packet); // TODO: Same as passing cipherOverhead into the CloningScheduler, this really // is a sad way to solve the writableBytes problem. diff --git a/quic/codec/QuicReadCodec.cpp b/quic/codec/QuicReadCodec.cpp index deed5ce76..1d16180bd 100644 --- a/quic/codec/QuicReadCodec.cpp +++ b/quic/codec/QuicReadCodec.cpp @@ -22,26 +22,26 @@ namespace quic { QuicReadCodec::QuicReadCodec(QuicNodeType nodeType) : nodeType_(nodeType) {} -folly::Optional -QuicReadCodec::tryParsingVersionNegotiation(BufQueue& queue) { +Optional QuicReadCodec::tryParsingVersionNegotiation( + BufQueue& queue) { folly::io::Cursor cursor(queue.front()); if (!cursor.canAdvance(sizeof(uint8_t))) { - return folly::none; + return none; } uint8_t initialByte = cursor.readBE(); auto headerForm = getHeaderForm(initialByte); if (headerForm != HeaderForm::Long) { - return folly::none; + return none; } auto longHeaderInvariant = parseLongHeaderInvariant(initialByte, cursor); if (!longHeaderInvariant) { // if it is an invalid packet, it's definitely not a VN packet, so ignore // it. - return folly::none; + return none; } if (longHeaderInvariant->invariant.version != QuicVersion::VERSION_NEGOTIATION) { - return folly::none; + return none; } return decodeVersionNegotiation(*longHeaderInvariant, cursor); } @@ -182,7 +182,7 @@ CodecResult QuicReadCodec::parseLongHeaderPacket( } PacketNum expectedNextPacketNum = 0; - folly::Optional largestRecvdPacketNum; + Optional largestRecvdPacketNum; switch (longHeaderTypeToProtectionType(type)) { case ProtectionType::Initial: largestRecvdPacketNum = ackStates.initialAckState->largestRecvdPacketNum; @@ -410,7 +410,7 @@ CodecResult QuicReadCodec::parsePacket( } auto data = queue.move(); - folly::Optional token; + Optional token; if (nodeType_ == QuicNodeType::Client && initialByte & ShortHeader::kFixedBitMask) { auto dataLength = data->length(); @@ -472,8 +472,8 @@ const Aead* QuicReadCodec::getHandshakeReadCipher() const { return handshakeReadCipher_.get(); } -const folly::Optional& -QuicReadCodec::getStatelessResetToken() const { +const Optional& QuicReadCodec::getStatelessResetToken() + const { return statelessResetToken_; } @@ -591,7 +591,7 @@ void QuicReadCodec::onHandshakeDone(TimePoint handshakeDoneTime) { } } -folly::Optional QuicReadCodec::getHandshakeDoneTime() { +Optional QuicReadCodec::getHandshakeDoneTime() { return handshakeDoneTime_; } diff --git a/quic/codec/QuicReadCodec.h b/quic/codec/QuicReadCodec.h index 5ca1f3c07..73c2a9751 100644 --- a/quic/codec/QuicReadCodec.h +++ b/quic/codec/QuicReadCodec.h @@ -7,12 +7,12 @@ #pragma once -#include #include #include #include #include #include +#include #include #include #include @@ -108,10 +108,10 @@ class QuicReadCodec { /** * Tries to parse the packet and returns whether or not * it is a version negotiation packet. - * This returns folly::none if the packet is either not + * This returns none if the packet is either not * a VN packet or is invalid. */ - folly::Optional tryParsingVersionNegotiation( + Optional tryParsingVersionNegotiation( BufQueue& queue); const Aead* getOneRttReadCipher() const; @@ -125,7 +125,7 @@ class QuicReadCodec { const PacketNumberCipher* getHandshakeHeaderCipher() const; const PacketNumberCipher* getZeroRttHeaderCipher() const; - const folly::Optional& getStatelessResetToken() const; + const Optional& getStatelessResetToken() const; [[nodiscard]] ProtectionType getCurrentOneRttReadPhase() const; @@ -180,7 +180,7 @@ class QuicReadCodec { */ void onHandshakeDone(TimePoint handshakeDoneTime); - folly::Optional getHandshakeDoneTime(); + Optional getHandshakeDoneTime(); private: CodecResult tryParseShortHeaderPacket( @@ -197,8 +197,8 @@ class QuicReadCodec { QuicNodeType nodeType_; CodecParameters params_; - folly::Optional clientConnectionId_; - folly::Optional serverConnectionId_; + Optional clientConnectionId_; + Optional serverConnectionId_; // Cipher used to decrypt handshake packets. std::unique_ptr initialReadCipher_; @@ -213,16 +213,16 @@ class QuicReadCodec { // The packet number of the first packet in the current 1-RTT phase // It's not set when a key update is ongoing (i.e. the write key has been // updated but no packets have been received with the corresponding read key) - folly::Optional currentOneRttReadPhaseStartPacketNum_{0}; + Optional currentOneRttReadPhaseStartPacketNum_{0}; std::unique_ptr initialHeaderCipher_; std::unique_ptr oneRttHeaderCipher_; std::unique_ptr zeroRttHeaderCipher_; std::unique_ptr handshakeHeaderCipher_; - folly::Optional statelessResetToken_; + Optional statelessResetToken_; std::function cryptoEqual_; - folly::Optional handshakeDoneTime_; + Optional handshakeDoneTime_; QuicTransportStatsCallback* statsCallback_{nullptr}; }; diff --git a/quic/codec/QuicWriteCodec.cpp b/quic/codec/QuicWriteCodec.cpp index a5b1ecafc..2ba25301d 100644 --- a/quic/codec/QuicWriteCodec.cpp +++ b/quic/codec/QuicWriteCodec.cpp @@ -28,18 +28,18 @@ bool packetSpaceCheck(uint64_t limit, size_t require) { namespace quic { -folly::Optional writeStreamFrameHeader( +Optional writeStreamFrameHeader( PacketBuilderInterface& builder, StreamId id, uint64_t offset, uint64_t writeBufferLen, uint64_t flowControlLen, bool fin, - folly::Optional skipLenHint, - folly::Optional streamGroupId, + Optional skipLenHint, + Optional streamGroupId, bool appendFrame) { if (builder.remainingSpaceInPkt() == 0) { - return folly::none; + return none; } if (writeBufferLen == 0 && !fin) { throw QuicInternalException( @@ -51,7 +51,7 @@ folly::Optional writeStreamFrameHeader( streamTypeBuilder.switchToStreamGroups(); } QuicInteger idInt(id); - folly::Optional groupIdInt; + Optional groupIdInt; if (streamGroupId) { groupIdInt = QuicInteger(*streamGroupId); } @@ -65,7 +65,7 @@ folly::Optional writeStreamFrameHeader( if (builder.remainingSpaceInPkt() < headerSize) { VLOG(4) << "No space in packet for stream header. stream=" << id << " remaining=" << builder.remainingSpaceInPkt(); - return folly::none; + return none; } QuicInteger offsetInt(offset); if (offset != 0) { @@ -115,7 +115,7 @@ folly::Optional writeStreamFrameHeader( headerSize + dataLenLen >= builder.remainingSpaceInPkt()) { VLOG(4) << "No space in packet for stream header. stream=" << id << " remaining=" << builder.remainingSpaceInPkt(); - return folly::none; + return none; } // We have to encode the actual data length in the header. headerSize += dataLenLen; @@ -126,12 +126,12 @@ folly::Optional writeStreamFrameHeader( bool shouldSetFin = fin && dataLen == writeBufferLen; if (dataLen == 0 && !shouldSetFin) { // This would be an empty non-fin stream frame. - return folly::none; + return none; } if (builder.remainingSpaceInPkt() < headerSize) { VLOG(4) << "No space in packet for stream header. stream=" << id << " remaining=" << builder.remainingSpaceInPkt(); - return folly::none; + return none; } // Done with the accounting, set the bits and write the actual frame header. @@ -185,7 +185,7 @@ void writeStreamFrameData( } } -folly::Optional writeCryptoFrame( +Optional writeCryptoFrame( uint64_t offsetIn, const BufQueue& data, PacketBuilderInterface& builder) { @@ -200,7 +200,7 @@ folly::Optional writeCryptoFrame( if (spaceLeftInPkt <= cryptoFrameHeaderSize) { VLOG(3) << "No space left in packet to write cryptoFrame header of size: " << cryptoFrameHeaderSize << ", space left=" << spaceLeftInPkt; - return folly::none; + return none; } size_t spaceRemaining = spaceLeftInPkt - cryptoFrameHeaderSize; size_t dataLength = data.chainLength(); @@ -378,12 +378,12 @@ static size_t fillPacketReceiveTimestamps( return ackFrame.recvdPacketsTimestampRanges.size(); } -folly::Optional writeAckFrameToPacketBuilder( +Optional writeAckFrameToPacketBuilder( const quic::WriteAckFrameMetaData& ackFrameMetaData, PacketBuilderInterface& builder, FrameType frameType) { if (ackFrameMetaData.ackState.acks.empty()) { - return folly::none; + return none; } const WriteAckFrameState& ackState = ackFrameMetaData.ackState; // The last block must be the largest block. @@ -455,7 +455,7 @@ folly::Optional writeAckFrameToPacketBuilder( getQuicIntegerSize(maybeLastPktTsDelta.count()).value_or(0); } if (spaceLeft < (headerSize + minAdditionalAckReceiveTimestampsFieldsSize)) { - return folly::none; + return none; } spaceLeft -= (headerSize + minAdditionalAckReceiveTimestampsFieldsSize); @@ -492,7 +492,7 @@ folly::Optional writeAckFrameToPacketBuilder( return ackFrame; } -folly::Optional writeAckFrame( +Optional writeAckFrame( const quic::WriteAckFrameMetaData& ackFrameMetaData, PacketBuilderInterface& builder, FrameType frameType) { @@ -507,11 +507,11 @@ folly::Optional writeAckFrame( maybeWriteAckFrame.value(), maybeWriteAckFrame.value().ackBlocks.size()); } else { - return folly::none; + return none; } } -folly::Optional writeAckFrameWithReceivedTimestamps( +Optional writeAckFrameWithReceivedTimestamps( const quic::WriteAckFrameMetaData& ackFrameMetaData, PacketBuilderInterface& builder, const AckReceiveTimestampsConfig& recvTimestampsConfig, @@ -520,7 +520,7 @@ folly::Optional writeAckFrameWithReceivedTimestamps( auto maybeAckFrame = writeAckFrameToPacketBuilder( ackFrameMetaData, builder, FrameType::ACK_RECEIVE_TIMESTAMPS); if (!maybeAckFrame.has_value()) { - return folly::none; + return none; } auto ackFrame = maybeAckFrame.value(); const WriteAckFrameState& ackState = ackFrameMetaData.ackState; @@ -919,7 +919,7 @@ size_t writeFrame(QuicWriteFrame&& frame, PacketBuilderInterface& builder) { : FrameType::CONNECTION_CLOSE_APP_ERR)); QuicInteger reasonLength(connectionCloseFrame.reasonPhrase.size()); - folly::Optional closingFrameType; + Optional closingFrameType; if (isTransportErrorCode) { closingFrameType = QuicInteger( static_cast(connectionCloseFrame.closingFrameType)); diff --git a/quic/codec/QuicWriteCodec.h b/quic/codec/QuicWriteCodec.h index ba7800d75..022f3c7ea 100644 --- a/quic/codec/QuicWriteCodec.h +++ b/quic/codec/QuicWriteCodec.h @@ -49,15 +49,15 @@ size_t writeFrame(QuicWriteFrame&& frame, PacketBuilderInterface& builder); * to decide it. When skipLenHint is true, the field is skipped. When it's * false, it will be encoded into the header. */ -folly::Optional writeStreamFrameHeader( +Optional writeStreamFrameHeader( PacketBuilderInterface& builder, StreamId id, uint64_t offset, uint64_t writeBufferLen, uint64_t flowControlLen, bool fin, - folly::Optional skipLenHint, - folly::Optional streamGroupId = folly::none, + Optional skipLenHint, + Optional streamGroupId = none, bool appendFrame = true); /** @@ -93,7 +93,7 @@ void writeStreamFrameData( * written. The caller should check the structure to confirm how many bytes were * written. */ -folly::Optional writeCryptoFrame( +Optional writeCryptoFrame( uint64_t offsetIn, const BufQueue& data, PacketBuilderInterface& builder); @@ -114,7 +114,7 @@ folly::Optional writeCryptoFrame( * written to the appender. Returns an empty optional if an ack block could not * be written. */ -folly::Optional writeAckFrame( +Optional writeAckFrame( const WriteAckFrameMetaData& ackFrameMetaData, PacketBuilderInterface& builder, FrameType frameType = FrameType::ACK); @@ -124,13 +124,13 @@ folly::Optional writeAckFrame( */ size_t computeSizeUsedByRecvdTimestamps(quic::WriteAckFrame& writeAckFrame); -folly::Optional writeAckFrameWithReceivedTimestamps( +Optional writeAckFrameWithReceivedTimestamps( const WriteAckFrameMetaData& ackFrameMetaData, PacketBuilderInterface& builder, const AckReceiveTimestampsConfig& recvTimestampsConfig, uint64_t maxRecvTimestampsToSend); -folly::Optional writeAckFrameToPacketBuilder( +Optional writeAckFrameToPacketBuilder( const WriteAckFrameMetaData& ackFrameMetaData, quic::PacketBuilderInterface& builder, quic::FrameType frameType); diff --git a/quic/codec/Types.h b/quic/codec/Types.h index 4dae20419..aa892d476 100644 --- a/quic/codec/Types.h +++ b/quic/codec/Types.h @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include #include @@ -187,8 +187,8 @@ struct ReadAckFrame { using Vec = SmallVec; Vec ackBlocks; FrameType frameType = FrameType::ACK; - folly::Optional maybeLatestRecvdPacketTime; - folly::Optional maybeLatestRecvdPacketNum; + Optional maybeLatestRecvdPacketTime; + Optional maybeLatestRecvdPacketNum; RecvdPacketsTimestampsRangeVec recvdPacketsTimestampRanges; uint32_t ecnECT0Count{0}; uint32_t ecnECT1Count{0}; @@ -208,8 +208,8 @@ struct WriteAckFrame { // Delay in sending ack from time that packet was received. std::chrono::microseconds ackDelay{0us}; FrameType frameType = FrameType::ACK; - folly::Optional maybeLatestRecvdPacketTime; - folly::Optional maybeLatestRecvdPacketNum; + Optional maybeLatestRecvdPacketTime; + Optional maybeLatestRecvdPacketNum; RecvdPacketsTimestampsRangeVec recvdPacketsTimestampRanges; uint32_t ecnECT0Count{0}; uint32_t ecnECT1Count{0}; @@ -236,7 +236,7 @@ struct WriteAckFrameState { // Updated whenever we receive a packet with a larger packet number // than all previously received packets in the packet number space // tracked by this AckState. - folly::Optional largestRecvdPacketInfo; + Optional largestRecvdPacketInfo; // Receive timestamp and packet number for the last received packet. // @@ -244,7 +244,7 @@ struct WriteAckFrameState { // if the last packet was received out of order and thus had a packet // number less than that of a previously received packet in the packet // number space tracked by this AckState. - folly::Optional lastRecvdPacketInfo; + Optional lastRecvdPacketInfo; // Packet number and timestamp of recently received packets. // @@ -438,7 +438,7 @@ struct ReadNewTokenFrame { */ struct WriteStreamFrame { StreamId streamId; - folly::Optional streamGroupId; + Optional streamGroupId; uint64_t offset; uint64_t len; bool fin; @@ -455,7 +455,7 @@ struct WriteStreamFrame { uint64_t lenIn, bool finIn, bool fromBufMetaIn = false, - folly::Optional streamGroupIdIn = folly::none, + Optional streamGroupIdIn = none, uint64_t streamPacketIdxIn = 0) : streamId(streamIdIn), streamGroupId(streamGroupIdIn), @@ -478,7 +478,7 @@ struct WriteStreamFrame { */ struct ReadStreamFrame { StreamId streamId; - folly::Optional streamGroupId; + Optional streamGroupId; uint64_t offset; Buf data; bool fin; @@ -488,7 +488,7 @@ struct ReadStreamFrame { uint64_t offsetIn, Buf dataIn, bool finIn, - folly::Optional streamGroupIdIn = folly::none) + Optional streamGroupIdIn = none) : streamId(streamIdIn), streamGroupId(streamGroupIdIn), offset(offsetIn), @@ -499,7 +499,7 @@ struct ReadStreamFrame { StreamId streamIdIn, uint64_t offsetIn, bool finIn, - folly::Optional streamGroupIdIn = folly::none) + Optional streamGroupIdIn = none) : streamId(streamIdIn), streamGroupId(streamGroupIdIn), offset(offsetIn), diff --git a/quic/codec/test/BUCK b/quic/codec/test/BUCK index 81a2f21b8..96eece3c3 100644 --- a/quic/codec/test/BUCK +++ b/quic/codec/test/BUCK @@ -22,10 +22,10 @@ cpp_unittest( "QuicHeaderCodecTest.cpp", ], deps = [ - "//folly:optional", "//folly/portability:gtest", "//quic:exception", "//quic/codec:header_codec", + "//quic/common:optional", "//quic/common/test:test_utils", ], ) @@ -191,12 +191,12 @@ cpp_unittest( supports_static_listing = False, deps = [ "//folly:expected", - "//folly:optional", "//folly:string", "//folly/io:iobuf", "//folly/portability:gtest", "//quic:exception", "//quic/codec:types", + "//quic/common:optional", ], ) diff --git a/quic/codec/test/DecodeTest.cpp b/quic/codec/test/DecodeTest.cpp index 68fb6a969..9c0562af9 100644 --- a/quic/codec/test/DecodeTest.cpp +++ b/quic/codec/test/DecodeTest.cpp @@ -42,10 +42,10 @@ struct NormalizedAckBlock { template std::unique_ptr createAckFrame( - folly::Optional largestAcked, - folly::Optional ackDelay = folly::none, - folly::Optional numAdditionalBlocks = folly::none, - folly::Optional firstAckBlockLength = folly::none, + Optional largestAcked, + Optional ackDelay = none, + Optional numAdditionalBlocks = none, + Optional firstAckBlockLength = none, std::vector ackBlocks = {}, bool useRealValuesForLargestAcked = false, bool useRealValuesForAckDelay = false, @@ -90,12 +90,12 @@ std::unique_ptr createAckFrame( template std::unique_ptr createStreamFrame( - folly::Optional streamId, - folly::Optional offset = folly::none, - folly::Optional dataLength = folly::none, + Optional streamId, + Optional offset = none, + Optional dataLength = none, Buf data = nullptr, bool useRealValuesForStreamId = false, - folly::Optional groupId = folly::none) { + Optional groupId = none) { std::unique_ptr streamFrame = folly::IOBuf::create(0); BufAppender wcursor(streamFrame.get(), 10); auto appenderOp = [&](auto val) { wcursor.writeBE(val); }; @@ -122,8 +122,8 @@ std::unique_ptr createStreamFrame( } std::unique_ptr createCryptoFrame( - folly::Optional offset = folly::none, - folly::Optional dataLength = folly::none, + Optional offset = none, + Optional dataLength = none, Buf data = nullptr) { std::unique_ptr cryptoFrame = folly::IOBuf::create(0); BufAppender wcursor(cryptoFrame.get(), 10); @@ -141,10 +141,10 @@ std::unique_ptr createCryptoFrame( } std::unique_ptr createAckFrequencyFrame( - folly::Optional sequenceNumber, - folly::Optional packetTolerance, - folly::Optional maxAckDelay, - folly::Optional reorderThreshold) { + Optional sequenceNumber, + Optional packetTolerance, + Optional maxAckDelay, + Optional reorderThreshold) { QuicInteger intFrameType(static_cast(FrameType::ACK_FREQUENCY)); std::unique_ptr ackFrequencyFrame = folly::IOBuf::create(0); BufAppender wcursor(ackFrequencyFrame.get(), 50); @@ -437,11 +437,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) { ackBlocks.emplace_back(QuicInteger(10), QuicInteger(10)); auto result1 = createAckFrame( - largestAcked, - folly::none, - numAdditionalBlocks, - firstAckBlockLength, - ackBlocks); + largestAcked, none, numAdditionalBlocks, firstAckBlockLength, ackBlocks); folly::io::Cursor cursor1(result1.get()); EXPECT_THROW( @@ -452,7 +448,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) { QuicTransportException); auto result2 = createAckFrame( - largestAcked, ackDelay, folly::none, firstAckBlockLength, ackBlocks); + largestAcked, ackDelay, none, firstAckBlockLength, ackBlocks); folly::io::Cursor cursor2(result2.get()); EXPECT_THROW( decodeAckFrame( @@ -462,7 +458,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) { QuicTransportException); auto result3 = createAckFrame( - largestAcked, ackDelay, folly::none, firstAckBlockLength, ackBlocks); + largestAcked, ackDelay, none, firstAckBlockLength, ackBlocks); folly::io::Cursor cursor3(result3.get()); EXPECT_THROW( decodeAckFrame( @@ -472,7 +468,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) { QuicTransportException); auto result4 = createAckFrame( - largestAcked, ackDelay, numAdditionalBlocks, folly::none, ackBlocks); + largestAcked, ackDelay, numAdditionalBlocks, none, ackBlocks); folly::io::Cursor cursor4(result4.get()); EXPECT_THROW( decodeAckFrame( @@ -613,8 +609,8 @@ TEST_F(DecodeTest, StreamLengthStreamIdInvalid) { QuicInteger streamId(std::numeric_limits::max()); auto streamType = StreamTypeField::Builder().setFin().setOffset().setLength().build(); - auto streamFrame = createStreamFrame( - streamId, folly::none, folly::none, nullptr, true); + auto streamFrame = + createStreamFrame(streamId, none, none, nullptr, true); BufQueue queue; queue.append(streamFrame->clone()); EXPECT_THROW(decodeStreamFrame(queue, streamType), QuicTransportException); @@ -625,8 +621,8 @@ TEST_F(DecodeTest, StreamOffsetNotPresent) { QuicInteger length(1); auto streamType = StreamTypeField::Builder().setFin().setOffset().setLength().build(); - auto streamFrame = createStreamFrame( - streamId, folly::none, length, folly::IOBuf::copyBuffer("a")); + auto streamFrame = + createStreamFrame(streamId, none, length, folly::IOBuf::copyBuffer("a")); BufQueue queue; queue.append(streamFrame->clone()); EXPECT_THROW(decodeStreamFrame(queue, streamType), QuicTransportException); @@ -726,14 +722,14 @@ TEST_F(DecodeTest, CryptoDecodeSuccess) { TEST_F(DecodeTest, CryptoOffsetNotPresent) { QuicInteger length(1); auto cryptoFrame = - createCryptoFrame(folly::none, length, folly::IOBuf::copyBuffer("a")); + createCryptoFrame(none, length, folly::IOBuf::copyBuffer("a")); folly::io::Cursor cursor(cryptoFrame.get()); EXPECT_THROW(decodeCryptoFrame(cursor), QuicTransportException); } TEST_F(DecodeTest, CryptoLengthNotPresent) { QuicInteger offset(0); - auto cryptoFrame = createCryptoFrame(offset, folly::none, nullptr); + auto cryptoFrame = createCryptoFrame(offset, none, nullptr); folly::io::Cursor cursor(cryptoFrame.get()); EXPECT_THROW(decodeCryptoFrame(cursor), QuicTransportException); } @@ -789,7 +785,7 @@ TEST_F(DecodeTest, DecodeMultiplePaddingTest) { } std::unique_ptr createNewTokenFrame( - folly::Optional tokenLength = folly::none, + Optional tokenLength = none, Buf token = nullptr) { std::unique_ptr newTokenFrame = folly::IOBuf::create(0); BufAppender wcursor(newTokenFrame.get(), 10); @@ -813,8 +809,7 @@ TEST_F(DecodeTest, NewTokenDecodeSuccess) { } TEST_F(DecodeTest, NewTokenLengthNotPresent) { - auto newTokenFrame = - createNewTokenFrame(folly::none, folly::IOBuf::copyBuffer("a")); + auto newTokenFrame = createNewTokenFrame(none, folly::IOBuf::copyBuffer("a")); folly::io::Cursor cursor(newTokenFrame.get()); EXPECT_THROW(decodeNewTokenFrame(cursor), QuicTransportException); } @@ -922,7 +917,7 @@ TEST_F(DecodeTest, AckFrequencyFrameDecodeInvalidReserved) { QuicInteger packetTolerance(100); QuicInteger maxAckDelay(100000); // 100 ms auto ackFrequencyFrame = createAckFrequencyFrame( - sequenceNumber, packetTolerance, maxAckDelay, folly::none); + sequenceNumber, packetTolerance, maxAckDelay, none); ASSERT_NE(ackFrequencyFrame, nullptr); folly::io::Cursor cursor(ackFrequencyFrame.get()); diff --git a/quic/codec/test/QuicHeaderCodecTest.cpp b/quic/codec/test/QuicHeaderCodecTest.cpp index f672d6911..9c622450f 100644 --- a/quic/codec/test/QuicHeaderCodecTest.cpp +++ b/quic/codec/test/QuicHeaderCodecTest.cpp @@ -5,8 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -#include #include +#include #include #include diff --git a/quic/codec/test/QuicIntegerTest.cpp b/quic/codec/test/QuicIntegerTest.cpp index 50efe0f90..06896bb9c 100644 --- a/quic/codec/test/QuicIntegerTest.cpp +++ b/quic/codec/test/QuicIntegerTest.cpp @@ -6,10 +6,10 @@ */ #include -#include #include #include #include +#include #include #include diff --git a/quic/codec/test/QuicPacketBuilderTest.cpp b/quic/codec/test/QuicPacketBuilderTest.cpp index b4ad22c10..80090bb5b 100644 --- a/quic/codec/test/QuicPacketBuilderTest.cpp +++ b/quic/codec/test/QuicPacketBuilderTest.cpp @@ -93,7 +93,7 @@ class QuicPacketBuilderTest : public TestWithParam { uint32_t pktSizeLimit, PacketHeader header, PacketNum largestAckedPacketNum, - folly::Optional outputBufSize) { + quic::Optional outputBufSize) { switch (flavor) { case TestFlavor::Regular: return std::make_unique( diff --git a/quic/codec/test/QuicPacketRebuilderTest.cpp b/quic/codec/test/QuicPacketRebuilderTest.cpp index e94b664be..1dc28464e 100644 --- a/quic/codec/test/QuicPacketRebuilderTest.cpp +++ b/quic/codec/test/QuicPacketRebuilderTest.cpp @@ -143,7 +143,7 @@ TEST_F(QuicPacketRebuilderTest, RebuildPacket) { buf->computeChainDataLength(), buf->computeChainDataLength(), true, - folly::none /* skipLenHint */); + none /* skipLenHint */); writeStreamFrameData( regularBuilder1, buf->clone(), buf->computeChainDataLength()); writeFrame(maxDataFrame, regularBuilder1); @@ -273,7 +273,7 @@ TEST_F(QuicPacketRebuilderTest, RebuildAfterResetStream) { buf->computeChainDataLength(), buf->computeChainDataLength(), true, - folly::none /* skipLenHint */); + none /* skipLenHint */); writeStreamFrameData( regularBuilder1, buf->clone(), buf->computeChainDataLength()); auto packet1 = std::move(regularBuilder1).buildPacket(); @@ -305,7 +305,7 @@ TEST_F(QuicPacketRebuilderTest, FinOnlyStreamRebuild) { // Write them with a regular builder writeStreamFrameHeader( - regularBuilder1, streamId, 0, 0, 0, true, folly::none /* skipLenHint */); + regularBuilder1, streamId, 0, 0, 0, true, none /* skipLenHint */); auto packet1 = std::move(regularBuilder1).buildPacket(); stream->retransmissionBuffer.emplace( std::piecewise_construct, @@ -360,7 +360,7 @@ TEST_F(QuicPacketRebuilderTest, RebuildDataStreamAndEmptyCryptoStream) { buf->computeChainDataLength(), buf->computeChainDataLength(), true, - folly::none /* skipLenHint */); + none /* skipLenHint */); writeStreamFrameData( regularBuilder1, buf->clone(), buf->computeChainDataLength()); writeCryptoFrame(cryptoOffset, cryptoBuf->clone(), regularBuilder1); @@ -469,7 +469,7 @@ TEST_F(QuicPacketRebuilderTest, CannotRebuild) { buf->computeChainDataLength(), buf->computeChainDataLength(), true, - folly::none /* skipLenHint */); + none /* skipLenHint */); writeStreamFrameData( regularBuilder1, buf->clone(), buf->computeChainDataLength()); auto packet1 = std::move(regularBuilder1).buildPacket(); @@ -537,7 +537,7 @@ TEST_F(QuicPacketRebuilderTest, PurePingWontRebuild) { kDefaultUDPSendPacketLen, std::move(shortHeader2), 0); regularBuilder2.encodePacketHeader(); PacketRebuilder rebuilder(regularBuilder2, conn); - EXPECT_EQ(folly::none, rebuilder.rebuildFromPacket(outstandingPacket)); + EXPECT_EQ(none, rebuilder.rebuildFromPacket(outstandingPacket)); EXPECT_FALSE(outstandingPacket.associatedEvent.has_value()); EXPECT_EQ(0, conn.outstandings.numClonedPackets()); } @@ -564,7 +564,7 @@ TEST_F(QuicPacketRebuilderTest, LastStreamFrameSkipLen) { buf1->computeChainDataLength(), buf1->computeChainDataLength(), false, - folly::none); + none); writeStreamFrameData( regularBuilder, buf1->clone(), buf1->computeChainDataLength()); writeStreamFrameHeader( @@ -574,7 +574,7 @@ TEST_F(QuicPacketRebuilderTest, LastStreamFrameSkipLen) { buf2->computeChainDataLength(), buf2->computeChainDataLength(), true, - folly::none); + none); writeStreamFrameData( regularBuilder, buf2->clone(), buf2->computeChainDataLength()); auto packet = std::move(regularBuilder).buildPacket(); @@ -638,7 +638,7 @@ TEST_F(QuicPacketRebuilderTest, LastStreamFrameFinOnlySkipLen) { buf1->computeChainDataLength(), buf1->computeChainDataLength(), false, - folly::none); + none); writeStreamFrameData( regularBuilder, buf1->clone(), buf1->computeChainDataLength()); writeStreamFrameHeader( @@ -648,7 +648,7 @@ TEST_F(QuicPacketRebuilderTest, LastStreamFrameFinOnlySkipLen) { 0, 0, true, - folly::none); + none); writeStreamFrameData(regularBuilder, nullptr, 0); auto packet = std::move(regularBuilder).buildPacket(); auto outstandingPacket = makeDummyOutstandingPacket(packet.packet, 1200); diff --git a/quic/codec/test/QuicReadCodecTest.cpp b/quic/codec/test/QuicReadCodecTest.cpp index 40ea08102..1b47b9113 100644 --- a/quic/codec/test/QuicReadCodecTest.cpp +++ b/quic/codec/test/QuicReadCodecTest.cpp @@ -296,7 +296,7 @@ TEST_F(QuicReadCodecTest, PacketDecryptFail) { auto aead = std::make_unique(); EXPECT_CALL(*aead, _tryDecrypt(_, _, _)) - .WillOnce(Invoke([](auto&, const auto, auto) { return folly::none; })); + .WillOnce(Invoke([](auto&, const auto, auto) { return none; })); auto data = folly::IOBuf::copyBuffer("hello"); auto streamPacket = createStreamPacket( connId, @@ -396,7 +396,7 @@ TEST_F(QuicReadCodecTest, KeyPhaseOnePacket) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); AckStates ackStates; @@ -422,8 +422,7 @@ TEST_F(QuicReadCodecTest, BadResetFirstTwoBits) { QuicNodeType::Client); EXPECT_CALL(*rawAead, _tryDecrypt(_, _, _)) .Times(AtMost(1)) - .WillRepeatedly( - Invoke([](auto&, const auto&, auto) { return folly::none; })); + .WillRepeatedly(Invoke([](auto&, const auto&, auto) { return none; })); PacketNum packetNum = 1; StreamId streamId = 2; auto data = folly::IOBuf::create(30); @@ -436,7 +435,7 @@ TEST_F(QuicReadCodecTest, BadResetFirstTwoBits) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); overridePacketWithToken(streamPacket, tok); @@ -469,8 +468,7 @@ TEST_F(QuicReadCodecTest, RandomizedShortHeaderLeadsToReset) { QuicNodeType::Client); EXPECT_CALL(*rawAead, _tryDecrypt(_, _, _)) .Times(AtMost(1)) - .WillRepeatedly( - Invoke([](auto&, const auto&, auto) { return folly::none; })); + .WillRepeatedly(Invoke([](auto&, const auto&, auto) { return none; })); PacketNum packetNum = 1; StreamId streamId = 2; auto data = folly::IOBuf::create(30); @@ -483,7 +481,7 @@ TEST_F(QuicReadCodecTest, RandomizedShortHeaderLeadsToReset) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); overridePacketWithToken(streamPacket, tok); @@ -514,7 +512,7 @@ TEST_F(QuicReadCodecTest, StatelessResetTokenMismatch) { QuicNodeType::Client); EXPECT_CALL(*rawAead, _tryDecrypt(_, _, _)) .Times(1) - .WillOnce(Invoke([](auto&, const auto&, auto) { return folly::none; })); + .WillOnce(Invoke([](auto&, const auto&, auto) { return none; })); PacketNum packetNum = 1; StreamId streamId = 2; auto data = folly::IOBuf::create(30); @@ -527,7 +525,7 @@ TEST_F(QuicReadCodecTest, StatelessResetTokenMismatch) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); tok[0] ^= tok[0]; @@ -562,7 +560,7 @@ TEST_F(QuicReadCodecTest, NoOneRttCipherNoReset) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); overridePacketWithToken(streamPacket, tok); @@ -590,7 +588,7 @@ TEST_F(QuicReadCodecTest, FailToDecryptLongHeaderNoReset) { EXPECT_CALL(*rawAead, _tryDecrypt(_, _, _)) .Times(1) - .WillOnce(Invoke([](auto&, const auto&, auto) { return folly::none; })); + .WillOnce(Invoke([](auto&, const auto&, auto) { return none; })); PacketNum packetNum = 1; StreamId streamId = 2; auto data = folly::IOBuf::create(30); @@ -625,7 +623,7 @@ TEST_F(QuicReadCodecTest, FailToDecryptNoTokenNoReset) { EXPECT_CALL(*rawAead, _tryDecrypt(_, _, _)) .Times(1) - .WillOnce(Invoke([](auto&, const auto&, auto) { return folly::none; })); + .WillOnce(Invoke([](auto&, const auto&, auto) { return none; })); PacketNum packetNum = 1; StreamId streamId = 2; auto data = folly::IOBuf::create(30); @@ -638,7 +636,7 @@ TEST_F(QuicReadCodecTest, FailToDecryptNoTokenNoReset) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); AckStates ackStates; @@ -862,7 +860,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingValid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); AckStates ackStates; @@ -889,7 +887,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingValid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -925,7 +923,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingValid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -957,7 +955,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingValid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -989,7 +987,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingValid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -1049,7 +1047,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingInvalid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); AckStates ackStates; @@ -1068,7 +1066,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingInvalid) { .Times(1) .WillOnce(Invoke([](std::unique_ptr&, const auto&, auto) { // Failed decryption - return folly::none; + return none; })); packetNum = 3; streamPacket = createStreamPacket( @@ -1079,7 +1077,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingInvalid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -1110,7 +1108,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingInvalid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -1135,7 +1133,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingInvalid) { .Times(1) .WillOnce(Invoke([](std::unique_ptr&, const auto&, auto) { // Failed decryption - return folly::none; + return none; })); packetNum = 1; streamPacket = createStreamPacket( @@ -1146,7 +1144,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingInvalid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -1167,7 +1165,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingInvalid) { .Times(1) .WillOnce(Invoke([](std::unique_ptr&, const auto&, auto) { // Failed decryption - return folly::none; + return none; })); packetNum = 5; streamPacket = createStreamPacket( @@ -1178,7 +1176,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateIncomingInvalid) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -1229,7 +1227,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateCipherUnavailable) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); AckStates ackStates; @@ -1253,7 +1251,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateCipherUnavailable) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -1277,7 +1275,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateCipherUnavailable) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); packetQueue = bufToQueue(packetToBuf(streamPacket)); @@ -1331,7 +1329,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateInitiate) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseZero); AckStates ackStates; @@ -1377,7 +1375,7 @@ TEST_F(QuicReadCodecTest, KeyUpdateInitiate) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true, ProtectionType::KeyPhaseOne); packetQueue = bufToQueue(packetToBuf(streamPacket)); diff --git a/quic/codec/test/QuicWriteCodecTest.cpp b/quic/codec/test/QuicWriteCodecTest.cpp index 588c20aed..dddb1804a 100644 --- a/quic/codec/test/QuicWriteCodecTest.cpp +++ b/quic/codec/test/QuicWriteCodecTest.cpp @@ -36,8 +36,8 @@ ShortHeader buildTestShortHeader() { QuicFrame parseQuicFrame( BufQueue& queue, bool isAckReceiveTimestampsSupported = false) { - folly::Optional receiveTimeStampsConfig = - folly::none; + quic::Optional receiveTimeStampsConfig = + quic::none; if (isAckReceiveTimestampsSupported) { receiveTimeStampsConfig.assign( {.maxReceiveTimestampsPerAck = 5, .receiveTimestampsExponent = 3}); @@ -317,7 +317,7 @@ TEST_F(QuicWriteCodecTest, WriteStreamFrameToEmptyPacket) { uint64_t offset = 0; bool fin = false; auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 10, 10, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 10, 10, fin, none /* skipLenHint */); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, 10); writeStreamFrameData(pktBuilder, inputBuf->clone(), 10); @@ -363,7 +363,7 @@ TEST_F(QuicWriteCodecTest, WriteStreamFrameToPartialPacket) { // 1 byte for length // => 8 bytes of header auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 20, 20, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 20, 20, fin, none /* skipLenHint */); ASSERT_TRUE(dataLen); EXPECT_EQ(*dataLen, 20); writeStreamFrameData(pktBuilder, inputBuf->clone(), 20); @@ -412,13 +412,7 @@ TEST_F(QuicWriteCodecTest, WriteTwoStreamFrames) { bool fin1 = false; auto inputBuf = buildRandomInputData(30); auto dataLen = writeStreamFrameHeader( - pktBuilder, - streamId1, - offset1, - 30, - 30, - fin1, - folly::none /* skipLenHint */); + pktBuilder, streamId1, offset1, 30, 30, fin1, none /* skipLenHint */); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, 30); writeStreamFrameData(pktBuilder, inputBuf->clone(), 30); @@ -445,7 +439,7 @@ TEST_F(QuicWriteCodecTest, WriteTwoStreamFrames) { remainingSpace, remainingSpace, fin2, - folly::none /* skipLenHint */); + none /* skipLenHint */); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, remainingSpace - 7); writeStreamFrameData(pktBuilder, inputBuf2->clone(), remainingSpace - 7); @@ -515,7 +509,7 @@ TEST_F(QuicWriteCodecTest, WriteStreamFramePartialData) { // 4 bytes for offset // => 7 bytes for header auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 50, 50, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 50, 50, fin, none /* skipLenHint */); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, 33); writeStreamFrameData(pktBuilder, inputBuf->clone(), 33); @@ -554,7 +548,7 @@ TEST_F(QuicWriteCodecTest, WriteStreamFrameTooSmallForStreamHeader) { uint64_t offset = 65535; bool fin = false; auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 1, 1, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 1, 1, fin, none /* skipLenHint */); EXPECT_FALSE(dataLen); EXPECT_EQ(1, pktBuilder.remainingSpaceInPkt()); } @@ -572,7 +566,7 @@ TEST_F(QuicWriteCodecTest, WriteStreamNoSpaceForData) { // 1 byte for offset // => 3 bytes auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 10, 10, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 10, 10, fin, none /* skipLenHint */); EXPECT_FALSE(dataLen.has_value()); EXPECT_EQ(pktBuilder.remainingSpaceInPkt(), 3); } @@ -594,13 +588,7 @@ TEST_F(QuicWriteCodecTest, WriteStreamSpaceForOneByte) { // 1 byte for offset // => 3 bytes auto dataLen = writeStreamFrameHeader( - pktBuilder, - streamId, - offset, - 100, - 100, - fin, - folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 100, 100, fin, none /* skipLenHint */); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, 1); writeStreamFrameData(pktBuilder, inputBuf->clone(), 1); @@ -646,7 +634,7 @@ TEST_F(QuicWriteCodecTest, WriteFinToEmptyPacket) { uint64_t offset = 0; bool fin = true; auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 10, 10, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 10, 10, fin, none /* skipLenHint */); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, 10); writeStreamFrameData(pktBuilder, inputBuf->clone(), 10); @@ -703,7 +691,7 @@ TEST_F(QuicWriteCodecTest, TestWriteIncompleteDataAndFin) { inDataSize, inDataSize, fin, - folly::none /* skipLenHint */); + none /* skipLenHint */); ASSERT_TRUE(dataLen); EXPECT_LT(*dataLen, inDataSize); } @@ -720,7 +708,7 @@ TEST_F(QuicWriteCodecTest, TestWriteNoDataAndFin) { bool fin = true; Buf empty; auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 0, 0, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 0, 0, fin, none /* skipLenHint */); ASSERT_TRUE(dataLen); EXPECT_EQ(*dataLen, 0); } @@ -734,13 +722,7 @@ TEST_F(QuicWriteCodecTest, TestWriteNoDataAndNoFin) { Buf empty; EXPECT_THROW( writeStreamFrameHeader( - pktBuilder, - streamId, - offset, - 0, - 0, - fin, - folly::none /* skipLenHint */), + pktBuilder, streamId, offset, 0, 0, fin, none /* skipLenHint */), QuicInternalException); } @@ -758,7 +740,7 @@ TEST_F(QuicWriteCodecTest, PacketOnlyHasSpaceForStreamHeader) { uint64_t offset = 0; bool fin = true; auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 20, 20, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 20, 20, fin, none /* skipLenHint */); EXPECT_FALSE(dataLen.has_value()); EXPECT_EQ(pktBuilder.remainingSpaceInPkt(), 2); } @@ -775,7 +757,7 @@ TEST_F(QuicWriteCodecTest, PacketOnlyHasSpaceForStreamHeaderWithFin) { uint64_t offset = 0; bool fin = true; auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 0, 0, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 0, 0, fin, none /* skipLenHint */); ASSERT_TRUE(dataLen.has_value()); EXPECT_EQ(*dataLen, 0); EXPECT_EQ(pktBuilder.remainingSpaceInPkt(), 0); @@ -793,7 +775,7 @@ TEST_F(QuicWriteCodecTest, PacketNotEnoughSpaceForStreamHeaderWithFin) { uint64_t offset = 0; bool fin = true; auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 0, 0, fin, folly::none /* skipLenHint */); + pktBuilder, streamId, offset, 0, 0, fin, none /* skipLenHint */); ASSERT_FALSE(dataLen.has_value()); EXPECT_EQ(pktBuilder.remainingSpaceInPkt(), 2); } @@ -819,7 +801,7 @@ TEST_F(QuicWriteCodecTest, WriteStreamFrameHeadeSkipLen) { uint64_t offset = 10; bool fin = false; auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 1200 * 2, 1200 * 2, fin, folly::none); + pktBuilder, streamId, offset, 1200 * 2, 1200 * 2, fin, none); EXPECT_LT(*dataLen, 1200); } @@ -843,8 +825,8 @@ TEST_F(QuicWriteCodecTest, WriteStreamFrameHeadeNotSkipLen) { StreamId streamId = 0; uint64_t offset = 10; bool fin = false; - auto dataLen = writeStreamFrameHeader( - pktBuilder, streamId, offset, 200, 200, fin, folly::none); + auto dataLen = + writeStreamFrameHeader(pktBuilder, streamId, offset, 200, 200, fin, none); EXPECT_EQ(*dataLen, 200); } @@ -2363,7 +2345,7 @@ TEST_F(QuicWriteCodecTest, WriteStreamFrameWithGroup) { 50, 50, fin, - folly::none /* skipLenHint */, + none /* skipLenHint */, groupId); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, 50); diff --git a/quic/common/BUCK b/quic/common/BUCK index 48026597a..5ff367713 100644 --- a/quic/common/BUCK +++ b/quic/common/BUCK @@ -9,8 +9,8 @@ mvfst_cpp_library( "IntervalSet-inl.h", ], exported_deps = [ + ":optional", "//folly:likely", - "//folly:optional", ], ) @@ -26,8 +26,8 @@ mvfst_cpp_library( "//folly:scope_guard", ], exported_deps = [ + ":optional", "//folly:function", - "//folly:optional", "//folly/io/async:delayed_destruction", "//quic:constants", "//quic/common/events:eventbase", @@ -135,8 +135,8 @@ mvfst_cpp_library( ], exported_deps = [ ":buf_util", + ":optional", ":time_points", - "//folly:optional", "//quic:constants", ], ) @@ -147,7 +147,7 @@ mvfst_cpp_library( "TimePoints.h", ], exported_deps = [ - "//folly:optional", + ":optional", "//quic:constants", ], ) @@ -176,9 +176,19 @@ mvfst_cpp_library( "//quic:constants", ], exported_deps = [ - "//folly:optional", + ":optional", ], external_deps = [ "glog", ], ) + +mvfst_cpp_library( + name = "optional", + headers = [ + "Optional.h", + ], + exported_deps = [ + "//folly:optional", + ], +) diff --git a/quic/common/FunctionLooper.cpp b/quic/common/FunctionLooper.cpp index baed55f7a..06b21b173 100644 --- a/quic/common/FunctionLooper.cpp +++ b/quic/common/FunctionLooper.cpp @@ -158,12 +158,12 @@ void FunctionLooper::callbackCanceled() noexcept { return; } -folly::Optional +Optional FunctionLooper::getTimerTickInterval() noexcept { if (pacingTimer_) { return pacingTimer_->getTickInterval(); } - return folly::none; + return none; } std::ostream& operator<<(std::ostream& out, const LooperType& rhs) { diff --git a/quic/common/FunctionLooper.h b/quic/common/FunctionLooper.h index ecbfeca84..7c5cf5b97 100644 --- a/quic/common/FunctionLooper.h +++ b/quic/common/FunctionLooper.h @@ -9,9 +9,9 @@ #include #include -#include #include #include +#include #include #include @@ -95,7 +95,7 @@ class FunctionLooper : public QuicEventBaseLoopCallback, void callbackCanceled() noexcept override; - folly::Optional getTimerTickInterval() noexcept; + Optional getTimerTickInterval() noexcept; /* * Controls whether to fire a loop early when the pacing timer has been diff --git a/quic/common/IntervalSet-inl.h b/quic/common/IntervalSet-inl.h index 5390602c9..fd36ac525 100644 --- a/quic/common/IntervalSet-inl.h +++ b/quic/common/IntervalSet-inl.h @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -#include +#include namespace quic { diff --git a/quic/common/NetworkData.h b/quic/common/NetworkData.h index 51f2bbbfb..80bdf15da 100644 --- a/quic/common/NetworkData.h +++ b/quic/common/NetworkData.h @@ -7,9 +7,9 @@ #pragma once -#include #include #include +#include #include #include @@ -51,7 +51,7 @@ struct ReceivedUdpPacket { TimePoint receiveTimePoint; // Socket timestamps, when available. - folly::Optional maybeSoftwareTs; + Optional maybeSoftwareTs; }; ReceivedUdpPacket() = default; diff --git a/quic/common/Optional.h b/quic/common/Optional.h new file mode 100644 index 000000000..332950919 --- /dev/null +++ b/quic/common/Optional.h @@ -0,0 +1,16 @@ +/* + * 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 + +namespace quic { +template +using Optional = folly::Optional; + +constexpr folly::None none{folly::None::_secret::_token}; +} // namespace quic diff --git a/quic/common/TimePoints.h b/quic/common/TimePoints.h index 9d571bdfb..87093f10e 100644 --- a/quic/common/TimePoints.h +++ b/quic/common/TimePoints.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include /** * Namespace for mvfst chrono types. @@ -36,7 +36,7 @@ struct SystemClockTimePointExt { // // We keep both the raw TimePoint and the transformed TimePoint to enable us // to measure the impact of said correction and for debugging purposes. - folly::Optional maybeMonotonic; + Optional maybeMonotonic; }; /** diff --git a/quic/common/TransportKnobs.cpp b/quic/common/TransportKnobs.cpp index c5fb18917..6e08fb27d 100644 --- a/quic/common/TransportKnobs.cpp +++ b/quic/common/TransportKnobs.cpp @@ -28,7 +28,7 @@ bool compareTransportKnobParam( } // namespace -folly::Optional parseTransportKnobs( +Optional parseTransportKnobs( const std::string& serializedParams) { TransportKnobParams knobParams; try { @@ -66,7 +66,7 @@ folly::Optional parseTransportKnobs( knobParams.push_back({paramId, expectAsInt.value()}); continue; // triggers next loop iteration } - return folly::none; // error parsing integer parameter + return none; // error parsing integer parameter } /* @@ -82,7 +82,7 @@ folly::Optional parseTransportKnobs( {paramId, folly::to(cctype.value())}); } else { LOG(ERROR) << "unknown cc type " << val; - return folly::none; + return none; } /* * set rtt factor used in cc algs like bbr or copa @@ -104,7 +104,7 @@ folly::Optional parseTransportKnobs( if (pos == std::string::npos) { LOG(ERROR) << "rtt factor knob expected format {numerator}/{denominator}"; - return folly::none; + return none; } uint64_t numerator = folly::tryTo(s.substr(0, pos)).value_or(kKnobFractionMax); @@ -117,7 +117,7 @@ folly::Optional parseTransportKnobs( LOG(ERROR) << "rtt factor knob numerator and denominator must be ints in range (0," << kKnobFractionMax << "]"; - return folly::none; + return none; } // transport knobs must be a single int, so we pack numerator and // denominator into a single int here and unpack in the handler @@ -135,7 +135,7 @@ folly::Optional parseTransportKnobs( LOG(ERROR) << "string param type is not valid for this knob with id= " << TransportKnobParamId::_from_integral(paramId); - return folly::none; + return none; } continue; } @@ -143,12 +143,12 @@ folly::Optional parseTransportKnobs( // Quic transport knob param values cannot be of type ARRAY, NULLT or // OBJECT LOG(ERROR) << "Invalid transport knob param value type" << val.type(); - return folly::none; + return none; } } } catch (const std::exception& e) { LOG(ERROR) << "fail to parse knobs: " << e.what(); - return folly::none; + return none; } std::sort(knobParams.begin(), knobParams.end(), compareTransportKnobParam); diff --git a/quic/common/TransportKnobs.h b/quic/common/TransportKnobs.h index 995a7cf0f..e1199a880 100644 --- a/quic/common/TransportKnobs.h +++ b/quic/common/TransportKnobs.h @@ -6,7 +6,7 @@ */ #pragma once -#include +#include #include #include #include @@ -31,7 +31,7 @@ constexpr uint64_t kPriorityThresholdKnobMultiplier = 1000; using TransportKnobParams = std::vector; -folly::Optional parseTransportKnobs( +Optional parseTransportKnobs( const std::string& serializedParams); } // namespace quic diff --git a/quic/common/test/TestPacketBuilders.cpp b/quic/common/test/TestPacketBuilders.cpp index 19a25d99e..4b3c530f0 100644 --- a/quic/common/test/TestPacketBuilders.cpp +++ b/quic/common/test/TestPacketBuilders.cpp @@ -71,11 +71,11 @@ RegularQuicPacketBuilder::Packet AckPacketBuilder::build() && { CHECK_NOTNULL(dstConn)->clientConnectionId.get_pointer()) : *CHECK_NOTNULL( CHECK_NOTNULL(dstConn)->serverConnectionId.get_pointer())); - folly::Optional header; + Optional header; const auto ackPnSpace = *CHECK_NOTNULL(maybePnSpace.get_pointer()); const auto ackPacketNum = [this, &ackPnSpace]() { - folly::Optional maybeAckPacketNum; + Optional maybeAckPacketNum; if (this->ackPacketNumStore) { CHECK(!maybeAckPacketNum.has_value()); auto& ackPacketNumStore = *this->ackPacketNumStore; diff --git a/quic/common/test/TestPacketBuilders.h b/quic/common/test/TestPacketBuilders.h index 8dcaa22c5..eb54f3cee 100644 --- a/quic/common/test/TestPacketBuilders.h +++ b/quic/common/test/TestPacketBuilders.h @@ -24,12 +24,12 @@ struct PacketNumStore { struct AckPacketBuilderFields { QuicConnectionStateBase* dstConn{nullptr}; - folly::Optional maybePnSpace; - folly::Optional maybeAckPacketNum; + Optional maybePnSpace; + Optional maybeAckPacketNum; PacketNumStore* ackPacketNumStore{nullptr}; - folly::Optional maybeAckBlocks; - folly::Optional maybeAckDelay; - folly::Optional maybeAead; // not required + Optional maybeAckBlocks; + Optional maybeAckDelay; + Optional maybeAead; // not required ProtectionType shortHeaderProtectionType{ProtectionType::KeyPhaseZero}; explicit AckPacketBuilderFields() = default; }; @@ -50,19 +50,19 @@ struct AckPacketBuilder : public AckPacketBuilderFields { }; struct OutstandingPacketBuilderFields { - folly::Optional maybePacket; - folly::Optional maybeTime; - folly::Optional maybeEncodedSize; - folly::Optional maybeEncodedBodySize; - folly::Optional maybeTotalBytesSent; - folly::Optional maybeTotalBodyBytesSent; - folly::Optional maybeInflightBytes; - folly::Optional maybePacketsInflight; - folly::Optional> maybeLossState; - folly::Optional maybeWriteCount; - folly::Optional + Optional maybePacket; + Optional maybeTime; + Optional maybeEncodedSize; + Optional maybeEncodedBodySize; + Optional maybeTotalBytesSent; + Optional maybeTotalBodyBytesSent; + Optional maybeInflightBytes; + Optional maybePacketsInflight; + Optional> maybeLossState; + Optional maybeWriteCount; + Optional maybeDetailsPerStream; - folly::Optional maybeTotalAppLimitedTimeUsecs; + Optional maybeTotalAppLimitedTimeUsecs; explicit OutstandingPacketBuilderFields() = default; }; diff --git a/quic/common/test/TestUtils.cpp b/quic/common/test/TestUtils.cpp index a00cf29ac..87c3c39b2 100644 --- a/quic/common/test/TestUtils.cpp +++ b/quic/common/test/TestUtils.cpp @@ -145,8 +145,8 @@ class AcceptingTicketCipher : public fizz::server::TicketCipher { public: ~AcceptingTicketCipher() override = default; - folly::SemiFuture, std::chrono::seconds>>> + folly::SemiFuture< + Optional, std::chrono::seconds>>> encrypt(fizz::server::ResumptionState) const override { // Fake handshake, no need todo anything here. return std::make_pair(folly::IOBuf::create(0), 2s); @@ -183,7 +183,7 @@ class AcceptingTicketCipher : public fizz::server::TicketCipher { } folly::SemiFuture< - std::pair>> + std::pair>> decrypt(std::unique_ptr) const override { return std::make_pair(fizz::PskType::Resumption, createResumptionState()); } @@ -271,10 +271,9 @@ RegularQuicPacketBuilder::Packet createStreamPacket( folly::IOBuf& data, uint8_t cipherOverhead, PacketNum largestAcked, - folly::Optional> - longHeaderOverride, + Optional> longHeaderOverride, bool eof, - folly::Optional shortHeaderOverride, + Optional shortHeaderOverride, uint64_t offset, uint64_t packetSizeLimit) { std::unique_ptr builder; @@ -305,7 +304,7 @@ RegularQuicPacketBuilder::Packet createStreamPacket( data.computeChainDataLength(), data.computeChainDataLength(), eof, - folly::none /* skipLenHint */); + none /* skipLenHint */); writeStreamFrameData( *builder, data.clone(), @@ -359,7 +358,7 @@ RegularQuicPacketBuilder::Packet createCryptoPacket( PacketNum largestAcked, uint64_t offset, uint64_t packetSizeLimit) { - folly::Optional header; + Optional header; switch (protectionType) { case ProtectionType::Initial: header = LongHeader( @@ -735,7 +734,7 @@ CongestionController::AckEvent::AckPacket makeAckPacketFromOutstandingPacket( .build(); } -folly::Optional +Optional writeCryptoFrame(uint64_t offsetIn, Buf data, PacketBuilderInterface& builder) { BufQueue bufQueue(std::move(data)); return writeCryptoFrame(offsetIn, bufQueue, builder); diff --git a/quic/common/test/TestUtils.h b/quic/common/test/TestUtils.h index acf71b2f6..b34b41ad7 100644 --- a/quic/common/test/TestUtils.h +++ b/quic/common/test/TestUtils.h @@ -81,10 +81,10 @@ RegularQuicPacketBuilder::Packet createStreamPacket( folly::IOBuf& data, uint8_t cipherOverhead, PacketNum largestAcked, - folly::Optional> - longHeaderOverride = folly::none, + Optional> longHeaderOverride = + none, bool eof = true, - folly::Optional shortHeaderOverride = folly::none, + Optional shortHeaderOverride = none, uint64_t offset = 0, uint64_t packetSizeLimit = kDefaultUDPSendPacketLen); @@ -315,7 +315,7 @@ CongestionController::AckEvent::AckPacket makeAckPacketFromOutstandingPacket( OutstandingPacketWrapper outstandingPacket); // A Buf based overload of writeCryptoFrame for test only -folly::Optional +Optional writeCryptoFrame(uint64_t offsetIn, Buf data, PacketBuilderInterface& builder); void overridePacketWithToken( @@ -400,7 +400,7 @@ class FakeServerHandshake : public FizzServerHandshake { std::shared_ptr fizzContext, bool chloSync = false, bool cfinSync = false, - folly::Optional clientActiveConnectionIdLimit = folly::none) + Optional clientActiveConnectionIdLimit = none) : FizzServerHandshake( &conn, std::move(fizzContext), @@ -479,8 +479,7 @@ class FakeServerHandshake : public FizzServerHandshake { } } - folly::Optional getClientTransportParams() - override { + Optional getClientTransportParams() override { std::vector transportParams; transportParams.push_back(encodeIntegerParameter( TransportParameterId::initial_max_stream_data_bidi_local, @@ -578,7 +577,7 @@ class FakeServerHandshake : public FizzServerHandshake { uint64_t maxRecvPacketSize{kDefaultMaxUDPPayload}; bool allowZeroRttKeys_{false}; std::vector sourceAddrs_; - folly::Optional clientActiveConnectionIdLimit_; + Optional clientActiveConnectionIdLimit_; }; } // namespace test diff --git a/quic/common/testutil/MockAsyncUDPSocket.h b/quic/common/testutil/MockAsyncUDPSocket.h index 86c78404a..adccc7321 100644 --- a/quic/common/testutil/MockAsyncUDPSocket.h +++ b/quic/common/testutil/MockAsyncUDPSocket.h @@ -56,14 +56,14 @@ struct MockAsyncUDPSocket : public FollyQuicAsyncUDPSocket { (uint64_t readBufferSize, uint16_t numPackets, NetworkData& networkData, - folly::Optional& peerAddress, + Optional& peerAddress, size_t& totalData)); MOCK_METHOD(int, getGRO, ()); MOCK_METHOD(bool, setGRO, (bool)); MOCK_METHOD( void, setAdditionalCmsgsFunc, - (folly::Function()>&&)); + (folly::Function()>&&)); MOCK_METHOD(void, setRcvBuf, (int)); MOCK_METHOD(void, setSndBuf, (int)); MOCK_METHOD(int, getTimestamping, ()); diff --git a/quic/common/udpsocket/BUCK b/quic/common/udpsocket/BUCK index d7a56f615..74e7aed23 100644 --- a/quic/common/udpsocket/BUCK +++ b/quic/common/udpsocket/BUCK @@ -18,6 +18,7 @@ mvfst_cpp_library( "//folly/io/async:async_socket_exception", "//folly/portability:sockets", "//quic/common:network_data", + "//quic/common:optional", "//quic/common/events:eventbase", ], ) @@ -60,6 +61,9 @@ mvfst_cpp_library( headers = [ "LibevQuicAsyncUDPSocket.h", ], + deps = [ + "//quic/common:optional", + ], exported_deps = [ ":quic_async_udp_socket_impl", "//quic/common:network_data", diff --git a/quic/common/udpsocket/FollyQuicAsyncUDPSocket.cpp b/quic/common/udpsocket/FollyQuicAsyncUDPSocket.cpp index a7ff3bb50..6370e7b0c 100644 --- a/quic/common/udpsocket/FollyQuicAsyncUDPSocket.cpp +++ b/quic/common/udpsocket/FollyQuicAsyncUDPSocket.cpp @@ -159,8 +159,7 @@ void FollyQuicAsyncUDPSocket::appendCmsgs(const folly::SocketCmsgMap& cmsgs) { follySocket_.appendCmsgs(cmsgs); } void FollyQuicAsyncUDPSocket::setAdditionalCmsgsFunc( - folly::Function()>&& - additionalCmsgsFunc) { + folly::Function()>&& additionalCmsgsFunc) { follySocket_.setAdditionalCmsgsFunc(std::move(additionalCmsgsFunc)); } diff --git a/quic/common/udpsocket/FollyQuicAsyncUDPSocket.h b/quic/common/udpsocket/FollyQuicAsyncUDPSocket.h index 2abb54f34..7efdef1c0 100644 --- a/quic/common/udpsocket/FollyQuicAsyncUDPSocket.h +++ b/quic/common/udpsocket/FollyQuicAsyncUDPSocket.h @@ -140,8 +140,8 @@ class FollyQuicAsyncUDPSocket : public QuicAsyncUDPSocketImpl { void setCmsgs(const folly::SocketCmsgMap& cmsgs) override; void appendCmsgs(const folly::SocketCmsgMap& cmsgs) override; void setAdditionalCmsgsFunc( - folly::Function()>&& - additionalCmsgsFunc) override; + folly::Function()>&& additionalCmsgsFunc) + override; /* * Packet timestamping is currentl not supported. diff --git a/quic/common/udpsocket/LibevQuicAsyncUDPSocket.cpp b/quic/common/udpsocket/LibevQuicAsyncUDPSocket.cpp index 2c70a99ff..6342ec69a 100644 --- a/quic/common/udpsocket/LibevQuicAsyncUDPSocket.cpp +++ b/quic/common/udpsocket/LibevQuicAsyncUDPSocket.cpp @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include @@ -128,7 +129,7 @@ int LibevQuicAsyncUDPSocket::writem( } void LibevQuicAsyncUDPSocket::setAdditionalCmsgsFunc( - folly::Function()>&& + folly::Function()>&& /* additionalCmsgsFunc */) { LOG(WARNING) << "Setting an additional cmsgs function is not implemented for LibevQuicAsyncUDPSocket"; diff --git a/quic/common/udpsocket/LibevQuicAsyncUDPSocket.h b/quic/common/udpsocket/LibevQuicAsyncUDPSocket.h index aeccb2d3a..d11e079c8 100644 --- a/quic/common/udpsocket/LibevQuicAsyncUDPSocket.h +++ b/quic/common/udpsocket/LibevQuicAsyncUDPSocket.h @@ -117,8 +117,8 @@ class LibevQuicAsyncUDPSocket : public QuicAsyncUDPSocketImpl { void setCmsgs(const folly::SocketCmsgMap& cmsgs) override; void appendCmsgs(const folly::SocketCmsgMap& cmsgs) override; void setAdditionalCmsgsFunc( - folly::Function()>&& - additionalCmsgsFunc) override; + folly::Function()>&& additionalCmsgsFunc) + override; /* * Packet timestamping is currently not supported. diff --git a/quic/common/udpsocket/QuicAsyncUDPSocket.h b/quic/common/udpsocket/QuicAsyncUDPSocket.h index dd5ec9d55..5a5b07a65 100644 --- a/quic/common/udpsocket/QuicAsyncUDPSocket.h +++ b/quic/common/udpsocket/QuicAsyncUDPSocket.h @@ -17,6 +17,7 @@ #include #include +#include #include namespace quic { @@ -222,14 +223,14 @@ class QuicAsyncUDPSocket { explicit RecvResult(NoReadReason noReadReason) : maybeNoReadReason(noReadReason) {} - folly::Optional maybeNoReadReason; + Optional maybeNoReadReason; }; virtual RecvResult recvmmsgNetworkData( uint64_t readBufferSize, uint16_t numPackets, NetworkData& networkData, - folly::Optional& peerAddress, + Optional& peerAddress, size_t& totalData) = 0; // generic segmentation offload get/set @@ -267,7 +268,7 @@ class QuicAsyncUDPSocket { virtual void setCmsgs(const folly::SocketCmsgMap& /* cmsgs */) = 0; virtual void appendCmsgs(const folly::SocketCmsgMap& /* cmsgs */) = 0; virtual void setAdditionalCmsgsFunc( - folly::Function()>&& + folly::Function()>&& /* additionalCmsgsFunc */) = 0; /* diff --git a/quic/common/udpsocket/QuicAsyncUDPSocketImpl.cpp b/quic/common/udpsocket/QuicAsyncUDPSocketImpl.cpp index 5630537b4..eaa35ad7a 100644 --- a/quic/common/udpsocket/QuicAsyncUDPSocketImpl.cpp +++ b/quic/common/udpsocket/QuicAsyncUDPSocketImpl.cpp @@ -17,7 +17,7 @@ QuicAsyncUDPSocket::RecvResult QuicAsyncUDPSocketImpl::recvmmsgNetworkData( uint64_t readBufferSize, uint16_t numPackets, NetworkData& networkData, - folly::Optional& peerAddress, + Optional& peerAddress, size_t& totalData) { /** * This is largely a copy / paste of QuicClientTransport::recvmmsg. @@ -126,11 +126,11 @@ QuicAsyncUDPSocket::RecvResult QuicAsyncUDPSocketImpl::recvmmsgNetworkData( // ts[2] -> hardware timestamp if (params.ts.has_value()) { const auto timespecToTimestamp = [](const timespec& ts) - -> folly::Optional { + -> Optional { std::chrono::nanoseconds duration = std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec); if (duration == duration.zero()) { - return folly::none; + return none; } ReceivedUdpPacket::Timings::SocketTimestampExt sockTsExt; diff --git a/quic/common/udpsocket/QuicAsyncUDPSocketImpl.h b/quic/common/udpsocket/QuicAsyncUDPSocketImpl.h index 73311ef51..21f8865b3 100644 --- a/quic/common/udpsocket/QuicAsyncUDPSocketImpl.h +++ b/quic/common/udpsocket/QuicAsyncUDPSocketImpl.h @@ -17,7 +17,7 @@ class QuicAsyncUDPSocketImpl : public QuicAsyncUDPSocket { uint64_t readBufferSize, uint16_t numPackets, NetworkData& networkData, - folly::Optional& peerAddress, + Optional& peerAddress, size_t& totalData) override; private: diff --git a/quic/common/udpsocket/test/QuicAsyncUDPSocketMock.h b/quic/common/udpsocket/test/QuicAsyncUDPSocketMock.h index 3f27f0c67..f36c6825a 100644 --- a/quic/common/udpsocket/test/QuicAsyncUDPSocketMock.h +++ b/quic/common/udpsocket/test/QuicAsyncUDPSocketMock.h @@ -55,7 +55,7 @@ class QuicAsyncUDPSocketMock : public QuicAsyncUDPSocket { (uint64_t, uint16_t, NetworkData&, - folly::Optional&, + Optional&, size_t&)); MOCK_METHOD((int), getGSO, ()); MOCK_METHOD((int), getGRO, ()); @@ -69,7 +69,7 @@ class QuicAsyncUDPSocketMock : public QuicAsyncUDPSocket { MOCK_METHOD( (void), setAdditionalCmsgsFunc, - (folly::Function()>&&)); + (folly::Function()>&&)); MOCK_METHOD((int), getTimestamping, ()); MOCK_METHOD((void), setReuseAddr, (bool)); MOCK_METHOD((void), setDFAndTurnOffPMTU, (bool)); diff --git a/quic/congestion_control/BUCK b/quic/congestion_control/BUCK index 1a126b8d3..0ec9e04eb 100644 --- a/quic/congestion_control/BUCK +++ b/quic/congestion_control/BUCK @@ -170,8 +170,8 @@ mvfst_cpp_library( ], exported_deps = [ ":congestion_controller", - "//folly:optional", "//quic:exception", + "//quic/common:optional", "//quic/congestion_control/third_party:chromium_windowed_filter", "//quic/state:ack_event", "//quic/state:quic_state_machine", @@ -344,7 +344,7 @@ mvfst_cpp_library( "ThrottlingSignalProvider.h", ], exported_deps = [ - "//folly:optional", + "//quic/common:optional", ], ) diff --git a/quic/congestion_control/Bbr.cpp b/quic/congestion_control/Bbr.cpp index 129f13053..f6b31bb98 100644 --- a/quic/congestion_control/Bbr.cpp +++ b/quic/congestion_control/Bbr.cpp @@ -346,7 +346,7 @@ void BbrCongestionController::handleAckInProbeBw( } // To avoid calculating target cwnd with 1.0 gain twice. - folly::Optional targetCwndCache; + Optional targetCwndCache; // If not in background mode, pacingGain_ < 1.0 means BBR is draining the // network queue. If inflight bytes is below the target, then draining is @@ -679,12 +679,11 @@ uint64_t BbrCongestionController::getCongestionWindow() const noexcept { return cwnd_; } -folly::Optional BbrCongestionController::getBandwidth() - const noexcept { +Optional BbrCongestionController::getBandwidth() const noexcept { if (bandwidthSampler_) { return bandwidthSampler_->getBandwidth(); } - return folly::none; + return none; } void BbrCongestionController::detectBottleneckBandwidth(bool appLimitedSample) { diff --git a/quic/congestion_control/Bbr.h b/quic/congestion_control/Bbr.h index defb5503b..579800124 100644 --- a/quic/congestion_control/Bbr.h +++ b/quic/congestion_control/Bbr.h @@ -129,17 +129,14 @@ class BbrCongestionController : public CongestionController { void onPacketAckOrLoss( const AckEvent* FOLLY_NULLABLE, const LossEvent* FOLLY_NULLABLE) override; - void onPacketAckOrLoss( - folly::Optional ack, - folly::Optional loss) { + void onPacketAckOrLoss(Optional ack, Optional loss) { onPacketAckOrLoss(ack.get_pointer(), loss.get_pointer()); } uint64_t getWritableBytes() const noexcept override; uint64_t getCongestionWindow() const noexcept override; - [[nodiscard]] folly::Optional getBandwidth() - const noexcept override; + [[nodiscard]] Optional getBandwidth() const noexcept override; CongestionControlType type() const noexcept override; void setAppIdle(bool idle, TimePoint eventTime) noexcept override; @@ -258,7 +255,7 @@ class BbrCongestionController : public CongestionController { TimePoint endOfRoundTrip_; // When a packet with send time later than endOfRecovery_ is acked, the // connection is no longer in recovery - folly::Optional endOfRecovery_; + Optional endOfRecovery_; // Cwnd in bytes uint64_t cwnd_; // Initial cwnd in bytes @@ -290,10 +287,10 @@ class BbrCongestionController : public CongestionController { // Once in ProbeRtt state, we cannot exit ProbeRtt before at least we spend // some duration with low inflight bytes. earliestTimeToExitProbeRtt_ is that // time point. - folly::Optional earliestTimeToExitProbeRtt_; + Optional earliestTimeToExitProbeRtt_; // We also cannot exit ProbeRtt if are not at least at the low inflight bytes // mode for one RTT round. probeRttRound_ tracks that. - folly::Optional probeRttRound_; + Optional probeRttRound_; WindowedFilter< uint64_t /* ack bytes count */, @@ -301,7 +298,7 @@ class BbrCongestionController : public CongestionController { uint64_t /* roundtrip count */, uint64_t /* roundtrip count */> maxAckHeightFilter_; - folly::Optional ackAggregationStartTime_; + Optional ackAggregationStartTime_; uint64_t aggregatedAckBytes_{0}; bool appLimitedSinceProbeRtt_{false}; @@ -310,8 +307,8 @@ class BbrCongestionController : public CongestionController { // The last max ACK delay requested, so we don't end up sending // them too frequently. - folly::Optional lastMaxAckDelay_; - folly::Optional lastAckThreshold_; + Optional lastMaxAckDelay_; + Optional lastAckThreshold_; friend std::ostream& operator<<( std::ostream& os, diff --git a/quic/congestion_control/Bbr2.cpp b/quic/congestion_control/Bbr2.cpp index ff161a478..d03f906c5 100644 --- a/quic/congestion_control/Bbr2.cpp +++ b/quic/congestion_control/Bbr2.cpp @@ -215,7 +215,7 @@ bool Bbr2CongestionController::isInBackgroundMode() const { return false; } -folly::Optional Bbr2CongestionController::getBandwidth() const { +Optional Bbr2CongestionController::getBandwidth() const { return bandwidth_; } diff --git a/quic/congestion_control/Bbr2.h b/quic/congestion_control/Bbr2.h index c2973e4c6..9021225c4 100644 --- a/quic/congestion_control/Bbr2.h +++ b/quic/congestion_control/Bbr2.h @@ -50,7 +50,7 @@ class Bbr2CongestionController : public CongestionController { FOLLY_NODISCARD bool isAppLimited() const override; - FOLLY_NODISCARD folly::Optional getBandwidth() const override; + FOLLY_NODISCARD Optional getBandwidth() const override; void setAppLimited() noexcept override; @@ -143,22 +143,22 @@ class Bbr2CongestionController : public CongestionController { WindowedFilter, uint64_t, uint64_t> maxBwFilter_; Bandwidth bandwidth_; - folly::Optional bandwidthHi_, bandwidthLo_; + Optional bandwidthHi_, bandwidthLo_; uint64_t cycleCount_{0}; // TODO: this can be one bit // Data Volume Model Parameters std::chrono::microseconds minRtt_{kDefaultMinRtt}; - folly::Optional minRttTimestamp_; + Optional minRttTimestamp_; - folly::Optional probeRttMinTimestamp_; + Optional probeRttMinTimestamp_; std::chrono::microseconds probeRttMinValue_{kDefaultMinRtt}; - folly::Optional probeRttDoneTimestamp_; + Optional probeRttDoneTimestamp_; bool probeRttExpired_{false}; uint64_t sendQuantum_{64 * 1024}; - folly::Optional inflightLo_, inflightHi_; - folly::Optional extraAckedStartTimestamp_; + Optional inflightLo_, inflightHi_; + Optional extraAckedStartTimestamp_; uint64_t extraAckedDelivered_{0}; WindowedFilter, uint64_t, uint64_t> maxExtraAckedFilter_; diff --git a/quic/congestion_control/BbrRttSampler.h b/quic/congestion_control/BbrRttSampler.h index 8f6ce61e2..8c6d93ee4 100644 --- a/quic/congestion_control/BbrRttSampler.h +++ b/quic/congestion_control/BbrRttSampler.h @@ -27,7 +27,7 @@ class BbrRttSampler : public BbrCongestionController::MinRttSampler { private: std::chrono::seconds expiration_; std::chrono::microseconds minRtt_{kDefaultMinRtt}; - folly::Optional minRttTimestamp_; + Optional minRttTimestamp_; bool rttSampleExpired_; }; } // namespace quic diff --git a/quic/congestion_control/CongestionController.h b/quic/congestion_control/CongestionController.h index 2d2d095b8..cc7d8cb62 100644 --- a/quic/congestion_control/CongestionController.h +++ b/quic/congestion_control/CongestionController.h @@ -50,22 +50,22 @@ struct CongestionController { struct State { uint64_t writableBytes{0}; uint64_t congestionWindowBytes{0}; - folly::Optional maybeBandwidthBitsPerSec{folly::none}; + Optional maybeBandwidthBitsPerSec{none}; }; // Helper struct to group multiple lost packets into one event struct LossEvent { - folly::Optional largestLostPacketNum; + Optional largestLostPacketNum; std::vector lostPacketNumbers; uint64_t lostBytes{0}; uint32_t lostPackets{0}; const TimePoint lossTime; // The packet sent time of the lost packet with largest packet sent time in // this LossEvent - folly::Optional largestLostSentTime; + Optional largestLostSentTime; // The packet sent time of the lost packet with smallest packet sent time in // the LossEvent - folly::Optional smallestLostSentTime; + Optional smallestLostSentTime; // Whether this LossEvent also indicates persistent congestion bool persistentCongestion{false}; @@ -121,8 +121,8 @@ struct CongestionController { * * Unit is bits-per-second (bps). */ - FOLLY_NODISCARD virtual folly::Optional getBandwidth() const { - return folly::none; + FOLLY_NODISCARD virtual Optional getBandwidth() const { + return none; } /** diff --git a/quic/congestion_control/Copa.h b/quic/congestion_control/Copa.h index bcb58b6f8..5eb865772 100644 --- a/quic/congestion_control/Copa.h +++ b/quic/congestion_control/Copa.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include #include @@ -35,9 +35,7 @@ class Copa : public CongestionController { void onPacketAckOrLoss( const AckEvent* FOLLY_NULLABLE, const LossEvent* FOLLY_NULLABLE) override; - void onPacketAckOrLoss( - folly::Optional ack, - folly::Optional loss) { + void onPacketAckOrLoss(Optional ack, Optional loss) { onPacketAckOrLoss(ack.get_pointer(), loss.get_pointer()); } @@ -78,7 +76,7 @@ class Copa : public CongestionController { uint64_t numTimesDirectionSame{0}; // updated every srtt uint64_t lastRecordedCwndBytes; - folly::Optional lastCwndRecordTime{folly::none}; + Optional lastCwndRecordTime{none}; }; void checkAndUpdateDirection(const TimePoint ackTime); void changeDirection( @@ -89,7 +87,7 @@ class Copa : public CongestionController { bool isSlowStart_; // time at which cwnd was last doubled during slow start - folly::Optional lastCwndDoubleTime_{folly::none}; + Optional lastCwndDoubleTime_{none}; WindowedFilter< std::chrono::microseconds, diff --git a/quic/congestion_control/Copa2.cpp b/quic/congestion_control/Copa2.cpp index 35952c8ef..917d498ef 100644 --- a/quic/congestion_control/Copa2.cpp +++ b/quic/congestion_control/Copa2.cpp @@ -76,7 +76,7 @@ void Copa2::onPacketAckOrLoss( } // Switch to and from lossy mode -void Copa2::manageLossyMode(folly::Optional sentTime) { +void Copa2::manageLossyMode(Optional sentTime) { if (!sentTime) { // Loss happened and we don't know when. Be safe lossyMode_ = true; diff --git a/quic/congestion_control/Copa2.h b/quic/congestion_control/Copa2.h index 6e1360958..a285b71b9 100644 --- a/quic/congestion_control/Copa2.h +++ b/quic/congestion_control/Copa2.h @@ -26,9 +26,7 @@ class Copa2 : public CongestionController { void onPacketAckOrLoss( const AckEvent* FOLLY_NULLABLE, const LossEvent* FOLLY_NULLABLE) override; - void onPacketAckOrLoss( - folly::Optional ack, - folly::Optional loss) { + void onPacketAckOrLoss(Optional ack, Optional loss) { onPacketAckOrLoss(ack.get_pointer(), loss.get_pointer()); } @@ -56,7 +54,7 @@ class Copa2 : public CongestionController { private: void onPacketLoss(const LossEvent&); void onPacketAcked(const AckEvent&); - void manageLossyMode(folly::Optional sentTime); + void manageLossyMode(Optional sentTime); QuicConnectionStateBase& conn_; uint64_t cwndBytes_; @@ -76,7 +74,7 @@ class Copa2 : public CongestionController { minRTTFilter_; // Updates happen in cycles. - folly::Optional cycleStartTime_; + Optional cycleStartTime_; bool appLimitedInCycle_{false}; uint64_t bytesAckedInCycle_{0}; diff --git a/quic/congestion_control/NewReno.h b/quic/congestion_control/NewReno.h index 6b1dad14f..ed0b3cc06 100644 --- a/quic/congestion_control/NewReno.h +++ b/quic/congestion_control/NewReno.h @@ -24,9 +24,7 @@ class NewReno : public CongestionController { void onPacketAckOrLoss( const AckEvent* FOLLY_NULLABLE, const LossEvent* FOLLY_NULLABLE) override; - void onPacketAckOrLoss( - folly::Optional ack, - folly::Optional loss) { + void onPacketAckOrLoss(Optional ack, Optional loss) { onPacketAckOrLoss(ack.get_pointer(), loss.get_pointer()); } @@ -61,6 +59,6 @@ class NewReno : public CongestionController { QuicConnectionStateBase& conn_; uint64_t ssthresh_; uint64_t cwndBytes_; - folly::Optional endOfRecovery_; + Optional endOfRecovery_; }; } // namespace quic diff --git a/quic/congestion_control/PacketProcessor.h b/quic/congestion_control/PacketProcessor.h index c31f83792..df02c8595 100644 --- a/quic/congestion_control/PacketProcessor.h +++ b/quic/congestion_control/PacketProcessor.h @@ -17,7 +17,7 @@ namespace quic { class PacketProcessor { public: struct PrewriteRequest { - folly::Optional cmsgs; + Optional cmsgs; }; virtual ~PacketProcessor() = default; @@ -26,8 +26,8 @@ class PacketProcessor { * Called before a write loop start. The returned PrewriteRequest * will apply to that write loop only. */ - virtual folly::Optional prewrite() { - return folly::none; + virtual Optional prewrite() { + return none; } /** diff --git a/quic/congestion_control/QuicCubic.cpp b/quic/congestion_control/QuicCubic.cpp index 5f510e488..85d9108eb 100644 --- a/quic/congestion_control/QuicCubic.cpp +++ b/quic/congestion_control/QuicCubic.cpp @@ -331,7 +331,7 @@ void Cubic::onPacketAckOrLoss( const AckEvent* FOLLY_NULLABLE ackEvent, const LossEvent* FOLLY_NULLABLE lossEvent) { // TODO: current code in detectLossPackets only gives back a loss event when - // largestLostPacketNum isn't a folly::none. But we should probably also check + // largestLostPacketNum isn't a none. But we should probably also check // against it here anyway just in case the loss code is changed in the // future. if (lossEvent) { @@ -453,7 +453,7 @@ void Cubic::onPacketAckedInHystart(const AckEvent& ack) { conn_.transportSettings.maxCwndInMss, conn_.transportSettings.minCwndInMss); - folly::Optional exitReason; + Optional exitReason; SCOPE_EXIT { if (hystartState_.found != Cubic::HystartFound::No && cwndBytes_ >= kLowSsthreshInMss * conn_.udpSendPacketLen) { diff --git a/quic/congestion_control/QuicCubic.h b/quic/congestion_control/QuicCubic.h index 126709d0e..96e54b0cb 100644 --- a/quic/congestion_control/QuicCubic.h +++ b/quic/congestion_control/QuicCubic.h @@ -79,9 +79,7 @@ class Cubic : public CongestionController { void onPacketAckOrLoss( const AckEvent* FOLLY_NULLABLE, const LossEvent* FOLLY_NULLABLE) override; - void onPacketAckOrLoss( - folly::Optional ack, - folly::Optional loss) { + void onPacketAckOrLoss(Optional ack, Optional loss) { onPacketAckOrLoss(ack.get_pointer(), loss.get_pointer()); } void onRemoveBytesFromInflight(uint64_t) override; @@ -145,6 +143,10 @@ class Cubic : public CongestionController { QuicConnectionStateBase& conn_; uint64_t cwndBytes_; + // the value of cwndBytes_ at last loss event + Optional lossCwndBytes_; + // the value of ssthresh_ at the last loss event + Optional lossSsthresh_; uint64_t ssthresh_; struct HystartState { @@ -160,11 +162,11 @@ class Cubic : public CongestionController { TimePoint lastJiffy; // The minimal of sampled RTT in current RTT round. Hystart only samples // first a few RTTs in a round - folly::Optional currSampledRtt; + Optional currSampledRtt; // End value of currSampledRtt at the end of a RTT round: - folly::Optional lastSampledRtt; + Optional lastSampledRtt; // Estimated minimal delay of a path - folly::Optional delayMin; + Optional delayMin; // Ack sampling count uint8_t ackCount{0}; // When a packet with sent time >= rttRoundEndTarget is acked, end the @@ -176,12 +178,12 @@ class Cubic : public CongestionController { // time takes for cwnd to increase to lastMaxCwndBytes double timeToOrigin{0.0}; // The cwnd value that timeToOrigin is calculated based on - folly::Optional originPoint; + Optional originPoint; bool tcpFriendly{true}; - folly::Optional lastReductionTime; + Optional lastReductionTime; // This is Wmax, it could be different from lossCwndBytes if cwnd never // reaches last lastMaxCwndBytes before loss event: - folly::Optional lastMaxCwndBytes; + Optional lastMaxCwndBytes; uint64_t estRenoCwnd; // cache reduction/increase factors based on numEmulatedConnections_ float reductionFactor{kDefaultCubicReductionFactor}; @@ -191,11 +193,11 @@ class Cubic : public CongestionController { struct RecoveryState { // The time point after which Quic will no longer be in current recovery - folly::Optional endOfRecovery; + Optional endOfRecovery; }; // if quiescenceStart_ has a value, then the connection is app limited - folly::Optional quiescenceStart_; + Optional quiescenceStart_; HystartState hystartState_; SteadyState steadyState_; diff --git a/quic/congestion_control/SimulatedTBF.cpp b/quic/congestion_control/SimulatedTBF.cpp index c845fb88e..f557f88a1 100644 --- a/quic/congestion_control/SimulatedTBF.cpp +++ b/quic/congestion_control/SimulatedTBF.cpp @@ -73,12 +73,11 @@ double SimulatedTBF::consumeWithBorrowNonBlockingAndUpdateState( } // Send (consume tokens) and determine if any new debt. - folly::Optional maybeDebtPayOffTimeDouble = - consumeWithBorrowNonBlocking( - toConsume, - config_.rateBytesPerSecond, - config_.burstSizeBytes, - sendTimeDouble); + Optional maybeDebtPayOffTimeDouble = consumeWithBorrowNonBlocking( + toConsume, + config_.rateBytesPerSecond, + config_.burstSizeBytes, + sendTimeDouble); DCHECK(maybeDebtPayOffTimeDouble.hasValue()); if (maybeDebtPayOffTimeDouble.value() > 0) { // Bucket is in debt now after consuming toConsume tokens @@ -198,8 +197,7 @@ void SimulatedTBF::forgetEmptyIntervalsPriorTo(const TimePoint& time) { return config_.burstSizeBytes; } -[[nodiscard]] folly::Optional SimulatedTBF::getMaxDebtQueueSizeBytes() - const { +[[nodiscard]] Optional SimulatedTBF::getMaxDebtQueueSizeBytes() const { return config_.maybeMaxDebtQueueSizeBytes; } diff --git a/quic/congestion_control/SimulatedTBF.h b/quic/congestion_control/SimulatedTBF.h index 7e5a78cbe..b5d2a51c0 100644 --- a/quic/congestion_control/SimulatedTBF.h +++ b/quic/congestion_control/SimulatedTBF.h @@ -47,7 +47,7 @@ class SimulatedTBF : private folly::BasicDynamicTokenBucket< struct Config { double rateBytesPerSecond{0}; double burstSizeBytes{0}; - folly::Optional maybeMaxDebtQueueSizeBytes; + Optional maybeMaxDebtQueueSizeBytes; // Whether the SimulatedTBF will keep track of when TBF was empty. bool trackEmptyIntervals{true}; @@ -138,7 +138,7 @@ class SimulatedTBF : private folly::BasicDynamicTokenBucket< [[nodiscard]] double getBurstSizeBytes() const; - [[nodiscard]] folly::Optional getMaxDebtQueueSizeBytes() const; + [[nodiscard]] Optional getMaxDebtQueueSizeBytes() const; private: static double timePointToDouble(TimePoint timePoint) { @@ -146,8 +146,8 @@ class SimulatedTBF : private folly::BasicDynamicTokenBucket< } struct EmptyIntervalState { std::shared_ptr> emptyBucketTimeIntervals_; - folly::Optional maybeLastSendTimeBucketNotEmpty_; - folly::Optional maybeLastForgetEmptyIntervalTime_; + Optional maybeLastSendTimeBucketNotEmpty_; + Optional maybeLastForgetEmptyIntervalTime_; }; EmptyIntervalState& getEmptyIntervalState(); @@ -155,6 +155,6 @@ class SimulatedTBF : private folly::BasicDynamicTokenBucket< Config config_; double zeroTime_{0}; - folly::Optional maybeEmptyIntervalState_; + Optional maybeEmptyIntervalState_; }; } // namespace quic diff --git a/quic/congestion_control/ThrottlingSignalProvider.h b/quic/congestion_control/ThrottlingSignalProvider.h index 18ba1f35f..528ea9329 100644 --- a/quic/congestion_control/ThrottlingSignalProvider.h +++ b/quic/congestion_control/ThrottlingSignalProvider.h @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace quic { @@ -25,17 +25,17 @@ class ThrottlingSignalProvider { // stores the amount of tokens currently available at throttler's bucket // and if the bucket is in debt, it stores zero. // Note that this value changes over time and may become stale quickly. - folly::Optional maybeBytesToSend; + Optional maybeBytesToSend; // The rate for which CCA can send bytes when the connection is being // throttled (ie when the bucket has no tokens). // Note that this value changes over time and may become stale quickly. - folly::Optional maybeThrottledRateBytesPerSecond; + Optional maybeThrottledRateBytesPerSecond; // The rate for which CCA can send bytes when the connection is not being // throttled (eg during burst or generally when the bucket has tokens). // Note that this value changes over time and may become stale quickly. - folly::Optional maybeBurstRateBytesPerSecond; + Optional maybeBurstRateBytesPerSecond; }; virtual ~ThrottlingSignalProvider() = default; @@ -44,7 +44,7 @@ class ThrottlingSignalProvider { * Returns the current value of throttling signal, if exists. * Its return value changes over time and may become stale quickly. */ - virtual folly::Optional getCurrentThrottlingSignal() = 0; + virtual Optional getCurrentThrottlingSignal() = 0; }; } // namespace quic diff --git a/quic/congestion_control/TokenlessPacer.h b/quic/congestion_control/TokenlessPacer.h index f6939df6e..fbb79986e 100644 --- a/quic/congestion_control/TokenlessPacer.h +++ b/quic/congestion_control/TokenlessPacer.h @@ -55,7 +55,7 @@ class TokenlessPacer : public Pacer { uint64_t maxPacingRateBytesPerSec_{std::numeric_limits::max()}; std::chrono::microseconds writeInterval_{0}; PacingRateCalculator pacingRateCalculator_; - folly::Optional lastWriteTime_; + Optional lastWriteTime_; uint8_t rttFactorNumerator_{1}; uint8_t rttFactorDenominator_{1}; bool experimental_{false}; diff --git a/quic/congestion_control/test/BbrTest.cpp b/quic/congestion_control/test/BbrTest.cpp index 9b4cd650b..2b1864cd2 100644 --- a/quic/congestion_control/test/BbrTest.cpp +++ b/quic/congestion_control/test/BbrTest.cpp @@ -106,7 +106,7 @@ TEST_F(BbrTest, Recovery) { // This doesn't change endOfRoundTrip_, but move endOfRecovery to new // Clock::now() auto estimatedLossTime = Clock::now(); - bbr.onPacketAckOrLoss(folly::none, loss2); + bbr.onPacketAckOrLoss(none, loss2); EXPECT_EQ(expectedRecoveryWindow, bbr.getCongestionWindow()); ackedBytes = 500; @@ -118,7 +118,7 @@ TEST_F(BbrTest, Recovery) { ackedBytes, estimatedLossTime - 1us, estimatedEndOfRoundTrip + 1us), - folly::none); + none); EXPECT_TRUE(bbr.inRecovery()); // Since recoveryWindow_ is larger than inflightBytes + recoveryIncrase EXPECT_EQ(expectedRecoveryWindow, bbr.getCongestionWindow()); @@ -128,13 +128,13 @@ TEST_F(BbrTest, Recovery) { loss3.persistentCongestion = true; loss3.lostBytes = inflightBytes / 2; expectedRecoveryWindow = conn.udpSendPacketLen * kMinCwndInMssForBbr; - bbr.onPacketAckOrLoss(folly::none, loss3); + bbr.onPacketAckOrLoss(none, loss3); EXPECT_EQ(expectedRecoveryWindow, bbr.getCongestionWindow()); CongestionController::AckEvent ack3 = makeAck( 12, inflightBytes / 2, estimatedLossTime + 10ms, estimatedLossTime + 5ms); // This will exit Recovery - bbr.onPacketAckOrLoss(ack3, folly::none); + bbr.onPacketAckOrLoss(ack3, none); EXPECT_FALSE(bbr.inRecovery()); // Only one update should have been issued. ASSERT_EQ(conn.pendingEvents.frames.size(), 1); @@ -166,7 +166,7 @@ TEST_F(BbrTest, StartupCwnd) { // Target cwnd will be 100 * 5000 * 2.885 = 1442500, but you haven't finished // STARTUP, too bad kiddo, you only grow a little today bbr.onPacketAckOrLoss( - makeAck(0, 3000, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 3000, Clock::now(), packet.metadata.time), none); EXPECT_EQ(startingCwnd + 3000, bbr.getCongestionWindow()); } @@ -194,7 +194,7 @@ TEST_F(BbrTest, StartupCwndImplicit) { // STARTUP, too bad kiddo, you only grow a little today auto ack = makeAck(0, 3000, Clock::now(), packet.metadata.time); ack.implicit = true; - bbr.onPacketAckOrLoss(ack, folly::none); + bbr.onPacketAckOrLoss(ack, none); EXPECT_EQ(startingCwnd + 3000, bbr.getCongestionWindow()); } @@ -222,8 +222,7 @@ TEST_F(BbrTest, LeaveStartup) { .WillRepeatedly(Return( mockedBandwidth * (growFast ? kExpectedStartupGrowth : 1.0))); bbr.onPacketAckOrLoss( - makeAck(currentLatest, 1000, Clock::now(), packet.metadata.time), - folly::none); + makeAck(currentLatest, 1000, Clock::now(), packet.metadata.time), none); conn.lossState.totalBytesAcked += 1000; if (growFast) { mockedBandwidth = mockedBandwidth * kExpectedStartupGrowth; @@ -309,7 +308,7 @@ TEST_F(BbrTest, ProbeRtt) { conn.udpSendPacketLen, Clock::now(), packetToAck.second), - folly::none); + none); conn.lossState.totalBytesAcked += conn.udpSendPacketLen; inflightBytes -= conn.udpSendPacketLen; inflightPackets.pop_front(); @@ -327,7 +326,7 @@ TEST_F(BbrTest, ProbeRtt) { conn.udpSendPacketLen, Clock::now(), packetToAck.second), - folly::none); + none); conn.lossState.totalBytesAcked += conn.udpSendPacketLen; inflightBytes -= conn.udpSendPacketLen; inflightPackets.pop_front(); @@ -344,7 +343,7 @@ TEST_F(BbrTest, ProbeRtt) { conn.udpSendPacketLen, Clock::now(), packetToAck.second), - folly::none); + none); conn.lossState.totalBytesAcked += conn.udpSendPacketLen; inflightBytes -= conn.udpSendPacketLen; inflightPackets.pop_front(); @@ -361,7 +360,7 @@ TEST_F(BbrTest, ProbeRtt) { conn.udpSendPacketLen, currentTime, packetToAck.second), - folly::none); + none); conn.lossState.totalBytesAcked += conn.udpSendPacketLen; inflightBytes -= conn.udpSendPacketLen; inflightPackets.pop_front(); @@ -376,7 +375,7 @@ TEST_F(BbrTest, ProbeRtt) { conn.udpSendPacketLen, packetToAck.second + 1ms, packetToAck.second), - folly::none); + none); inflightBytes -= conn.udpSendPacketLen; inflightPackets.pop_front(); EXPECT_EQ(BbrCongestionController::BbrState::ProbeRtt, bbr.state()); @@ -393,7 +392,7 @@ TEST_F(BbrTest, ProbeRtt) { conn.udpSendPacketLen, packetToAck.second + 2ms, packetToAck.second), - folly::none); + none); inflightBytes -= conn.udpSendPacketLen; inflightPackets.pop_front(); EXPECT_EQ(BbrCongestionController::BbrState::ProbeRtt, bbr.state()); @@ -411,7 +410,7 @@ TEST_F(BbrTest, ProbeRtt) { conn.udpSendPacketLen, packetToAck.second + kProbeRttDuration, packetToAck.second), - folly::none); + none); conn.lossState.totalBytesAcked += conn.udpSendPacketLen; inflightBytes -= conn.udpSendPacketLen; inflightPackets.pop_front(); @@ -557,7 +556,7 @@ TEST_F(BbrTest, AckAggregation) { // force send time < ack time Clock::now() + std::chrono::milliseconds(10), packet.metadata.time), - folly::none); + none); conn.lossState.totalBytesAcked += 1000; if (growFast) { mockedBandwidth = mockedBandwidth * kExpectedStartupGrowth; @@ -603,7 +602,7 @@ TEST_F(BbrTest, AckAggregation) { .WillRepeatedly(Return(mockedBandwidth * 10)); auto expectedBdp = mockedBandwidth * 50 * std::chrono::microseconds(50) / 1000 / 1000; - bbr.onPacketAckOrLoss(ackEvent, folly::none); + bbr.onPacketAckOrLoss(ackEvent, none); auto newCwnd = bbr.getCongestionWindow(); auto currentMaxAckHeight = 0; if (newCwnd != currentCwnd + 1000) { @@ -626,7 +625,7 @@ TEST_F(BbrTest, AckAggregation) { ackEvent.ackTime + 1ms, packet1.metadata.time); - bbr.onPacketAckOrLoss(ackEvent2, folly::none); + bbr.onPacketAckOrLoss(ackEvent2, none); newCwnd = bbr.getCongestionWindow(); EXPECT_GT(newCwnd, expectedBdp * kProbeBwGain + currentMaxAckHeight); } @@ -695,7 +694,7 @@ TEST_F(BbrTest, ExtendMinRttExpiration) { 1000, Clock::now(), packet.metadata.time), - folly::none); + none); } TEST_F(BbrTest, BytesCounting) { @@ -753,7 +752,7 @@ TEST_F(BbrTest, PacketLossInvokesPacer) { EXPECT_CALL(*rawPacer, onPacketsLoss()).Times(1); CongestionController::LossEvent lossEvent; lossEvent.addLostPacket(packet); - bbr.onPacketAckOrLoss(folly::none, lossEvent); + bbr.onPacketAckOrLoss(none, lossEvent); } TEST_F(BbrTest, ProbeRttSetsAppLimited) { @@ -770,13 +769,13 @@ TEST_F(BbrTest, ProbeRttSetsAppLimited) { EXPECT_CALL(*rawRttSampler, minRttExpired()).Times(1).WillOnce(Return(true)); EXPECT_CALL(*rawBandwidthSampler, onAppLimited()).Times(2); bbr.onPacketAckOrLoss( - makeAck(0, 1000, Clock::now(), Clock::now() - 5ms), folly::none); + makeAck(0, 1000, Clock::now(), Clock::now() - 5ms), none); EXPECT_EQ(BbrCongestionController::BbrState::ProbeRtt, bbr.state()); bbr.onPacketSent(makeTestingWritePacket(1, 1000, 2000)); EXPECT_CALL(*rawBandwidthSampler, onAppLimited()).Times(1); bbr.onPacketAckOrLoss( - makeAck(1, 1000, Clock::now(), Clock::now() - 5ms), folly::none); + makeAck(1, 1000, Clock::now(), Clock::now() - 5ms), none); EXPECT_EQ(BbrCongestionController::BbrState::ProbeRtt, bbr.state()); } diff --git a/quic/congestion_control/test/Copa2Test.cpp b/quic/congestion_control/test/Copa2Test.cpp index 49e92f8e0..0da79794a 100644 --- a/quic/congestion_control/test/Copa2Test.cpp +++ b/quic/congestion_control/test/Copa2Test.cpp @@ -96,7 +96,7 @@ TEST_F(Copa2Test, PersistentCongestion) { CongestionController::LossEvent loss; loss.persistentCongestion = true; loss.addLostPacket(pkt); - copa2.onPacketAckOrLoss(folly::none, loss); + copa2.onPacketAckOrLoss(none, loss); EXPECT_EQ( copa2.getCongestionWindow(), conn.transportSettings.minCwndInMss * conn.udpSendPacketLen); @@ -172,7 +172,7 @@ TEST_F(Copa2Test, TestBwEstimate) { // You get the ack for the first 5 packets after 100ms all at once conn.lossState.lrtt = 100ms; now += 100ms; - copa2.onPacketAckOrLoss(createAckEvent(5, 5 * packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(5, 5 * packetSize, now), none); numPacketsInFlight -= 5; EXPECT_EQ(copa2.getBytesInFlight(), numPacketsInFlight * packetSize); // Not enough time has passed for cwnd to increase @@ -184,7 +184,7 @@ TEST_F(Copa2Test, TestBwEstimate) { now += 210ms; conn.lossState.lrtt = 500ms; // Large value should be ignored since // only the min rtt should matter. - copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), none); EXPECT_EQ( copa2.getCongestionWindow(), (6 + alphaParam) * conn.udpSendPacketLen); EXPECT_FALSE(copa2.inLossyMode()); @@ -224,10 +224,10 @@ TEST_F(Copa2Test, PacketLossInvokesPacer) { EXPECT_CALL(*rawPacer, onPacketsLoss()).Times(1); CongestionController::LossEvent lossEvent; lossEvent.addLostPacket(packet); - copa2.onPacketAckOrLoss(folly::none, lossEvent); + copa2.onPacketAckOrLoss(none, lossEvent); // Ack one packet to test how we set pacing rate copa2.onPacketSent(createPacket(1, 1000, 2000)); - copa2.onPacketAckOrLoss(createAckEvent(1, 1000, Clock::now()), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, 1000, Clock::now()), none); } TEST_F(Copa2Test, ProbeRttHappens) { @@ -248,28 +248,28 @@ TEST_F(Copa2Test, ProbeRttHappens) { now += 10ms; // Set the min rtt conn.lossState.lrtt = 100ms; - copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), none); EXPECT_FALSE(copa2.inProbeRtt()); now += kCopa2ProbeRttInterval / 2; conn.lossState.lrtt = 250ms; - copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), none); EXPECT_FALSE(copa2.inProbeRtt()); now += kCopa2ProbeRttInterval / 2; - copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), none); EXPECT_TRUE(copa2.inProbeRtt()); conn.lossState.lrtt = 150ms; now += kCopa2ProbeRttInterval / 2 - 50ms; - copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), none); EXPECT_FALSE(copa2.inProbeRtt()); // If delay is small enough, it will enter probe rtt after half the usual // period conn.lossState.lrtt = 150ms; now += 100ms; - copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), none); EXPECT_TRUE(copa2.inProbeRtt()); } @@ -302,7 +302,7 @@ TEST_F(Copa2Test, LossModeHappens) { loss.lostPackets = 1; loss.largestLostSentTime = now; // Start the cycle - copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), none); now += 21ms; // End it copa2.onPacketAckOrLoss(createAckEvent(8, 7 * packetSize, now), loss); @@ -312,7 +312,7 @@ TEST_F(Copa2Test, LossModeHappens) { // Should shift to loss mode now loss.largestLostPacketNum = 10; - copa2.onPacketAckOrLoss(folly::none, loss); + copa2.onPacketAckOrLoss(none, loss); EXPECT_TRUE(copa2.inLossyMode()); // Send the next cycle and ensure that we are sending fewer packets @@ -322,7 +322,7 @@ TEST_F(Copa2Test, LossModeHappens) { // Ack it at 10ms + 10ms * 2 * lossToleranceParam + 1ms now += 12ms; - copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), folly::none); + copa2.onPacketAckOrLoss(createAckEvent(1, packetSize, now), none); EXPECT_EQ( copa2.getCongestionWindow(), packetSize + alphaParam * conn.udpSendPacketLen); diff --git a/quic/congestion_control/test/CopaTest.cpp b/quic/congestion_control/test/CopaTest.cpp index 925d69f2a..fbf5921d9 100644 --- a/quic/congestion_control/test/CopaTest.cpp +++ b/quic/congestion_control/test/CopaTest.cpp @@ -121,7 +121,7 @@ class CopaTest : public Test { // ack for first packet, lastCwndDoubleTime_ will be initialized now copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + createAckEvent(packetNumToAck, packetSize, now), none); numPacketsInFlight--; EXPECT_EQ(copa.getBytesInFlight(), numPacketsInFlight * packetSize); @@ -143,7 +143,7 @@ class CopaTest : public Test { conn.lossState.srtt = 100ms; copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + createAckEvent(packetNumToAck, packetSize, now), none); packetNumToAck++; EXPECT_FALSE(copa.inSlowStart()); uint64_t cwndChange = @@ -200,7 +200,7 @@ TEST_F(CopaTest, PersistentCongestion) { CongestionController::LossEvent loss; loss.persistentCongestion = true; loss.addLostPacket(pkt); - copa.onPacketAckOrLoss(folly::none, loss); + copa.onPacketAckOrLoss(none, loss); EXPECT_EQ( copa.getWritableBytes(), conn.transportSettings.minCwndInMss * conn.udpSendPacketLen); @@ -280,8 +280,7 @@ TEST_F(CopaTest, TestSlowStartAck) { conn.lossState.srtt = 280ms; // ack for first packet, lastCwndDoubleTime_ will be initialized now - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); numPacketsInFlight--; EXPECT_EQ(copa.getBytesInFlight(), numPacketsInFlight * packetSize); @@ -301,11 +300,9 @@ TEST_F(CopaTest, TestSlowStartAck) { auto lastCwnd = copa.getCongestionWindow(); // Say more time passed and some packets were acked meanwhile. - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); packetNumToAck++; - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); packetNumToAck++; now += 300ms; @@ -314,8 +311,7 @@ TEST_F(CopaTest, TestSlowStartAck) { // RTTmin = 280ms conn.lossState.srtt = 300ms; - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); packetNumToAck++; now += 100ms; @@ -326,8 +322,7 @@ TEST_F(CopaTest, TestSlowStartAck) { // ack for 5th packet, at this point currentRate < targetRate, but not enough // time has passed for cwnd to double again in slow start - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); EXPECT_TRUE(copa.inSlowStart()); EXPECT_EQ(copa.getCongestionWindow(), lastCwnd); @@ -341,8 +336,7 @@ TEST_F(CopaTest, TestSlowStartAck) { // ack for 6th packet, at this point even though lrtt has increased, standing // rtt hasn't. Hence it will still not exit slow start - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); EXPECT_TRUE(copa.inSlowStart()); // cwnd = 40 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd); @@ -354,8 +348,7 @@ TEST_F(CopaTest, TestSlowStartAck) { // ack for 7th packet, at this point currentRate > targetRate, so it would // exit slow start and reduce cwnd - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); EXPECT_FALSE(copa.inSlowStart()); EXPECT_LE(copa.getCongestionWindow(), lastCwnd); } @@ -378,8 +371,7 @@ TEST_F(CopaTest, TestSteadyStateChanges) { conn.lossState.lrtt = 100ms; // Rttmin = 100ms conn.lossState.srtt = 100ms; - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); packetNumToAck++; uint64_t cwndChange = cwndChangeSteadyState(lastCwnd, 1.0, packetSize, 0.5, conn); @@ -393,8 +385,7 @@ TEST_F(CopaTest, TestSteadyStateChanges) { conn.lossState.lrtt = 50ms; // Rttmin = 60ms conn.lossState.srtt = 100ms; - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); packetNumToAck++; cwndChange = cwndChangeSteadyState(lastCwnd, 1.0, packetSize, 0.5, conn); // cwnd = 9.6 + 1 / (0.5 * 9.6) = 9.8 packets @@ -406,8 +397,7 @@ TEST_F(CopaTest, TestSteadyStateChanges) { // Rttmin = 60ms conn.lossState.srtt = 100ms; // Though lrtt has increased, rtt standing has not. Will still increase - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); packetNumToAck++; cwndChange = cwndChangeSteadyState(lastCwnd, 1.0, packetSize, 0.5, conn); // cwnd = 9.8 + 1 / (0.5 * 9.8) = 10.0 packets @@ -416,8 +406,7 @@ TEST_F(CopaTest, TestSteadyStateChanges) { // If sufficient time has elapsed, the increased rtt will be noted now += 110ms; - copa.onPacketAckOrLoss( - createAckEvent(packetNumToAck, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(packetNumToAck, packetSize, now), none); packetNumToAck++; cwndChange = cwndChangeSteadyState(lastCwnd, 1.0, packetSize, 0.5, conn); // cwnd = 10 - 1 / (0.5 * 10) = 9.8 @@ -449,7 +438,7 @@ TEST_F(CopaTest, TestVelocity) { conn.lossState.srtt = 100ms; now += 100ms; // velocity = 1, direction = 0 - copa.onPacketAckOrLoss(createAckEvent(30, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(30, packetSize, now), none); uint64_t cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); @@ -459,7 +448,7 @@ TEST_F(CopaTest, TestVelocity) { // another ack, velocity = 1, direction 0 -> 1 now += 100ms; - copa.onPacketAckOrLoss(createAckEvent(35, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(35, packetSize, now), none); cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); // cwnd = 10 + 1 / (0.5 * 10) = 10.2 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd + cwndChange); @@ -467,7 +456,7 @@ TEST_F(CopaTest, TestVelocity) { // another ack, velocity = 1, direction = 1 now += 100ms; - copa.onPacketAckOrLoss(createAckEvent(40, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(40, packetSize, now), none); cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); // cwnd = 10.2 + 1 / (0.5 * 10.2) = 10.4 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd + cwndChange); @@ -475,7 +464,7 @@ TEST_F(CopaTest, TestVelocity) { // another ack, velocity = 1, direction = 1 now += 100ms; - copa.onPacketAckOrLoss(createAckEvent(45, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(45, packetSize, now), none); cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); // cwnd = 10.4 + 1 / (0.5 * 10.4) = 10.6 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd + cwndChange); @@ -483,7 +472,7 @@ TEST_F(CopaTest, TestVelocity) { // another ack, velocity = 1, direction = 1 now += 100ms; - copa.onPacketAckOrLoss(createAckEvent(50, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(50, packetSize, now), none); cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); // cwnd = 10.4 + 1 / (0.5 * 10.4) = 10.6 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd + cwndChange); @@ -492,7 +481,7 @@ TEST_F(CopaTest, TestVelocity) { // another ack, velocity = 2, direction = 1 velocity = 2 * velocity; now += 100ms; - copa.onPacketAckOrLoss(createAckEvent(55, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(55, packetSize, now), none); cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); // cwnd = 10 + 2 / (0.5 * 10.6) = 11 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd + cwndChange); @@ -501,7 +490,7 @@ TEST_F(CopaTest, TestVelocity) { // another ack, velocity = 4, direction = 1 velocity = 2 * velocity; now += 100ms; - copa.onPacketAckOrLoss(createAckEvent(60, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(60, packetSize, now), none); cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); // cwnd = 11 + 4 / (0.5 * 11) = 11.8 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd + cwndChange); @@ -510,7 +499,7 @@ TEST_F(CopaTest, TestVelocity) { // another ack, velocity = 8, direction = 1 velocity = 2 * velocity; now += 100ms; - copa.onPacketAckOrLoss(createAckEvent(65, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(65, packetSize, now), none); cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); // cwnd = 11.8 + 8 / (0.5 * 11.8) = 13.4 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd + cwndChange); @@ -524,7 +513,7 @@ TEST_F(CopaTest, TestVelocity) { velocity = 1; // give it some extra time for rtt standing to reset now += 110ms; - copa.onPacketAckOrLoss(createAckEvent(50, packetSize, now), folly::none); + copa.onPacketAckOrLoss(createAckEvent(50, packetSize, now), none); cwndChange = cwndChangeSteadyState(lastCwnd, velocity, packetSize, 0.5, conn); // cwnd = 11.8 + 8 / (0.5 * 11.8) = 13.4 packets EXPECT_EQ(copa.getCongestionWindow(), lastCwnd - cwndChange); @@ -575,7 +564,7 @@ TEST_F(CopaTest, PacketLossInvokesPacer) { EXPECT_CALL(*rawPacer, onPacketsLoss()).Times(1); CongestionController::LossEvent lossEvent; lossEvent.addLostPacket(packet); - copa.onPacketAckOrLoss(folly::none, lossEvent); + copa.onPacketAckOrLoss(none, lossEvent); } } // namespace test diff --git a/quic/congestion_control/test/CubicHystartTest.cpp b/quic/congestion_control/test/CubicHystartTest.cpp index daa44b41c..a26b5110b 100644 --- a/quic/congestion_control/test/CubicHystartTest.cpp +++ b/quic/congestion_control/test/CubicHystartTest.cpp @@ -29,7 +29,7 @@ TEST_F(CubicHystartTest, SendAndAck) { auto packet = makeTestingWritePacket(0, 1000, 1000); cubic.onPacketSent(packet); cubic.onPacketAckOrLoss( - makeAck(0, 1000, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 1000, Clock::now(), packet.metadata.time), none); EXPECT_EQ(initCwnd + 1000, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::Hystart, cubic.state()); @@ -46,7 +46,7 @@ TEST_F(CubicHystartTest, CwndLargerThanSSThresh) { auto packet = makeTestingWritePacket(0, 1000, 1000); cubic.onPacketSent(packet); cubic.onPacketAckOrLoss( - makeAck(0, 1000, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 1000, Clock::now(), packet.metadata.time), none); EXPECT_EQ(initCwnd + 1000, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::Steady, cubic.state()); } @@ -66,7 +66,7 @@ TEST_F(CubicHystartTest, NoDelayIncrease) { auto packet = makeTestingWritePacket(0, 1000, 1000, realNow); cubic.onPacketSent(packet); cubic.onPacketAckOrLoss( - makeAck(0, 1000, realNow + 2us, packet.metadata.time), folly::none); + makeAck(0, 1000, realNow + 2us, packet.metadata.time), none); EXPECT_EQ(initCwnd + 1000, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::Hystart, cubic.state()); } @@ -95,7 +95,7 @@ TEST_F(CubicHystartTest, AckTrain) { kLowSsthreshInMss * conn.udpSendPacketLen, realNow, packet0.metadata.time), - folly::none); + none); // Packet 1 is acked: cubic.onPacketAckOrLoss( makeAck( @@ -103,7 +103,7 @@ TEST_F(CubicHystartTest, AckTrain) { kLowSsthreshInMss * conn.udpSendPacketLen, realNow + 2us, packet1.metadata.time), - folly::none); + none); EXPECT_EQ( initCwnd + kLowSsthreshInMss * conn.udpSendPacketLen * 2, cubic.getWritableBytes()); @@ -126,7 +126,7 @@ TEST_F(CubicHystartTest, NoAckTrainNoDelayIncrease) { cubic.onPacketSent(packet); cubic.onPacketAckOrLoss( makeAck(0, 1000, realNow + kAckCountingGap + 2us, packet.metadata.time), - folly::none); + none); EXPECT_EQ(initCwnd + 1000, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::Hystart, cubic.state()); } @@ -145,7 +145,7 @@ TEST_F(CubicHystartTest, DelayIncrease) { cubic.onPacketSent(packet); cubic.onPacketAckOrLoss( makeAck(packetNum++, fullSize, Clock::now(), packet.metadata.time), - folly::none); + none); totalSent += fullSize; } @@ -173,12 +173,10 @@ TEST_F(CubicHystartTest, DelayIncrease) { auto ackTimeIncrease = 2ms; ackTime += ackTimeIncrease; cubic.onPacketAckOrLoss( - makeAck(firstPacketNum, 1000, ackTime, packet0.metadata.time), - folly::none); + makeAck(firstPacketNum, 1000, ackTime, packet0.metadata.time), none); ackTime += ackTimeIncrease; cubic.onPacketAckOrLoss( - makeAck(secondPacketNum, 1000, ackTime, packet1.metadata.time), - folly::none); + makeAck(secondPacketNum, 1000, ackTime, packet1.metadata.time), none); auto estimatedRttEndTarget = Clock::now(); auto packet2 = makeTestingWritePacket( @@ -189,7 +187,7 @@ TEST_F(CubicHystartTest, DelayIncrease) { // This will end current RTT round and start a new one next time Ack happens: ackTime = packet2.metadata.time + ackTimeIncrease; cubic.onPacketAckOrLoss( - makeAck(packetNum, 1000, ackTime, packet2.metadata.time), folly::none); + makeAck(packetNum, 1000, ackTime, packet2.metadata.time), none); packetNum++; auto cwndEndRound = cubic.getWritableBytes(); @@ -209,7 +207,7 @@ TEST_F(CubicHystartTest, DelayIncrease) { packetNum++; } for (auto& ack : moreAcks) { - cubic.onPacketAckOrLoss(ack, folly::none); + cubic.onPacketAckOrLoss(ack, none); } // kAckSampling-th onPacketAcked in this round. This will trigger // DelayIncrease: @@ -220,7 +218,7 @@ TEST_F(CubicHystartTest, DelayIncrease) { totalSent += 1000; ackTime += ackTimeIncrease; cubic.onPacketAckOrLoss( - makeAck(packetNum, 1000, ackTime, packetEnd.metadata.time), folly::none); + makeAck(packetNum, 1000, ackTime, packetEnd.metadata.time), none); EXPECT_EQ(cwndEndRound + 1000 * kAckSampling, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::Steady, cubic.state()); @@ -249,19 +247,16 @@ TEST_F(CubicHystartTest, DelayIncreaseCwndTooSmall) { auto ackTime = realNow; auto ackTimeIncrease = 2us; ackTime += ackTimeIncrease; - cubic.onPacketAckOrLoss( - makeAck(0, 1, ackTime, packet0.metadata.time), folly::none); + cubic.onPacketAckOrLoss(makeAck(0, 1, ackTime, packet0.metadata.time), none); ackTime += ackTimeIncrease; - cubic.onPacketAckOrLoss( - makeAck(1, 1, ackTime, packet1.metadata.time), folly::none); + cubic.onPacketAckOrLoss(makeAck(1, 1, ackTime, packet1.metadata.time), none); auto packet2 = makeTestingWritePacket(2, 10, 10 + totalSent, realNow); conn.lossState.largestSent = 2; cubic.onPacketSent(packet2); totalSent += 10; ackTime += ackTimeIncrease; - cubic.onPacketAckOrLoss( - makeAck(2, 1, ackTime, packet2.metadata.time), folly::none); + cubic.onPacketAckOrLoss(makeAck(2, 1, ackTime, packet2.metadata.time), none); auto cwndEndRound = cubic.getWritableBytes(); // New RTT round, give currSampledRtt a value larger than previous RTT: @@ -277,7 +272,7 @@ TEST_F(CubicHystartTest, DelayIncreaseCwndTooSmall) { totalSent += 1; } for (auto& ack : moreAcks) { - cubic.onPacketAckOrLoss(ack, folly::none); + cubic.onPacketAckOrLoss(ack, none); } // kAckSampling-th onPacketAcked in this round. This will trigger // DelayIncrease: @@ -288,7 +283,7 @@ TEST_F(CubicHystartTest, DelayIncreaseCwndTooSmall) { totalSent += 1; ackTime += ackTimeIncrease; cubic.onPacketAckOrLoss( - makeAck(kAckSampling, 1, ackTime, packetEnd.metadata.time), folly::none); + makeAck(kAckSampling, 1, ackTime, packetEnd.metadata.time), none); auto expectedCwnd = cwndEndRound + 1 * kAckSampling; // Cwnd < kLowSsthresh, won't exit Hystart state: ASSERT_LT(expectedCwnd, kLowSsthreshInMss * conn.udpSendPacketLen); @@ -308,7 +303,7 @@ TEST_F(CubicHystartTest, ReduceByCubicReductionFactor) { // this decreases inflight by 1000, and then decreases cwnd by Cubic: CongestionController::LossEvent loss; loss.addLostPacket(packet); - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); EXPECT_EQ(initCwnd * kDefaultCubicReductionFactor, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); } diff --git a/quic/congestion_control/test/CubicRecoveryTest.cpp b/quic/congestion_control/test/CubicRecoveryTest.cpp index edd1632ab..d3b03d735 100644 --- a/quic/congestion_control/test/CubicRecoveryTest.cpp +++ b/quic/congestion_control/test/CubicRecoveryTest.cpp @@ -26,7 +26,7 @@ TEST_F(CubicRecoveryTest, LossBurst) { totalSent += 1000; CongestionController::LossEvent loss; loss.addLostPacket(packet0); - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); auto cwndAfterLoss = cubic.getCongestionWindow(); @@ -39,7 +39,7 @@ TEST_F(CubicRecoveryTest, LossBurst) { conn.lossState.largestSent = i; loss2.addLostPacket(packet); } - cubic.onPacketAckOrLoss(folly::none, std::move(loss2)); + cubic.onPacketAckOrLoss(none, std::move(loss2)); // Still in recovery: EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); // Cwnd should be reduced. @@ -56,7 +56,7 @@ TEST_F(CubicRecoveryTest, LossBeforeRecovery) { cubic.onPacketSent(packet); totalSent += 1000; cubic.onPacketAckOrLoss( - makeAck(0, 1000, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 1000, Clock::now(), packet.metadata.time), none); EXPECT_EQ(CubicStates::Hystart, cubic.state()); // Send three packets, lose second immediately. @@ -72,7 +72,7 @@ TEST_F(CubicRecoveryTest, LossBeforeRecovery) { conn.lossState.largestSent = 3; CongestionController::LossEvent loss2; loss2.addLostPacket(packet2); - cubic.onPacketAckOrLoss(folly::none, std::move(loss2)); + cubic.onPacketAckOrLoss(none, std::move(loss2)); // Should now be in recovery. Send packet4, receive acks for 3 and 4 which // should exit recovery with a certain cwnd. @@ -82,16 +82,16 @@ TEST_F(CubicRecoveryTest, LossBeforeRecovery) { totalSent += 1000; conn.lossState.largestSent = 4; cubic.onPacketAckOrLoss( - makeAck(3, 1000, Clock::now(), packet3.metadata.time), folly::none); + makeAck(3, 1000, Clock::now(), packet3.metadata.time), none); cubic.onPacketAckOrLoss( - makeAck(4, 1000, Clock::now(), packet4.metadata.time), folly::none); + makeAck(4, 1000, Clock::now(), packet4.metadata.time), none); auto cwndAfterRecovery = cubic.getCongestionWindow(); EXPECT_EQ(CubicStates::Steady, cubic.state()); // Now lose packet1, which should be ignored. CongestionController::LossEvent loss1; loss1.addLostPacket(packet1); - cubic.onPacketAckOrLoss(folly::none, std::move(loss1)); + cubic.onPacketAckOrLoss(none, std::move(loss1)); EXPECT_EQ(CubicStates::Steady, cubic.state()); EXPECT_EQ(cwndAfterRecovery, cubic.getCongestionWindow()); } @@ -104,14 +104,14 @@ TEST_F(CubicRecoveryTest, LossAfterRecovery) { auto packet = makeTestingWritePacket(0, 1000, 1000); cubic.onPacketSent(packet); cubic.onPacketAckOrLoss( - makeAck(0, 1000, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 1000, Clock::now(), packet.metadata.time), none); // Lose one packet. auto packet1 = makeTestingWritePacket(1, 1000, 2000); cubic.onPacketSent(packet1); conn.lossState.largestSent = 1; CongestionController::LossEvent loss1; loss1.addLostPacket(packet1); - cubic.onPacketAckOrLoss(folly::none, std::move(loss1)); + cubic.onPacketAckOrLoss(none, std::move(loss1)); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); auto cwndAfterLoss = cubic.getCongestionWindow(); @@ -121,7 +121,7 @@ TEST_F(CubicRecoveryTest, LossAfterRecovery) { conn.lossState.largestSent = 2; CongestionController::LossEvent loss2; loss2.addLostPacket(packet2); - cubic.onPacketAckOrLoss(folly::none, std::move(loss2)); + cubic.onPacketAckOrLoss(none, std::move(loss2)); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); EXPECT_TRUE(cwndAfterLoss > cubic.getCongestionWindow()); } @@ -145,19 +145,19 @@ TEST_F(CubicRecoveryTest, AckNotLargestNotChangeCwnd) { // packet5 is lost: loss.addLostPacket(packet5); - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); auto cwndAfterLoss = cubic.getWritableBytes() + 4000; // 4k are in flight // the the rest are acked: cubic.onPacketAckOrLoss( - makeAck(0, 1000, Clock::now(), packet1.metadata.time), folly::none); + makeAck(0, 1000, Clock::now(), packet1.metadata.time), none); cubic.onPacketAckOrLoss( - makeAck(1, 1000, Clock::now(), packet2.metadata.time), folly::none); + makeAck(1, 1000, Clock::now(), packet2.metadata.time), none); cubic.onPacketAckOrLoss( - makeAck(2, 1000, Clock::now(), packet3.metadata.time), folly::none); + makeAck(2, 1000, Clock::now(), packet3.metadata.time), none); cubic.onPacketAckOrLoss( - makeAck(3, 1000, Clock::now(), packet4.metadata.time), folly::none); + makeAck(3, 1000, Clock::now(), packet4.metadata.time), none); // Still in recovery: EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); diff --git a/quic/congestion_control/test/CubicStateTest.cpp b/quic/congestion_control/test/CubicStateTest.cpp index a792c07c5..722e36074 100644 --- a/quic/congestion_control/test/CubicStateTest.cpp +++ b/quic/congestion_control/test/CubicStateTest.cpp @@ -24,7 +24,7 @@ TEST_F(CubicStateTest, HystartLoss) { auto packet = makeTestingWritePacket(0, 0, 0); CongestionController::LossEvent lossEvent(Clock::now()); lossEvent.addLostPacket(packet); - cubic.onPacketAckOrLoss(folly::none, lossEvent); + cubic.onPacketAckOrLoss(none, lossEvent); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); } @@ -34,7 +34,7 @@ TEST_F(CubicStateTest, HystartAck) { auto packet = makeTestingWritePacket(0, 0, 0); cubic.onPacketSent(packet); cubic.onPacketAckOrLoss( - makeAck(0, 0, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 0, Clock::now(), packet.metadata.time), none); EXPECT_EQ(CubicStates::Hystart, cubic.state()); } @@ -51,9 +51,9 @@ TEST_F(CubicStateTest, FastRecoveryAck) { cubic.onPacketSent(packet1); CongestionController::LossEvent loss; loss.addLostPacket(packet); - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); cubic.onPacketAckOrLoss( - makeAck(2, 1000, Clock::now(), packet1.metadata.time), folly::none); + makeAck(2, 1000, Clock::now(), packet1.metadata.time), none); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); } @@ -65,11 +65,11 @@ TEST_F(CubicStateTest, FastRecoveryAckToSteady) { cubic.onPacketSent(packet); CongestionController::LossEvent loss; loss.addLostPacket(packet); - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); auto packet1 = makeTestingWritePacket(1, 1, 2); cubic.onPacketSent(packet1); cubic.onPacketAckOrLoss( - makeAck(1, 1, Clock::now(), packet1.metadata.time), folly::none); + makeAck(1, 1, Clock::now(), packet1.metadata.time), none); EXPECT_EQ(CubicStates::Steady, cubic.state()); } @@ -80,7 +80,7 @@ TEST_F(CubicStateTest, FastRecoveryLoss) { auto packet = makeTestingWritePacket(0, 0, 0); CongestionController::LossEvent lossEvent(Clock::now()); lossEvent.addLostPacket(packet); - cubic.onPacketAckOrLoss(folly::none, lossEvent); + cubic.onPacketAckOrLoss(none, lossEvent); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); } @@ -93,7 +93,7 @@ TEST_F(CubicStateTest, SteadyAck) { auto packet = makeTestingWritePacket(0, 0, 0); cubic.onPacketSent(packet); cubic.onPacketAckOrLoss( - makeAck(0, 0, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 0, Clock::now(), packet.metadata.time), none); EXPECT_EQ(CubicStates::Steady, cubic.state()); } @@ -104,7 +104,7 @@ TEST_F(CubicStateTest, SteadyLoss) { auto packet = makeTestingWritePacket(0, 0, 0); CongestionController::LossEvent lossEvent(Clock::now()); lossEvent.addLostPacket(packet); - cubic.onPacketAckOrLoss(folly::none, lossEvent); + cubic.onPacketAckOrLoss(none, lossEvent); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); } } // namespace test diff --git a/quic/congestion_control/test/CubicSteadyTest.cpp b/quic/congestion_control/test/CubicSteadyTest.cpp index 90cd3edb5..897f6459b 100644 --- a/quic/congestion_control/test/CubicSteadyTest.cpp +++ b/quic/congestion_control/test/CubicSteadyTest.cpp @@ -28,7 +28,7 @@ TEST_F(CubicSteadyTest, CubicReduction) { conn.lossState.largestSent = 0; cubic.onPacketSent(packet0); cubic.onPacketAckOrLoss( - makeAck(0, 1000, Clock::now(), packet0.metadata.time), folly::none); + makeAck(0, 1000, Clock::now(), packet0.metadata.time), none); EXPECT_EQ(3000, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::Steady, cubic.state()); @@ -39,7 +39,7 @@ TEST_F(CubicSteadyTest, CubicReduction) { cubic.onPacketSent(packet1); CongestionController::LossEvent loss; loss.addLostPacket(packet1); - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); EXPECT_EQ(2100, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); } diff --git a/quic/congestion_control/test/CubicTest.cpp b/quic/congestion_control/test/CubicTest.cpp index 0b647b644..5c961cb7e 100644 --- a/quic/congestion_control/test/CubicTest.cpp +++ b/quic/congestion_control/test/CubicTest.cpp @@ -35,7 +35,7 @@ TEST_F(CubicTest, AckIncreaseWritable) { // Acking 50, now inflight become 50. Cwnd is init + 50 cubic.onPacketAckOrLoss( - makeAck(0, 50, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 50, Clock::now(), packet.metadata.time), none); EXPECT_EQ(initCwnd, cubic.getWritableBytes()); } @@ -51,7 +51,7 @@ TEST_F(CubicTest, PersistentCongestion) { CongestionController::LossEvent loss; loss.addLostPacket(packet); loss.persistentCongestion = true; - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); EXPECT_EQ(CubicStates::Hystart, cubic.state()); // Cwnd should be dropped to minCwnd: EXPECT_EQ( @@ -62,8 +62,7 @@ TEST_F(CubicTest, PersistentCongestion) { auto packet2 = makeTestingWritePacket(1, initCwnd / 2, initCwnd / 2 + 1000); cubic.onPacketSent(packet2); cubic.onPacketAckOrLoss( - makeAck(1, initCwnd / 2, Clock::now(), packet2.metadata.time), - folly::none); + makeAck(1, initCwnd / 2, Clock::now(), packet2.metadata.time), none); EXPECT_EQ(CubicStates::Steady, cubic.state()); // Verify both lastMaxCwndBytes and lastReductionTime are also reset in @@ -74,7 +73,7 @@ TEST_F(CubicTest, PersistentCongestion) { auto packet3 = makeTestingWritePacket(2, 3000, initCwnd / 2 + 1000 + 3000); cubic.onPacketSent(packet3); cubic.onPacketAckOrLoss( - makeAck(2, 3000, Clock::now(), packet3.metadata.time), folly::none); + makeAck(2, 3000, Clock::now(), packet3.metadata.time), none); std::vector indices = getQLogEventIndices(QLogEventType::CongestionMetricUpdate, qLogger); @@ -128,7 +127,7 @@ TEST_F(CubicTest, CwndIncreaseAfterReduction) { conn.lossState.largestSent = 0; cubic.onPacketSent(packet0); cubic.onPacketAckOrLoss( - makeAck(0, 1000, Clock::now(), packet0.metadata.time), folly::none); + makeAck(0, 1000, Clock::now(), packet0.metadata.time), none); // Cwnd increased by 1000, inflight = 0: EXPECT_EQ(3000, cubic.getWritableBytes()); EXPECT_EQ(CubicStates::Steady, cubic.state()); @@ -145,17 +144,17 @@ TEST_F(CubicTest, CwndIncreaseAfterReduction) { EXPECT_EQ(0, cubic.getWritableBytes()); cubic.onPacketAckOrLoss( - makeAck(1, 1000, Clock::now(), packet1.metadata.time), folly::none); + makeAck(1, 1000, Clock::now(), packet1.metadata.time), none); // Cwnd >= 3000, inflight = 2000: EXPECT_GE(cubic.getWritableBytes(), 1000); CongestionController::LossEvent loss; loss.addLostPacket(packet2); - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); // Cwnd >= 2100, inflight = 1000: EXPECT_GE(cubic.getWritableBytes(), 1100); // This won't bring state machine back to Steady since endOfRecovery = 3 cubic.onPacketAckOrLoss( - makeAck(3, 1000, Clock::now(), packet3.metadata.time), folly::none); + makeAck(3, 1000, Clock::now(), packet3.metadata.time), none); // Cwnd no change, inflight = 0: EXPECT_GE(cubic.getWritableBytes(), 2100); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); @@ -165,7 +164,7 @@ TEST_F(CubicTest, CwndIncreaseAfterReduction) { cubic.onPacketSent(packet4); // This will bring state machine back to steady cubic.onPacketAckOrLoss( - makeAck(4, 1000, Clock::now(), packet4.metadata.time), folly::none); + makeAck(4, 1000, Clock::now(), packet4.metadata.time), none); EXPECT_GE(cubic.getWritableBytes(), 2100); EXPECT_EQ(CubicStates::Steady, cubic.state()); @@ -191,7 +190,7 @@ TEST_F(CubicTest, AppIdle) { auto maxCwnd = cubic.getCongestionWindow(); CongestionController::LossEvent loss(reductionTime); loss.addLostPacket(packet); - cubic.onPacketAckOrLoss(folly::none, std::move(loss)); + cubic.onPacketAckOrLoss(none, std::move(loss)); auto timeToOrigin = ::cbrt( (maxCwnd - cubic.getCongestionWindow()) * 1000 * 1000 / conn.udpSendPacketLen * 2500); @@ -200,8 +199,7 @@ TEST_F(CubicTest, AppIdle) { auto packet1 = makeTestingWritePacket(1, 1000, 2000); cubic.onPacketSent(packet1); cubic.onPacketAckOrLoss( - makeAck(1, 1000, reductionTime + 1000ms, packet1.metadata.time), - folly::none); + makeAck(1, 1000, reductionTime + 1000ms, packet1.metadata.time), none); EXPECT_EQ(CubicStates::Steady, cubic.state()); EXPECT_GT(cubic.getCongestionWindow(), cwnd); cwnd = cubic.getCongestionWindow(); @@ -211,8 +209,7 @@ TEST_F(CubicTest, AppIdle) { auto packet2 = makeTestingWritePacket(2, 1000, 3000); cubic.onPacketSent(packet2); cubic.onPacketAckOrLoss( - makeAck(2, 1000, reductionTime + 2000ms, packet2.metadata.time), - folly::none); + makeAck(2, 1000, reductionTime + 2000ms, packet2.metadata.time), none); EXPECT_EQ(cubic.getCongestionWindow(), cwnd); // 1 seconds of quiescence @@ -221,8 +218,7 @@ TEST_F(CubicTest, AppIdle) { auto packet3 = makeTestingWritePacket(3, 1000, 4000); cubic.onPacketSent(packet3); cubic.onPacketAckOrLoss( - makeAck(3, 1000, reductionTime + 3000ms, packet3.metadata.time), - folly::none); + makeAck(3, 1000, reductionTime + 3000ms, packet3.metadata.time), none); EXPECT_GT(cubic.getCongestionWindow(), cwnd); auto expectedDelta = static_cast(std::floor( @@ -263,7 +259,7 @@ TEST_F(CubicTest, PacingGain) { EXPECT_EQ(cubic.getCongestionWindow() * 2, cwndBytes); })); cubic.onPacketAckOrLoss( - makeAck(0, 1500, Clock::now(), packet.metadata.time), folly::none); + makeAck(0, 1500, Clock::now(), packet.metadata.time), none); EXPECT_EQ(CubicStates::Hystart, cubic.state()); auto packet1 = makeTestingWritePacket(1, 1500, 3000); @@ -279,7 +275,7 @@ TEST_F(CubicTest, PacingGain) { static_cast(cubic.getCongestionWindow() * 1.25), cwndBytes); })); - cubic.onPacketAckOrLoss(folly::none, loss); + cubic.onPacketAckOrLoss(none, loss); EXPECT_EQ(CubicStates::FastRecovery, cubic.state()); auto packet2 = makeTestingWritePacket(2, 1500, 4500); @@ -291,7 +287,7 @@ TEST_F(CubicTest, PacingGain) { EXPECT_EQ(cubic.getCongestionWindow(), cwndBytes); })); cubic.onPacketAckOrLoss( - makeAck(2, 1500, Clock::now(), packet2.metadata.time), folly::none); + makeAck(2, 1500, Clock::now(), packet2.metadata.time), none); EXPECT_EQ(CubicStates::Steady, cubic.state()); std::vector indices = @@ -314,7 +310,7 @@ TEST_F(CubicTest, PacetLossInvokesPacer) { EXPECT_CALL(*rawPacer, onPacketsLoss()).Times(1); CongestionController::LossEvent lossEvent; lossEvent.addLostPacket(packet); - cubic.onPacketAckOrLoss(folly::none, lossEvent); + cubic.onPacketAckOrLoss(none, lossEvent); } TEST_F(CubicTest, InitCwnd) { diff --git a/quic/congestion_control/test/NewRenoTest.cpp b/quic/congestion_control/test/NewRenoTest.cpp index f9f2e89d4..fad24438e 100644 --- a/quic/congestion_control/test/NewRenoTest.cpp +++ b/quic/congestion_control/test/NewRenoTest.cpp @@ -110,22 +110,19 @@ TEST_F(NewRenoTest, TestLoss) { EXPECT_EQ(reno.getBytesInFlight(), 41); auto originalWritableBytes = reno.getWritableBytes(); - reno.onPacketAckOrLoss( - folly::none, createLossEvent({std::make_pair(loss1, 11)})); + reno.onPacketAckOrLoss(none, createLossEvent({std::make_pair(loss1, 11)})); EXPECT_EQ(reno.getBytesInFlight(), 30); EXPECT_FALSE(reno.inSlowStart()); auto newWritableBytes1 = reno.getWritableBytes(); EXPECT_LE(newWritableBytes1, originalWritableBytes + 11); - reno.onPacketAckOrLoss( - folly::none, createLossEvent({std::make_pair(loss2, 10)})); + reno.onPacketAckOrLoss(none, createLossEvent({std::make_pair(loss2, 10)})); auto newWritableBytes2 = reno.getWritableBytes(); EXPECT_LE(newWritableBytes2, newWritableBytes1 + 10); EXPECT_EQ(reno.getBytesInFlight(), 20); - reno.onPacketAckOrLoss( - folly::none, createLossEvent({std::make_pair(loss3, 20)})); + reno.onPacketAckOrLoss(none, createLossEvent({std::make_pair(loss3, 20)})); auto newWritableBytes3 = reno.getWritableBytes(); EXPECT_LE(newWritableBytes3, newWritableBytes2 + 20); EXPECT_EQ(reno.getBytesInFlight(), 0); @@ -144,7 +141,7 @@ TEST_F(NewRenoTest, SendMoreThanWritable) { EXPECT_EQ(reno.getBytesInFlight(), originalWritableBytes + 20); EXPECT_EQ(reno.getWritableBytes(), 0); reno.onPacketAckOrLoss( - folly::none, + none, createLossEvent({std::make_pair(loss, originalWritableBytes + 20)})); EXPECT_LT(reno.getWritableBytes(), originalWritableBytes); } @@ -163,8 +160,7 @@ TEST_F(NewRenoTest, TestSlowStartAck) { reno.onPacketSent(packet); EXPECT_EQ(reno.getBytesInFlight(), ackedSize); reno.onPacketAckOrLoss( - createAckEvent(ackPacketNum1, ackedSize, packet.metadata.time), - folly::none); + createAckEvent(ackPacketNum1, ackedSize, packet.metadata.time), none); EXPECT_TRUE(reno.inSlowStart()); auto newWritableBytes = reno.getWritableBytes(); @@ -181,8 +177,7 @@ TEST_F(NewRenoTest, TestSteadyStateAck) { auto originalWritableBytes = reno.getWritableBytes(); PacketNum loss1 = 4; reno.onPacketSent(createPacket(loss1, 10, Clock::now())); - reno.onPacketAckOrLoss( - folly::none, createLossEvent({std::make_pair(loss1, 10)})); + reno.onPacketAckOrLoss(none, createLossEvent({std::make_pair(loss1, 10)})); EXPECT_FALSE(reno.inSlowStart()); auto newWritableBytes1 = reno.getWritableBytes(); EXPECT_LT(newWritableBytes1, originalWritableBytes); @@ -193,8 +188,7 @@ TEST_F(NewRenoTest, TestSteadyStateAck) { ackPacketNum1, ackedSize, Clock::now() - std::chrono::milliseconds(10)); reno.onPacketSent(packet1); reno.onPacketAckOrLoss( - createAckEvent(ackPacketNum1, ackedSize, packet1.metadata.time), - folly::none); + createAckEvent(ackPacketNum1, ackedSize, packet1.metadata.time), none); EXPECT_FALSE(reno.inSlowStart()); auto newWritableBytes2 = reno.getWritableBytes(); @@ -204,8 +198,7 @@ TEST_F(NewRenoTest, TestSteadyStateAck) { auto packet2 = createPacket(ackPacketNum2, ackedSize, Clock::now()); reno.onPacketSent(packet2); reno.onPacketAckOrLoss( - createAckEvent(ackPacketNum2, ackedSize, packet2.metadata.time), - folly::none); + createAckEvent(ackPacketNum2, ackedSize, packet2.metadata.time), none); EXPECT_FALSE(reno.inSlowStart()); auto newWritableBytes3 = reno.getWritableBytes(); @@ -245,7 +238,7 @@ TEST_F(NewRenoTest, PersistentCongestion) { CongestionController::LossEvent loss; loss.persistentCongestion = true; loss.addLostPacket(pkt); - reno.onPacketAckOrLoss(folly::none, loss); + reno.onPacketAckOrLoss(none, loss); EXPECT_EQ( reno.getWritableBytes(), conn.transportSettings.minCwndInMss * conn.udpSendPacketLen); diff --git a/quic/congestion_control/test/ThrottlingSignalProviderTest.cpp b/quic/congestion_control/test/ThrottlingSignalProviderTest.cpp index 149fd2eba..044caf63f 100644 --- a/quic/congestion_control/test/ThrottlingSignalProviderTest.cpp +++ b/quic/congestion_control/test/ThrottlingSignalProviderTest.cpp @@ -25,7 +25,7 @@ class SimpleThrottlingSignalProvider : public PacketProcessor, public: explicit SimpleThrottlingSignalProvider( SimulatedTBF::Config config, - folly::Optional burstRateBytesPerSecond = folly::none) + Optional burstRateBytesPerSecond = none) : stbf_(std::move(config)), burstRateBytesPerSecond_(std::move(burstRateBytesPerSecond)) {} ~SimpleThrottlingSignalProvider() override = default; @@ -34,7 +34,7 @@ class SimpleThrottlingSignalProvider : public PacketProcessor, packet.metadata.encodedSize, packet.metadata.time); } - [[nodiscard]] folly::Optional getCurrentThrottlingSignal() + [[nodiscard]] Optional getCurrentThrottlingSignal() override { auto availTokens = stbf_.getNumAvailableTokensInBytes(quic::Clock::now()); ThrottlingSignal signal = {}; @@ -49,7 +49,7 @@ class SimpleThrottlingSignalProvider : public PacketProcessor, private: SimulatedTBF stbf_; - folly::Optional burstRateBytesPerSecond_; + Optional burstRateBytesPerSecond_; }; TEST(ThrottlingSignalProviderTest, BasicInitSetGetTest) { @@ -156,7 +156,7 @@ TEST( bbr.onPacketAckOrLoss( makeAck( pn, 2000, now + std::chrono::milliseconds{5}, packet.metadata.time), - folly::none); + none); auto maybeSignal = signalProvider->getCurrentThrottlingSignal(); ASSERT_TRUE(maybeSignal.has_value()); ASSERT_TRUE(bbr.getBandwidth().has_value()); diff --git a/quic/dsr/BUCK b/quic/dsr/BUCK index ce61853e7..e497d3a92 100644 --- a/quic/dsr/BUCK +++ b/quic/dsr/BUCK @@ -12,8 +12,8 @@ mvfst_cpp_library( ], exported_deps = [ "//folly:network_address", - "//folly:optional", "//quic/codec:types", + "//quic/common:optional", "//quic/server/state:server", "//quic/state:quic_state_machine", ], diff --git a/quic/dsr/Types.h b/quic/dsr/Types.h index 1b520b665..8b9a3fc7c 100644 --- a/quic/dsr/Types.h +++ b/quic/dsr/Types.h @@ -7,10 +7,10 @@ #pragma once -#include #include #include #include +#include #include #include @@ -90,7 +90,7 @@ struct SendInstruction { std::chrono::microseconds writeOffset{0us}; // QUIC Stream info - folly::Optional largestAckedStreamOffset; + Optional largestAckedStreamOffset; StreamId streamId; uint64_t streamOffset; uint64_t len; @@ -166,13 +166,13 @@ struct SendInstruction { const folly::SocketAddress& clientAddr; PacketNum packetNum{0}; PacketNum largestAckedPacketNum{0}; - folly::Optional largestAckedStreamOffset; + Optional largestAckedStreamOffset; std::chrono::microseconds writeOffset{0us}; StreamId streamId; - folly::Optional streamOffset; - folly::Optional len; + Optional streamOffset; + Optional len; bool fin{false}; - folly::Optional bufMetaStartingOffset; + Optional bufMetaStartingOffset; }; private: @@ -183,7 +183,7 @@ struct SendInstruction { PacketNum packetNumIn, PacketNum largestAckedPacketNumIn, std::chrono::microseconds writeOffsetIn, - folly::Optional largestAckedStreamOffsetIn, + Optional largestAckedStreamOffsetIn, StreamId idIn, uint64_t streamOffsetIn, uint64_t lenIn, diff --git a/quic/dsr/backend/DSRPacketizer.cpp b/quic/dsr/backend/DSRPacketizer.cpp index 52cf669e8..4986b68ee 100644 --- a/quic/dsr/backend/DSRPacketizer.cpp +++ b/quic/dsr/backend/DSRPacketizer.cpp @@ -50,7 +50,7 @@ bool PacketGroupWriter::writeSingleQuicPacket( length /* flow control len*/, eof, true /* skip length field in stream header */, - folly::none, /* stream group id */ + none, /* stream group id */ false /* don't append frame to builder */); BufQueue bufQueue(std::move(buf)); writeStreamFrameData(builder, bufQueue, *dataLen); diff --git a/quic/dsr/backend/test/DSRPacketizerTest.cpp b/quic/dsr/backend/test/DSRPacketizerTest.cpp index e39dd5d98..d71e40a66 100644 --- a/quic/dsr/backend/test/DSRPacketizerTest.cpp +++ b/quic/dsr/backend/test/DSRPacketizerTest.cpp @@ -162,9 +162,9 @@ TEST_F(DSRMultiWriteTest, TwoRequestsWithLoss) { auto& packet2 = conn_.outstandings.packets.back().packet; EXPECT_EQ(1, packet1.frames.size()); WriteStreamFrame expectedFirstFrame( - streamId, bufMetaStartingOffset, 500, false, true, folly::none, 0); + streamId, bufMetaStartingOffset, 500, false, true, none, 0); WriteStreamFrame expectedSecondFrame( - streamId, 500 + bufMetaStartingOffset, 500, true, true, folly::none, 1); + streamId, 500 + bufMetaStartingOffset, 500, true, true, none, 1); EXPECT_EQ(expectedFirstFrame, *packet1.frames[0].asWriteStreamFrame()); EXPECT_EQ(expectedSecondFrame, *packet2.frames[0].asWriteStreamFrame()); diff --git a/quic/dsr/frontend/BUCK b/quic/dsr/frontend/BUCK index 909983bca..b7da07602 100644 --- a/quic/dsr/frontend/BUCK +++ b/quic/dsr/frontend/BUCK @@ -11,7 +11,7 @@ mvfst_cpp_library( "WriteCodec.h", ], deps = [ - "//folly:optional", + "//quic/common:optional", ], exported_deps = [ ":packet_builder", diff --git a/quic/dsr/frontend/WriteCodec.cpp b/quic/dsr/frontend/WriteCodec.cpp index 23924e0cf..6e8bb3249 100644 --- a/quic/dsr/frontend/WriteCodec.cpp +++ b/quic/dsr/frontend/WriteCodec.cpp @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -#include +#include #include namespace quic { diff --git a/quic/dsr/frontend/WriteFunctions.cpp b/quic/dsr/frontend/WriteFunctions.cpp index b6ee40a8e..150cc949b 100644 --- a/quic/dsr/frontend/WriteFunctions.cpp +++ b/quic/dsr/frontend/WriteFunctions.cpp @@ -84,7 +84,7 @@ uint64_t writePacketizationRequest( // of addSendInstruction() call. updateConnection( connection, - folly::none /* Packet Event */, + none /* Packet Event */, packet.packet, Clock::now(), packet.encodedSize + cipherOverhead, diff --git a/quic/dsr/frontend/test/PacketBuilderTest.cpp b/quic/dsr/frontend/test/PacketBuilderTest.cpp index 80e96124a..d5688ccd0 100644 --- a/quic/dsr/frontend/test/PacketBuilderTest.cpp +++ b/quic/dsr/frontend/test/PacketBuilderTest.cpp @@ -103,9 +103,8 @@ TEST_F(PacketBuilderTest, WriteTwoInstructions) { const auto& writePacket = packet.packet; EXPECT_EQ(2, packet.sendInstructions.size()); EXPECT_EQ(2, writePacket.frames.size()); - WriteStreamFrame expectedFirstFrame(id, 0, 100, false, true, folly::none, 5); - WriteStreamFrame expectedSecondFrame( - id, 100, 100, true, true, folly::none, 6); + WriteStreamFrame expectedFirstFrame(id, 0, 100, false, true, none, 5); + WriteStreamFrame expectedSecondFrame(id, 100, 100, true, true, none, 6); EXPECT_EQ(expectedFirstFrame, *writePacket.frames[0].asWriteStreamFrame()); EXPECT_EQ(expectedSecondFrame, *writePacket.frames[1].asWriteStreamFrame()); EXPECT_TRUE(expectedFirstFrame == packet.sendInstructions[0]); diff --git a/quic/dsr/frontend/test/WriteFunctionsTest.cpp b/quic/dsr/frontend/test/WriteFunctionsTest.cpp index 723a5d1fa..fa2adfb46 100644 --- a/quic/dsr/frontend/test/WriteFunctionsTest.cpp +++ b/quic/dsr/frontend/test/WriteFunctionsTest.cpp @@ -307,9 +307,9 @@ TEST_F(WriteFunctionsTest, LossAndFreshTwoInstructionsInTwoPackets) { EXPECT_EQ(1, packet1.frames.size()); EXPECT_EQ(1, packet2.frames.size()); WriteStreamFrame expectedFirstFrame( - streamId, bufMetaStartingOffset, 500, false, true, folly::none, 0); + streamId, bufMetaStartingOffset, 500, false, true, none, 0); WriteStreamFrame expectedSecondFrame( - streamId, 500 + bufMetaStartingOffset, 500, true, true, folly::none, 1); + streamId, 500 + bufMetaStartingOffset, 500, true, true, none, 1); EXPECT_EQ(expectedFirstFrame, *packet1.frames[0].asWriteStreamFrame()); EXPECT_EQ(expectedSecondFrame, *packet2.frames[0].asWriteStreamFrame()); } diff --git a/quic/fizz/client/handshake/BUCK b/quic/fizz/client/handshake/BUCK index 73ad91a98..4c205d050 100644 --- a/quic/fizz/client/handshake/BUCK +++ b/quic/fizz/client/handshake/BUCK @@ -14,7 +14,6 @@ mvfst_cpp_library( "FizzClientQuicHandshakeContext.h", ], deps = [ - "//fizz/backend:openssl", "//fizz/client:early_data_rejection", "//fizz/client:ech_policy", "//fizz/protocol:exporter", @@ -42,8 +41,8 @@ mvfst_cpp_library( ], exported_deps = [ "//fizz/client:psk_cache", - "//folly:optional", "//quic/client:cached_server_tp", + "//quic/common:optional", ], ) @@ -53,7 +52,7 @@ mvfst_cpp_library( "QuicTokenCache.h", ], exported_deps = [ - "//folly:optional", "//folly:string", + "//quic/common:optional", ], ) diff --git a/quic/fizz/client/handshake/FizzClientHandshake.cpp b/quic/fizz/client/handshake/FizzClientHandshake.cpp index 911cfb41c..d8f7fdd82 100644 --- a/quic/fizz/client/handshake/FizzClientHandshake.cpp +++ b/quic/fizz/client/handshake/FizzClientHandshake.cpp @@ -31,13 +31,13 @@ FizzClientHandshake::FizzClientHandshake( CHECK(cryptoFactory_->getFizzFactory()); } -folly::Optional -FizzClientHandshake::connectImpl(folly::Optional hostname) { +Optional FizzClientHandshake::connectImpl( + Optional hostname) { // Look up psk - folly::Optional quicCachedPsk = getPsk(hostname); + Optional quicCachedPsk = getPsk(hostname); - folly::Optional cachedPsk; - folly::Optional transportParams; + Optional cachedPsk; + Optional transportParams; if (quicCachedPsk) { cachedPsk = std::move(quicCachedPsk->cachedPsk); transportParams = std::move(quicCachedPsk->transportParams); @@ -52,7 +52,7 @@ FizzClientHandshake::connectImpl(folly::Optional hostname) { // Since Draft-17, EOED should not be sent context->setOmitEarlyRecordLayer(true); - folly::Optional> echConfigs; + Optional> echConfigs; if (hostname.hasValue()) { echConfigs = fizzContext_->getECHConfigs(*hostname); } @@ -69,11 +69,11 @@ FizzClientHandshake::connectImpl(folly::Optional hostname) { return transportParams; } -folly::Optional FizzClientHandshake::getPsk( - const folly::Optional& hostname) const { +Optional FizzClientHandshake::getPsk( + const Optional& hostname) const { auto quicCachedPsk = fizzContext_->getPsk(hostname); if (!quicCachedPsk) { - return folly::none; + return none; } // TODO T32658838 better API to disable early data for current connection @@ -92,8 +92,7 @@ folly::Optional FizzClientHandshake::getPsk( return quicCachedPsk; } -void FizzClientHandshake::removePsk( - const folly::Optional& hostname) { +void FizzClientHandshake::removePsk(const Optional& hostname) { fizzContext_->removePsk(hostname); } @@ -101,8 +100,8 @@ const CryptoFactory& FizzClientHandshake::getCryptoFactory() const { return *cryptoFactory_; } -const folly::Optional& -FizzClientHandshake::getApplicationProtocol() const { +const Optional& FizzClientHandshake::getApplicationProtocol() + const { auto& earlyDataParams = state_.earlyDataParams(); if (earlyDataParams) { return earlyDataParams->alpn; @@ -138,15 +137,14 @@ bool FizzClientHandshake::isTLSResumed() const { return pskType && *pskType == fizz::PskType::Resumption; } -folly::Optional> -FizzClientHandshake::getExportedKeyingMaterial( +Optional> FizzClientHandshake::getExportedKeyingMaterial( const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength) { const auto& ems = state_.exporterMasterSecret(); const auto cipherSuite = state_.cipher(); if (!ems.hasValue() || !cipherSuite.hasValue()) { - return folly::none; + return none; } auto ekm = fizz::Exporter::getExportedKeyingMaterial( @@ -154,7 +152,7 @@ FizzClientHandshake::getExportedKeyingMaterial( cipherSuite.value(), ems.value()->coalesce(), label, - context == folly::none ? nullptr : folly::IOBuf::wrapBuffer(*context), + context == none ? nullptr : folly::IOBuf::wrapBuffer(*context), keyLength); std::vector result(ekm->coalesce()); diff --git a/quic/fizz/client/handshake/FizzClientHandshake.h b/quic/fizz/client/handshake/FizzClientHandshake.h index cc261ec79..1f7712023 100644 --- a/quic/fizz/client/handshake/FizzClientHandshake.h +++ b/quic/fizz/client/handshake/FizzClientHandshake.h @@ -27,11 +27,11 @@ class FizzClientHandshake : public ClientHandshake { std::shared_ptr fizzContext, std::unique_ptr cryptoFactory); - void removePsk(const folly::Optional& hostname) override; + void removePsk(const Optional& hostname) override; const CryptoFactory& getCryptoFactory() const override; - const folly::Optional& getApplicationProtocol() const override; + const Optional& getApplicationProtocol() const override; bool verifyRetryIntegrityTag( const ConnectionId& originalDstConnId, @@ -39,9 +39,9 @@ class FizzClientHandshake : public ClientHandshake { bool isTLSResumed() const override; - folly::Optional> getExportedKeyingMaterial( + Optional> getExportedKeyingMaterial( const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength) override; const fizz::client::State& getState() const { @@ -53,16 +53,15 @@ class FizzClientHandshake : public ClientHandshake { } protected: - folly::Optional getPsk( - const folly::Optional& hostname) const; + Optional getPsk(const Optional& hostname) const; void onNewCachedPsk(fizz::client::NewCachedPsk& newCachedPsk) noexcept; void echRetryAvailable(fizz::client::ECHRetryAvailable& retry); private: - folly::Optional connectImpl( - folly::Optional hostname) override; + Optional connectImpl( + Optional hostname) override; EncryptionLevel getReadRecordLayerEncryptionLevel() override; void processSocketData(folly::IOBufQueue& queue) override; diff --git a/quic/fizz/client/handshake/FizzClientQuicHandshakeContext.cpp b/quic/fizz/client/handshake/FizzClientQuicHandshakeContext.cpp index 0eae504ed..57e626f00 100644 --- a/quic/fizz/client/handshake/FizzClientQuicHandshakeContext.cpp +++ b/quic/fizz/client/handshake/FizzClientQuicHandshakeContext.cpp @@ -53,17 +53,17 @@ FizzClientQuicHandshakeContext::makeClientHandshake( return handshake; } -folly::Optional FizzClientQuicHandshakeContext::getPsk( - const folly::Optional& hostname) { +Optional FizzClientQuicHandshakeContext::getPsk( + const Optional& hostname) { if (!hostname || !pskCache_) { - return folly::none; + return none; } return pskCache_->getPsk(*hostname); } void FizzClientQuicHandshakeContext::putPsk( - const folly::Optional& hostname, + const Optional& hostname, QuicCachedPsk quicCachedPsk) { if (hostname && pskCache_) { pskCache_->putPsk(*hostname, std::move(quicCachedPsk)); @@ -71,16 +71,16 @@ void FizzClientQuicHandshakeContext::putPsk( } void FizzClientQuicHandshakeContext::removePsk( - const folly::Optional& hostname) { + const Optional& hostname) { if (hostname && pskCache_) { pskCache_->removePsk(*hostname); } } -folly::Optional> +Optional> FizzClientQuicHandshakeContext::getECHConfigs(const std::string& sni) const { if (!echPolicy_) { - return folly::none; + return none; } return echPolicy_->getConfig(sni); } diff --git a/quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h b/quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h index e46826f7d..3c284e77a 100644 --- a/quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h +++ b/quic/fizz/client/handshake/FizzClientQuicHandshakeContext.h @@ -38,14 +38,13 @@ class FizzClientQuicHandshakeContext return verifier_; } - folly::Optional getPsk( - const folly::Optional& hostname); + Optional getPsk(const Optional& hostname); void putPsk( - const folly::Optional& hostname, + const Optional& hostname, QuicCachedPsk quicCachedPsk); - void removePsk(const folly::Optional& hostname); + void removePsk(const Optional& hostname); - folly::Optional> getECHConfigs( + Optional> getECHConfigs( const std::string& sni) const; void setECHRetryCallback( diff --git a/quic/fizz/client/handshake/QuicPskCache.h b/quic/fizz/client/handshake/QuicPskCache.h index 4a049bb6c..11349eaec 100644 --- a/quic/fizz/client/handshake/QuicPskCache.h +++ b/quic/fizz/client/handshake/QuicPskCache.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include @@ -26,7 +26,7 @@ class QuicPskCache { public: virtual ~QuicPskCache() = default; - virtual folly::Optional getPsk(const std::string&) = 0; + virtual Optional getPsk(const std::string&) = 0; virtual void putPsk(const std::string&, QuicCachedPsk) = 0; virtual void removePsk(const std::string&) = 0; }; @@ -39,12 +39,12 @@ class BasicQuicPskCache : public QuicPskCache { public: ~BasicQuicPskCache() override = default; - folly::Optional getPsk(const std::string& identity) override { + Optional getPsk(const std::string& identity) override { auto result = cache_.find(identity); if (result != cache_.end()) { return result->second; } - return folly::none; + return none; } void putPsk(const std::string& identity, QuicCachedPsk psk) override { diff --git a/quic/fizz/client/handshake/QuicTokenCache.h b/quic/fizz/client/handshake/QuicTokenCache.h index cd33fe89b..10f3c1f7c 100644 --- a/quic/fizz/client/handshake/QuicTokenCache.h +++ b/quic/fizz/client/handshake/QuicTokenCache.h @@ -10,8 +10,8 @@ #include #include -#include #include +#include namespace quic { @@ -19,7 +19,7 @@ class QuicTokenCache { public: virtual ~QuicTokenCache() = default; - [[nodiscard]] virtual folly::Optional getToken( + [[nodiscard]] virtual Optional getToken( const std::string& hostname) = 0; virtual void putToken(const std::string& hostname, std::string token) = 0; @@ -31,12 +31,12 @@ class BasicQuicTokenCache : public QuicTokenCache { public: ~BasicQuicTokenCache() override = default; - folly::Optional getToken(const std::string& hostname) override { + Optional getToken(const std::string& hostname) override { auto res = cache_.find(hostname); if (res != cache_.end()) { return res->second; } - return folly::none; + return none; } void putToken(const std::string& hostname, std::string token) override { diff --git a/quic/fizz/client/handshake/test/BUCK b/quic/fizz/client/handshake/test/BUCK index b6e61118b..ba7aa5d3e 100644 --- a/quic/fizz/client/handshake/test/BUCK +++ b/quic/fizz/client/handshake/test/BUCK @@ -50,8 +50,8 @@ mvfst_cpp_library( "MockQuicPskCache.h", ], exported_deps = [ - "//folly:optional", "//folly/portability:gmock", + "//quic/common:optional", "//quic/fizz/client/handshake:psk_cache", ], ) diff --git a/quic/fizz/client/handshake/test/FizzClientHandshakeTest.cpp b/quic/fizz/client/handshake/test/FizzClientHandshakeTest.cpp index 05495b1c7..560bb21cb 100644 --- a/quic/fizz/client/handshake/test/FizzClientHandshakeTest.cpp +++ b/quic/fizz/client/handshake/test/FizzClientHandshakeTest.cpp @@ -283,7 +283,7 @@ class ClientHandshakeTest : public Test, public boost::static_visitor<> { std::vector serverOutput; bool handshakeSuccess{false}; bool earlyHandshakeSuccess{false}; - folly::Optional handshakeError; + Optional handshakeError; folly::IOBufQueue serverReadBuf{folly::IOBufQueue::cacheChainLength()}; std::unique_ptr dg; fizz::Aead::AeadOptions readAeadOptions; @@ -294,7 +294,7 @@ class ClientHandshakeTest : public Test, public boost::static_visitor<> { const Aead* oneRttReadCipher = nullptr; std::unique_ptr zeroRttWriteCipher; - folly::Optional zeroRttRejected; + Optional zeroRttRejected; std::shared_ptr verifier; std::shared_ptr clientCtx; @@ -304,15 +304,14 @@ class ClientHandshakeTest : public Test, public boost::static_visitor<> { TEST_F(ClientHandshakeTest, TestGetExportedKeyingMaterial) { // Sanity check. getExportedKeyingMaterial () should return nullptr prior to // an handshake. - auto ekm = handshake->getExportedKeyingMaterial( - "EXPORTER-Some-Label", folly::none, 32); + auto ekm = + handshake->getExportedKeyingMaterial("EXPORTER-Some-Label", none, 32); EXPECT_TRUE(!ekm.has_value()); clientServerRound(); serverClientRound(); handshake->handshakeConfirmed(); - ekm = handshake->getExportedKeyingMaterial( - "EXPORTER-Some-Label", folly::none, 32); + ekm = handshake->getExportedKeyingMaterial("EXPORTER-Some-Label", none, 32); ASSERT_TRUE(ekm.has_value()); EXPECT_EQ(ekm->size(), 32); diff --git a/quic/fizz/client/handshake/test/MockQuicPskCache.h b/quic/fizz/client/handshake/test/MockQuicPskCache.h index d5aa0e384..2375784f4 100644 --- a/quic/fizz/client/handshake/test/MockQuicPskCache.h +++ b/quic/fizz/client/handshake/test/MockQuicPskCache.h @@ -9,15 +9,15 @@ #include -#include #include +#include #include namespace quic { class MockQuicPskCache : public QuicPskCache { public: - MOCK_METHOD(folly::Optional, getPsk, (const std::string&)); + MOCK_METHOD(Optional, getPsk, (const std::string&)); MOCK_METHOD(void, putPsk, (const std::string&, QuicCachedPsk)); MOCK_METHOD(void, removePsk, (const std::string&)); }; diff --git a/quic/fizz/client/test/QuicClientTransportTest.cpp b/quic/fizz/client/test/QuicClientTransportTest.cpp index 5bcb61f29..586d5b01f 100644 --- a/quic/fizz/client/test/QuicClientTransportTest.cpp +++ b/quic/fizz/client/test/QuicClientTransportTest.cpp @@ -380,10 +380,10 @@ TEST_P(QuicClientTransportIntegrationTest, FlowControlLimitedTest) { TEST_P(QuicClientTransportIntegrationTest, ALPNTest) { EXPECT_CALL(clientConnSetupCallback, onTransportReady()).WillOnce(Invoke([&] { ASSERT_EQ(client->getAppProtocol(), "h3"); - client->close(folly::none); + client->close(none); eventbase_.terminateLoopSoon(); })); - ASSERT_EQ(client->getAppProtocol(), folly::none); + ASSERT_EQ(client->getAppProtocol(), none); client->start(&clientConnSetupCallback, &clientConnCallback); eventbase_.loopForever(); } @@ -400,13 +400,13 @@ TEST_P(QuicClientTransportIntegrationTest, TLSAlert) { const TransportErrorCode* transportError = errorCode.code.asTransportErrorCode(); EXPECT_NE(transportError, nullptr); - client->close(folly::none); + client->close(none); this->checkTransportSummaryEvent(qLogger); eventbase_.terminateLoopSoon(); })); - ASSERT_EQ(client->getAppProtocol(), folly::none); + ASSERT_EQ(client->getAppProtocol(), none); client->start(&clientConnSetupCallback, &clientConnCallback); eventbase_.loopForever(); @@ -484,10 +484,10 @@ TEST_P(QuicClientTransportIntegrationTest, TestZeroRttSuccess) { setupZeroRttOnServerCtx(*serverCtx, cachedPsk); // Change the ctx server_->setFizzContext(serverCtx); - folly::Optional alpn = std::string("h3"); + Optional alpn = std::string("h3"); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional& alpnToValidate, const Buf&) { + [&](const Optional& alpnToValidate, const Buf&) { performedValidation = true; EXPECT_EQ(alpnToValidate, alpn); return true; @@ -562,10 +562,10 @@ TEST_P(QuicClientTransportIntegrationTest, ZeroRttRetryPacketTest) { std::make_shared()); client->setCongestionControl(CongestionControlType::NewReno); - folly::Optional alpn = std::string("h3"); + Optional alpn = std::string("h3"); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional& alpnToValidate, const Buf&) { + [&](const Optional& alpnToValidate, const Buf&) { performedValidation = true; EXPECT_EQ(alpnToValidate, alpn); return true; @@ -706,7 +706,7 @@ TEST_P(QuicClientTransportIntegrationTest, TestZeroRttRejection) { server_->setFizzContext(serverCtx); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { + [&](const Optional&, const Buf&) { performedValidation = true; return true; }, @@ -773,7 +773,7 @@ TEST_P(QuicClientTransportIntegrationTest, TestZeroRttNotAttempted) { server_->setFizzContext(serverCtx); client->getNonConstConn().transportSettings.attemptEarlyData = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { + [&](const Optional&, const Buf&) { EXPECT_TRUE(false); return true; }, @@ -815,7 +815,7 @@ TEST_P(QuicClientTransportIntegrationTest, TestZeroRttInvalidAppParams) { server_->setFizzContext(serverCtx); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { + [&](const Optional&, const Buf&) { performedValidation = true; return false; }, @@ -932,7 +932,7 @@ TEST_P(QuicClientTransportIntegrationTest, ResetClient) { } TEST_P(QuicClientTransportIntegrationTest, TestStatelessResetToken) { - folly::Optional token1, token2; + Optional token1, token2; expectTransportCallbacks(); auto server2 = createServer(ProcessId::ONE); @@ -1053,7 +1053,7 @@ TEST_F(QuicClientTransportTest, FirstPacketProcessedCallback) { deliverData(serverAddr, oneMoreAckPacket->coalesce()); EXPECT_FALSE(client->hasWriteCipher()); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, CloseSocketOnWriteError) { @@ -1078,7 +1078,7 @@ TEST_F(QuicClientTransportTest, AddNewPeerAddressSetsPacketSize) { client->addNewPeerAddress(v6Address); EXPECT_EQ(kDefaultV6UDPSendPacketLen, client->getConn().udpSendPacketLen); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, onNetworkSwitchNoReplace) { @@ -1088,7 +1088,7 @@ TEST_F(QuicClientTransportTest, onNetworkSwitchNoReplace) { EXPECT_CALL(*mockQLogger, addConnectionMigrationUpdate(true)).Times(0); client->onNetworkSwitch(nullptr); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, onNetworkSwitchReplaceAfterHandshake) { @@ -1111,7 +1111,7 @@ TEST_F(QuicClientTransportTest, onNetworkSwitchReplaceAfterHandshake) { EXPECT_CALL(*mockQLogger, addConnectionMigrationUpdate(true)); client->onNetworkSwitch(std::move(newSocket)); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, onNetworkSwitchReplaceNoHandshake) { @@ -1122,7 +1122,7 @@ TEST_F(QuicClientTransportTest, onNetworkSwitchReplaceNoHandshake) { EXPECT_CALL(*mockQLogger, addConnectionMigrationUpdate(true)).Times(0); EXPECT_CALL(*newSocketPtr, bind(_)).Times(0); client->onNetworkSwitch(std::move(newSocket)); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, SocketClosedDuringOnTransportReady) { @@ -1135,7 +1135,7 @@ TEST_F(QuicClientTransportTest, SocketClosedDuringOnTransportReady) { : socket_(std::move(socket)) {} void onTransportReady() noexcept override { - socket_->close(folly::none); + socket_->close(none); socket_.reset(); onTransportReadyMock(); } @@ -1242,7 +1242,7 @@ TEST_F(QuicClientTransportTest, SetQLoggerDcid) { EXPECT_CALL( *mockQLogger, setDcid(client->getConn().clientChosenDestConnectionId)); client->setQLogger(mockQLogger); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, CheckQLoggerRefCount) { @@ -1274,7 +1274,7 @@ TEST_F(QuicClientTransportTest, CheckQLoggerRefCount) { client->setQLogger(nullptr); CHECK(client->getQLogger() == nullptr); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, SwitchServerCidsNoOtherIds) { @@ -1287,7 +1287,7 @@ TEST_F(QuicClientTransportTest, SwitchServerCidsNoOtherIds) { EXPECT_EQ(conn.retireAndSwitchPeerConnectionIds(), false); EXPECT_EQ(conn.pendingEvents.frames.size(), 0); EXPECT_EQ(conn.peerConnectionIds.size(), 1); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, SwitchServerCidsOneOtherCid) { @@ -1312,7 +1312,7 @@ TEST_F(QuicClientTransportTest, SwitchServerCidsOneOtherCid) { auto replacedCid = conn.serverConnectionId; EXPECT_NE(originalCid.connId, *replacedCid); EXPECT_EQ(secondCid.connId, *replacedCid); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportTest, SwitchServerCidsMultipleCids) { @@ -1341,7 +1341,7 @@ TEST_F(QuicClientTransportTest, SwitchServerCidsMultipleCids) { auto replacedCid = conn.serverConnectionId; EXPECT_NE(originalCid.connId, *replacedCid); EXPECT_EQ(secondCid.connId, *replacedCid); - client->closeNow(folly::none); + client->closeNow(none); } enum class ServerFirstPacketType : uint8_t { ServerHello, Retry }; @@ -2316,7 +2316,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReadStream) { eventbase_->loopForever(); } EXPECT_TRUE(dataDelivered); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, CleanupReadLoopCounting) { @@ -2487,7 +2487,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReadStreamMultiplePackets) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none /* longHeaderOverride */, + none /* longHeaderOverride */, false /* eof */)); auto packet2 = packetToBuf(createStreamPacket( *serverChosenConnId /* src */, @@ -2497,9 +2497,9 @@ TEST_F(QuicClientTransportAfterStartTest, ReadStreamMultiplePackets) { *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none /* longHeaderOverride */, + none /* longHeaderOverride */, true /* eof */, - folly::none /* shortHeaderOverride */, + none /* shortHeaderOverride */, data->length() /* offset */)); socketReads.emplace_back(TestReadData(packet1->coalesce(), serverAddr)); @@ -2508,7 +2508,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReadStreamMultiplePackets) { eventbase_->loopForever(); } EXPECT_TRUE(dataDelivered); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, ReadStreamWithRetriableError) { @@ -2518,7 +2518,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReadStreamWithRetriableError) { EXPECT_CALL(readCb, readError(_, _)).Times(0); deliverNetworkError(EAGAIN); client->setReadCallback(streamId, nullptr); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, ReadStreamWithNonRetriableError) { @@ -2529,7 +2529,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReadStreamWithNonRetriableError) { EXPECT_CALL(readCb, readError(_, _)).Times(0); deliverNetworkError(EBADF); client->setReadCallback(streamId, nullptr); - client->close(folly::none); + client->close(none); } TEST_F( @@ -2564,7 +2564,7 @@ TEST_F( eventbase_->loopForever(); } EXPECT_TRUE(dataDelivered); - client->close(folly::none); + client->close(none); } TEST_F( @@ -2839,7 +2839,7 @@ TEST_P(QuicClientTransportAfterStartTest, ReadStreamCoalesced) { eventbase_->loopForever(); } EXPECT_TRUE(dataDelivered); - client->close(folly::none); + client->close(none); std::vector indices = getQLogEventIndices(QLogEventType::PacketDrop, qLogger); EXPECT_EQ(indices.size(), 1); @@ -2889,7 +2889,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReadStreamCoalescedMany) { auto data = packets.move(); deliverData(data->coalesce()); eventbase_->loopOnce(); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, RecvPathChallengeNoAvailablePeerIds) { @@ -3012,7 +3012,7 @@ TEST_F(QuicClientTransportAfterStartTest, CloseConnectionWithStreamPending) { *expected, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true)); socketWrites.clear(); deliverData(packet->coalesce()); @@ -3081,12 +3081,12 @@ TEST_F(QuicClientTransportAfterStartTest, CloseConnectionWithNoStreamPending) { *expected, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true)); socketWrites.clear(); deliverData(packet->coalesce()); EXPECT_CALL(readCb, readError(streamId, _)); - client->close(folly::none); + client->close(none); EXPECT_TRUE(verifyFramePresent( socketWrites, *makeEncryptedCodec(), @@ -3136,7 +3136,7 @@ TEST_P( EXPECT_TRUE(event->sendCloseImmediately); } else { - client->close(folly::none); + client->close(none); EXPECT_TRUE(verifyFramePresent( socketWrites, *makeHandshakeCodec(), @@ -3278,7 +3278,7 @@ TEST_P(QuicClientTransportAfterStartTestClose, CloseConnectionWithError) { *expected, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true)); deliverData(packet->coalesce()); socketWrites.clear(); @@ -3291,7 +3291,7 @@ TEST_P(QuicClientTransportAfterStartTestClose, CloseConnectionWithError) { *makeHandshakeCodec(), QuicFrame::Type::ConnectionCloseFrame)); } else { - client->close(folly::none); + client->close(none); EXPECT_TRUE(verifyFramePresent( socketWrites, *makeHandshakeCodec(), @@ -3327,7 +3327,7 @@ TEST_P( *expected, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, true)); deliverData(packet->coalesce()); EXPECT_NE(client->getConn().readCodec->getInitialCipher(), nullptr); @@ -3401,7 +3401,7 @@ TEST_F(QuicClientTransportAfterStartTest, IdleTimerNotResetOnDuplicatePacket) { ASSERT_FALSE(client->getConn().receivedNewPacketBeforeWrite); ASSERT_FALSE(client->idleTimeout().isTimerCallbackScheduled()); - client->closeNow(folly::none); + client->closeNow(none); } TEST_P(QuicClientTransportAfterStartTestClose, TimeoutsNotSetAfterClose) { @@ -3425,7 +3425,7 @@ TEST_P(QuicClientTransportAfterStartTestClose, TimeoutsNotSetAfterClose) { QuicErrorCode(TransportErrorCode::INTERNAL_ERROR), std::string("how about no"))); } else { - client->close(folly::none); + client->close(none); } client->idleTimeout().cancelTimerCallback(); ASSERT_FALSE(client->idleTimeout().isTimerCallbackScheduled()); @@ -3457,7 +3457,7 @@ TEST_F(QuicClientTransportAfterStartTest, IdleTimerNotResetOnWritingOldData) { ASSERT_FALSE(client->getConn().receivedNewPacketBeforeWrite); ASSERT_FALSE(client->idleTimeout().isTimerCallbackScheduled()); - client->closeNow(folly::none); + client->closeNow(none); } TEST_F(QuicClientTransportAfterStartTest, IdleTimerResetNoOutstandingPackets) { @@ -3633,7 +3633,7 @@ TEST_F( data->computeChainDataLength(), data->computeChainDataLength(), false, - folly::none /* skipLenHint */); + none /* skipLenHint */); writeStreamFrameData(builder2, data->clone(), data->computeChainDataLength()); auto packetObject = std::move(builder2).buildPacket(); auto packet2 = packetToBuf(std::move(packetObject)); @@ -3683,7 +3683,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReceiveRstStreamAfterEom) { deliverData(packet2->coalesce()); EXPECT_TRUE(client->getReadCallbacks().empty()); - client->close(folly::none); + client->close(none); } TEST_F( @@ -3729,7 +3729,7 @@ TEST_F( ASSERT_EQ( client->getNonConstConn().streamManager->getStream(streamId), nullptr); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, StreamClosedIfReadCallbackNull) { @@ -3766,7 +3766,7 @@ TEST_F(QuicClientTransportAfterStartTest, StreamClosedIfReadCallbackNull) { ASSERT_EQ( client->getNonConstConn().streamManager->getStream(streamId), nullptr); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, ReceiveAckInvokesDeliveryCallback) { @@ -3790,7 +3790,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReceiveAckInvokesDeliveryCallback) { EXPECT_CALL(deliveryCallback, onDeliveryAck(streamId, 0, _)).Times(1); deliverData(packet->coalesce()); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, InvokesDeliveryCallbackFinOnly) { @@ -3813,7 +3813,7 @@ TEST_F(QuicClientTransportAfterStartTest, InvokesDeliveryCallbackFinOnly) { EXPECT_CALL(deliveryCallback, onDeliveryAck(streamId, _, _)).Times(1); deliverData(packet->coalesce()); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, InvokesDeliveryCallbackRange) { @@ -3846,7 +3846,7 @@ TEST_F(QuicClientTransportAfterStartTest, InvokesDeliveryCallbackRange) { PacketNumberSpace::AppData)); deliverData(packet->coalesce()); - client->close(folly::none); + client->close(none); } TEST_F( @@ -3876,7 +3876,7 @@ TEST_F( EXPECT_CALL(deliveryCallback, onDeliveryAck(streamId, 0, _)).Times(1); client->registerDeliveryCallback(streamId, 0, &deliveryCallback); eventbase_->loopOnce(); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, DeliveryCallbackFromWriteChain) { @@ -3902,7 +3902,7 @@ TEST_F(QuicClientTransportAfterStartTest, DeliveryCallbackFromWriteChain) { // DeliveryCallback is called, and offset delivered is 10: EXPECT_CALL(deliveryCallback, onDeliveryAck(streamId, 10, _)).Times(1); deliverData(packet->coalesce()); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, NotifyPendingWrite) { @@ -3910,7 +3910,7 @@ TEST_F(QuicClientTransportAfterStartTest, NotifyPendingWrite) { EXPECT_CALL(writeCallback, onConnectionWriteReady(_)); client->notifyPendingWriteOnConnection(&writeCallback); loopForWrites(); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, SwitchEvbWhileAsyncEventPending) { @@ -3922,7 +3922,7 @@ TEST_F(QuicClientTransportAfterStartTest, SwitchEvbWhileAsyncEventPending) { client->detachEventBase(); client->attachEventBase(qEvb2); loopForWrites(); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, StatelessResetClosesTransport) { @@ -3933,7 +3933,7 @@ TEST_F(QuicClientTransportAfterStartTest, StatelessResetClosesTransport) { // Make the decrypt fail EXPECT_CALL(*aead, _tryDecrypt(_, _, _)) - .WillRepeatedly(Invoke([&](auto&, auto, auto) { return folly::none; })); + .WillRepeatedly(Invoke([&](auto&, auto, auto) { return none; })); auto token = *client->getConn().statelessResetToken; StatelessResetPacketBuilder builder(kDefaultUDPSendPacketLen, token); @@ -3951,7 +3951,7 @@ TEST_F(QuicClientTransportAfterStartTest, BadStatelessResetWontCloseTransport) { ASSERT_TRUE(aead); // Make the decrypt fail EXPECT_CALL(*aead, _tryDecrypt(_, _, _)) - .WillRepeatedly(Invoke([&](auto&, auto, auto) { return folly::none; })); + .WillRepeatedly(Invoke([&](auto&, auto, auto) { return none; })); // Alter the expected token so it definitely won't match the one in conn auto token = *client->getConn().statelessResetToken; token[0] = ~token[0]; @@ -4026,7 +4026,7 @@ TEST_F(QuicClientTransportVersionAndRetryTest, RetryPacket) { EXPECT_EQ(header.getDestinationConnId(), serverCid); eventbase_->loopOnce(); - client->close(folly::none); + client->close(none); } TEST_F( @@ -4053,7 +4053,7 @@ TEST_F( EXPECT_EQ(client->getConn().oneRttWriteCipher.get(), nullptr); EXPECT_CALL(clientConnSetupCallback, onTransportReady()).Times(0); EXPECT_CALL(clientConnSetupCallback, onReplaySafe()).Times(0); - client->close(folly::none); + client->close(none); } TEST_F( @@ -4073,7 +4073,7 @@ TEST_F( {QuicVersion::MVFST}) .buildPacket(); EXPECT_THROW(deliverData(packet.second->coalesce()), std::runtime_error); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportVersionAndRetryTest, UnencryptedStreamData) { @@ -4217,7 +4217,7 @@ TEST_F(QuicClientTransportAfterStartTest, SendReset) { deliverData(packet->coalesce()); // Stream is not yet closed because ingress state machine is open EXPECT_TRUE(conn.streamManager->streamExists(streamId)); - client->close(folly::none); + client->close(none); EXPECT_TRUE(client->isClosed()); } @@ -4247,7 +4247,7 @@ TEST_F(QuicClientTransportAfterStartTest, ResetClearsPendingLoss) { StreamId streamId = client->createBidirectionalStream().value(); client->setReadCallback(streamId, &readCb); SCOPE_EXIT { - client->close(folly::none); + client->close(none); }; client->writeChain(streamId, IOBuf::copyBuffer("hello"), true); loopForWrites(); @@ -4266,7 +4266,7 @@ TEST_F(QuicClientTransportAfterStartTest, LossAfterResetStream) { StreamId streamId = client->createBidirectionalStream().value(); client->setReadCallback(streamId, &readCb); SCOPE_EXIT { - client->close(folly::none); + client->close(none); }; client->writeChain(streamId, IOBuf::copyBuffer("hello"), true); loopForWrites(); @@ -4309,7 +4309,7 @@ TEST_F(QuicClientTransportAfterStartTest, SendResetAfterEom) { deliverData(packet->coalesce()); // Stream still exists since ingress state machine is still open EXPECT_TRUE(conn.streamManager->streamExists(streamId)); - client->close(folly::none); + client->close(none); EXPECT_TRUE(client->isClosed()); } @@ -4360,7 +4360,7 @@ TEST_F(QuicClientTransportAfterStartTest, HalfClosedLocalToClosed) { EXPECT_EQ(1, readCbs.count(streamId)); EXPECT_EQ(0, conn.streamManager->readableStreams().count(streamId)); EXPECT_TRUE(conn.streamManager->streamExists(streamId)); - client->close(folly::none); + client->close(none); EXPECT_EQ(0, readCbs.count(streamId)); EXPECT_FALSE(conn.streamManager->streamExists(streamId)); EXPECT_TRUE(client->isClosed()); @@ -4415,7 +4415,7 @@ TEST_F(QuicClientTransportAfterStartTest, SendResetSyncOnAck) { deliverData(packet->coalesce()); // Stream should be closed after it received the ack for rst EXPECT_FALSE(conn.streamManager->streamExists(streamId)); - client->close(folly::none); + client->close(none); EXPECT_TRUE(client->isClosed()); } @@ -4468,7 +4468,7 @@ TEST_F(QuicClientTransportAfterStartTest, HalfClosedRemoteToClosed) { EXPECT_FALSE(conn.streamManager->hasDeliverable()); EXPECT_TRUE(conn.streamManager->streamExists(streamId)); EXPECT_EQ(readCbs.count(streamId), 1); - client->close(folly::none); + client->close(none); EXPECT_FALSE(conn.streamManager->streamExists(streamId)); EXPECT_EQ(readCbs.count(streamId), 0); EXPECT_TRUE(client->isClosed()); @@ -4598,7 +4598,7 @@ TEST_F(QuicClientTransportAfterStartTest, DestroyWhileDraining) { EXPECT_CALL(deliveryCallback, onCanceled(_, _)); EXPECT_CALL(readCb, readError(_, _)); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientTransportAfterStartTest, CloseNowWhileDraining) { @@ -4907,7 +4907,7 @@ TEST_F(QuicClientTransportAfterStartTest, RetryPacketAfterRxInitial) { loopForWrites(); // validate we dropped the retry packet via retryToken str EXPECT_TRUE(client->getConn().retryToken.empty()); - client->close(folly::none); + client->close(none); } TEST_F(QuicClientVersionParamInvalidTest, InvalidVersion) { @@ -4933,7 +4933,7 @@ class QuicClientTransportPskCacheTest TEST_F(QuicClientTransportPskCacheTest, TestOnNewCachedPsk) { std::string appParams = "APP params"; client->setEarlyDataAppParamsFunctions( - [](const folly::Optional&, const Buf&) { return true; }, + [](const Optional&, const Buf&) { return true; }, [=]() -> Buf { return folly::IOBuf::copyBuffer(appParams); }); EXPECT_CALL(*mockPskCache_, putPsk(hostname_, _)) .WillOnce(Invoke([=](const std::string&, QuicCachedPsk psk) { @@ -4945,7 +4945,7 @@ TEST_F(QuicClientTransportPskCacheTest, TestOnNewCachedPsk) { TEST_F(QuicClientTransportPskCacheTest, TestTwoOnNewCachedPsk) { std::string appParams1 = "APP params1"; client->setEarlyDataAppParamsFunctions( - [](const folly::Optional&, const Buf&) { return true; }, + [](const Optional&, const Buf&) { return true; }, [=]() -> Buf { return folly::IOBuf::copyBuffer(appParams1); }); EXPECT_CALL(*mockPskCache_, putPsk(hostname_, _)) .WillOnce(Invoke([=](const std::string&, QuicCachedPsk psk) { @@ -4973,7 +4973,7 @@ TEST_F(QuicClientTransportPskCacheTest, TestTwoOnNewCachedPsk) { std::string appParams2 = "APP params2"; client->setEarlyDataAppParamsFunctions( - [](const folly::Optional&, const Buf&) { return true; }, + [](const Optional&, const Buf&) { return true; }, [=]() -> Buf { return folly::IOBuf::copyBuffer(appParams2); }); EXPECT_CALL(*mockPskCache_, putPsk(hostname_, _)) .WillOnce(Invoke([=](const std::string&, QuicCachedPsk psk) { @@ -5083,7 +5083,7 @@ TEST_F(QuicZeroRttClientTest, TestReplaySafeCallback) { })); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { + [&](const Optional&, const Buf&) { performedValidation = true; return true; }, @@ -5161,7 +5161,7 @@ TEST_F(QuicZeroRttClientTest, TestEarlyRetransmit0Rtt) { client->setTransportSettings(tp); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { + [&](const Optional&, const Buf&) { performedValidation = true; return true; }, @@ -5241,7 +5241,7 @@ TEST_F(QuicZeroRttClientTest, TestZeroRttRejection) { })); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { + [&](const Optional&, const Buf&) { performedValidation = true; return true; }, @@ -5293,7 +5293,7 @@ TEST_F(QuicZeroRttClientTest, TestZeroRttRejectionWithSmallerFlowControl) { })); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { + [&](const Optional&, const Buf&) { performedValidation = true; return true; }, @@ -5336,7 +5336,7 @@ TEST_F(QuicZeroRttClientTest, TestZeroRttRejectionCannotResendZeroRttData) { })); bool performedValidation = false; client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { + [&](const Optional&, const Buf&) { performedValidation = true; return true; }, @@ -5415,7 +5415,7 @@ TEST_F( return quicCachedPsk; })); client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { return true; }, + [&](const Optional&, const Buf&) { return true; }, []() -> Buf { return nullptr; }); EXPECT_CALL(*sock, write(firstAddress, _)) @@ -5506,7 +5506,7 @@ TEST_F( return quicCachedPsk; })); client->setEarlyDataAppParamsFunctions( - [&](const folly::Optional&, const Buf&) { return true; }, + [&](const Optional&, const Buf&) { return true; }, []() -> Buf { return nullptr; }); EXPECT_CALL(*sock, write(firstAddress, _)) @@ -5894,7 +5894,7 @@ TEST(AsyncUDPSocketTest, CloseMultipleTimes) { EmptyReadCallback readCallback; happyEyeballsSetUpSocket( socket, - folly::none, + none, folly::SocketAddress("127.0.0.1", 12345), transportSettings, 0, // tosValue diff --git a/quic/fizz/client/test/QuicClientTransportTestUtil.h b/quic/fizz/client/test/QuicClientTransportTestUtil.h index 1a55cab31..bd4812e2a 100644 --- a/quic/fizz/client/test/QuicClientTransportTestUtil.h +++ b/quic/fizz/client/test/QuicClientTransportTestUtil.h @@ -163,12 +163,12 @@ class FakeOneRttHandshakeLayer : public FizzClientHandshake { std::move(fizzContext), std::make_unique()) {} - folly::Optional connectImpl( - folly::Optional hostname) override { + Optional connectImpl( + Optional hostname) override { // Look up psk - folly::Optional quicCachedPsk = getPsk(hostname); + Optional quicCachedPsk = getPsk(hostname); - folly::Optional transportParams; + Optional transportParams; if (quicCachedPsk) { transportParams = quicCachedPsk->transportParams; } @@ -316,7 +316,7 @@ class FakeOneRttHandshakeLayer : public FizzClientHandshake { return connected_; } - const folly::Optional& getServerTransportParams() + const Optional& getServerTransportParams() override { return params_; } @@ -339,7 +339,7 @@ class FakeOneRttHandshakeLayer : public FizzClientHandshake { uint64_t connWindowSize{kDefaultConnectionFlowControlWindow}; uint64_t maxInitialStreamsBidi{std::numeric_limits::max()}; uint64_t maxInitialStreamsUni{std::numeric_limits::max()}; - folly::Optional params_; + Optional params_; EnumArray readBuffers{}; std::unique_ptr oneRttWriteCipher_; @@ -358,7 +358,7 @@ class FakeOneRttHandshakeLayer : public FizzClientHandshake { throw std::runtime_error( "getReadRecordLayerEncryptionLevel not implemented"); } - const folly::Optional& getApplicationProtocol() const override { + const Optional& getApplicationProtocol() const override { throw std::runtime_error("getApplicationProtocol not implemented"); } void processSocketData(folly::IOBufQueue&) override { @@ -387,7 +387,7 @@ class QuicClientTransportTestBase : public virtual testing::Test { struct TestReadData { ReceivedUdpPacket udpPacket; folly::SocketAddress addr; - folly::Optional err; + Optional err; TestReadData(folly::ByteRange dataIn, folly::SocketAddress addrIn) : udpPacket(folly::IOBuf::copyBuffer(dataIn)), @@ -651,7 +651,7 @@ class QuicClientTransportTestBase : public virtual testing::Test { recvServerHello(serverAddr); } - void recvTicket(folly::Optional offsetOverride = folly::none) { + void recvTicket(Optional offsetOverride = none) { auto negotiatedVersion = *client->getConn().version; auto ticket = folly::IOBuf::copyBuffer("NST"); auto packet = packetToBuf(createCryptoPacket( @@ -835,9 +835,7 @@ class QuicClientTransportTestBase : public virtual testing::Test { eventbase_->loopOnce(EVLOOP_NONBLOCK); } - void assertWritten( - bool shortHeader, - folly::Optional longHeader) { + void assertWritten(bool shortHeader, Optional longHeader) { size_t numShort = 0; size_t numLong = 0; size_t numOthers = 0; @@ -979,8 +977,8 @@ class QuicClientTransportTestBase : public virtual testing::Test { std::shared_ptr client; PacketNum initialPacketNum{0}, handshakePacketNum{0}, appDataPacketNum{0}; std::unique_ptr connIdAlgo_; - folly::Optional originalConnId; - folly::Optional serverChosenConnId; + Optional originalConnId; + Optional serverChosenConnId; QuicVersion version{QuicVersion::QUIC_V1}; std::shared_ptr> quicStats_; std::string hostname_{"TestHost"}; diff --git a/quic/fizz/handshake/BUCK b/quic/fizz/handshake/BUCK index 3cbe6d420..bc878e17c 100644 --- a/quic/fizz/handshake/BUCK +++ b/quic/fizz/handshake/BUCK @@ -22,6 +22,7 @@ mvfst_cpp_library( deps = [ "//fizz/crypto:crypto", "//fizz/crypto:utils", + "//quic/common:optional", ], exported_deps = [ "//fizz/backend:openssl", diff --git a/quic/fizz/handshake/FizzBridge.cpp b/quic/fizz/handshake/FizzBridge.cpp index 411580726..6363144be 100644 --- a/quic/fizz/handshake/FizzBridge.cpp +++ b/quic/fizz/handshake/FizzBridge.cpp @@ -25,13 +25,13 @@ EncryptionLevel getEncryptionLevelFromFizz( folly::assume_unreachable(); } -folly::Optional FizzAead::getKey() const { +Optional FizzAead::getKey() const { if (!fizzAead) { - return folly::none; + return none; } auto fizzKey = fizzAead->getKey(); if (!fizzKey) { - return folly::none; + return none; } TrafficKey quicKey; quicKey.key = std::move(fizzKey->key); diff --git a/quic/fizz/handshake/FizzBridge.h b/quic/fizz/handshake/FizzBridge.h index fe010292a..deea14e0e 100644 --- a/quic/fizz/handshake/FizzBridge.h +++ b/quic/fizz/handshake/FizzBridge.h @@ -28,7 +28,7 @@ class FizzAead final : public Aead { return std::unique_ptr(new FizzAead(std::move(fizzAeadIn))); } - folly::Optional getKey() const override; + Optional getKey() const override; /** * Simply forward all calls to fizz::Aead. @@ -49,7 +49,7 @@ class FizzAead final : public Aead { return fizzAead->decrypt( std::move(ciphertext), associatedData, seqNum, options); } - folly::Optional> tryDecrypt( + Optional> tryDecrypt( std::unique_ptr&& ciphertext, const folly::IOBuf* associatedData, uint64_t seqNum) const override { diff --git a/quic/fizz/handshake/FizzTransportParameters.h b/quic/fizz/handshake/FizzTransportParameters.h index cc1433134..cb492c887 100644 --- a/quic/fizz/handshake/FizzTransportParameters.h +++ b/quic/fizz/handshake/FizzTransportParameters.h @@ -117,13 +117,13 @@ inline fizz::Extension encodeExtension( namespace fizz { -inline folly::Optional getClientExtension( +inline quic::Optional getClientExtension( const std::vector& extensions, quic::QuicVersion encodingVersion) { auto extensionType = getQuicTransportParametersExtention(encodingVersion); auto it = findExtension(extensions, extensionType); if (it == extensions.end()) { - return folly::none; + return quic::none; } quic::ClientTransportParameters parameters; folly::io::Cursor cursor(it->extension_data.get()); @@ -131,13 +131,13 @@ inline folly::Optional getClientExtension( return parameters; } -inline folly::Optional getServerExtension( +inline quic::Optional getServerExtension( const std::vector& extensions, quic::QuicVersion encodingVersion) { auto extensionType = getQuicTransportParametersExtention(encodingVersion); auto it = findExtension(extensions, extensionType); if (it == extensions.end()) { - return folly::none; + return quic::none; } quic::ServerTransportParameters parameters; folly::io::Cursor cursor(it->extension_data.get()); @@ -145,13 +145,13 @@ inline folly::Optional getServerExtension( return parameters; } -inline folly::Optional getTicketExtension( +inline quic::Optional getTicketExtension( const std::vector& extensions, quic::QuicVersion encodingVersion) { auto extensionType = getQuicTransportParametersExtention(encodingVersion); auto it = findExtension(extensions, extensionType); if (it == extensions.end()) { - return folly::none; + return quic::none; } quic::TicketTransportParameters parameters; folly::io::Cursor cursor(it->extension_data.get()); diff --git a/quic/fizz/handshake/QuicFizzFactory.cpp b/quic/fizz/handshake/QuicFizzFactory.cpp index c5fba3c7b..1f805f475 100644 --- a/quic/fizz/handshake/QuicFizzFactory.cpp +++ b/quic/fizz/handshake/QuicFizzFactory.cpp @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include namespace { @@ -17,7 +18,7 @@ class QuicPlaintextReadRecordLayer : public fizz::PlaintextReadRecordLayer { folly::IOBufQueue& buf, fizz::Aead::AeadOptions) override { if (buf.empty()) { - return folly::none; + return quic::none; } fizz::TLSMessage msg; msg.type = fizz::ContentType::handshake; @@ -37,7 +38,7 @@ class QuicEncryptedReadRecordLayer : public fizz::EncryptedReadRecordLayer { folly::IOBufQueue& buf, fizz::Aead::AeadOptions) override { if (buf.empty()) { - return folly::none; + return quic::none; } fizz::TLSMessage msg; msg.type = fizz::ContentType::handshake; diff --git a/quic/fizz/handshake/test/FizzCryptoFactoryTest.cpp b/quic/fizz/handshake/test/FizzCryptoFactoryTest.cpp index 84ccd478e..5530d09b9 100644 --- a/quic/fizz/handshake/test/FizzCryptoFactoryTest.cpp +++ b/quic/fizz/handshake/test/FizzCryptoFactoryTest.cpp @@ -58,8 +58,8 @@ class FizzCryptoFactoryTest : public Test { return mockPacketNumberCipher; } - folly::Optional trafficKey_; - folly::Optional> packetCipherKey_; + Optional trafficKey_; + Optional> packetCipherKey_; }; TEST_F(FizzCryptoFactoryTest, TestV1ClearTextCipher) { diff --git a/quic/fizz/handshake/test/FizzTransportParametersTest.cpp b/quic/fizz/handshake/test/FizzTransportParametersTest.cpp index daab06209..da80b56ef 100644 --- a/quic/fizz/handshake/test/FizzTransportParametersTest.cpp +++ b/quic/fizz/handshake/test/FizzTransportParametersTest.cpp @@ -73,7 +73,7 @@ TEST_F(QuicExtensionsTest, TestClientParamsV1) { // Confirm D29 parameters are not parsed for V1. auto d29Exts = getExtensions(clientParamsD29); auto d2Ext = getClientExtension(exts, kQuicDraft); - EXPECT_EQ(d2Ext, folly::none); + EXPECT_EQ(d2Ext, none); } TEST_F(QuicExtensionsTest, TestClientParamsD29) { @@ -114,7 +114,7 @@ TEST_F(QuicExtensionsTest, TestServerParamsV1) { // Confirm D29 parameters are not parsed for V1. auto d29Exts = getExtensions(serverParamsD29); auto d2Ext = getServerExtension(exts, kQuicDraft); - EXPECT_EQ(d2Ext, folly::none); + EXPECT_EQ(d2Ext, none); } TEST_F(QuicExtensionsTest, TestServerParamsD29) { @@ -156,7 +156,7 @@ TEST_F(QuicExtensionsTest, TestTicketParamsV1) { // Confirm D29 parameters are not parsed for V1. auto d29Exts = getExtensions(ticketParamsD29); auto d2Ext = getTicketExtension(exts, kQuicDraft); - EXPECT_EQ(d2Ext, folly::none); + EXPECT_EQ(d2Ext, none); } TEST_F(QuicExtensionsTest, TestTicketParamsD29) { diff --git a/quic/fizz/server/handshake/AppToken.cpp b/quic/fizz/server/handshake/AppToken.cpp index 5fb0b7ecd..e61272d83 100644 --- a/quic/fizz/server/handshake/AppToken.cpp +++ b/quic/fizz/server/handshake/AppToken.cpp @@ -26,7 +26,7 @@ std::unique_ptr encodeAppToken(const AppToken& appToken) { return buf; } -folly::Optional decodeAppToken(const folly::IOBuf& buf) { +Optional decodeAppToken(const folly::IOBuf& buf) { AppToken appToken; folly::io::Cursor cursor(&buf); std::vector extensions; @@ -44,7 +44,7 @@ folly::Optional decodeAppToken(const folly::IOBuf& buf) { fizz::detail::read(appToken.version, cursor); fizz::detail::readBuf(appToken.appParams, cursor); } catch (const std::exception&) { - return folly::none; + return none; } return appToken; } diff --git a/quic/fizz/server/handshake/AppToken.h b/quic/fizz/server/handshake/AppToken.h index d4e97a375..87e6927ea 100644 --- a/quic/fizz/server/handshake/AppToken.h +++ b/quic/fizz/server/handshake/AppToken.h @@ -11,13 +11,13 @@ #include -#include +#include namespace quic { std::unique_ptr encodeAppToken(const AppToken& appToken); -folly::Optional decodeAppToken(const folly::IOBuf& buf); +Optional decodeAppToken(const folly::IOBuf& buf); } // namespace quic diff --git a/quic/fizz/server/handshake/BUCK b/quic/fizz/server/handshake/BUCK index 130ce2567..e9027fb25 100644 --- a/quic/fizz/server/handshake/BUCK +++ b/quic/fizz/server/handshake/BUCK @@ -40,7 +40,7 @@ mvfst_cpp_library( ], exported_deps = [ "//fizz/record:record", - "//folly:optional", + "//quic/common:optional", "//quic/server/handshake:app_token", ], ) diff --git a/quic/flowcontrol/QuicFlowController.cpp b/quic/flowcontrol/QuicFlowController.cpp index 795a00295..103f084ff 100644 --- a/quic/flowcontrol/QuicFlowController.cpp +++ b/quic/flowcontrol/QuicFlowController.cpp @@ -16,19 +16,19 @@ namespace quic { namespace { -folly::Optional calculateNewWindowUpdate( +Optional calculateNewWindowUpdate( uint64_t curReadOffset, uint64_t curAdvertisedOffset, uint64_t windowSize, const std::chrono::microseconds& srtt, const TransportSettings& transportSettings, - const folly::Optional& lastSendTime, + const Optional& lastSendTime, const TimePoint& updateTime) { DCHECK_LE(curReadOffset, curAdvertisedOffset); auto nextAdvertisedOffset = curReadOffset + windowSize; if (nextAdvertisedOffset == curAdvertisedOffset) { // No change in flow control - return folly::none; + return none; } bool enoughTimeElapsed = lastSendTime && updateTime > *lastSendTime && (updateTime - *lastSendTime) > @@ -43,7 +43,7 @@ folly::Optional calculateNewWindowUpdate( if (enoughWindowElapsed) { return nextAdvertisedOffset; } - return folly::none; + return none; } template @@ -72,7 +72,7 @@ inline uint64_t calculateMaximumData(const QuicStreamState& stream) { } // namespace void maybeIncreaseFlowControlWindow( - const folly::Optional& timeOfLastFlowControlUpdate, + const Optional& timeOfLastFlowControlUpdate, TimePoint updateTime, std::chrono::microseconds srtt, uint64_t& windowSize) { diff --git a/quic/flowcontrol/QuicFlowController.h b/quic/flowcontrol/QuicFlowController.h index c389041b5..e37347ad1 100644 --- a/quic/flowcontrol/QuicFlowController.h +++ b/quic/flowcontrol/QuicFlowController.h @@ -12,7 +12,7 @@ namespace quic { void maybeIncreaseFlowControlWindow( - const folly::Optional& timeOfLastFlowControlUpdate, + const Optional& timeOfLastFlowControlUpdate, TimePoint updateTime, std::chrono::microseconds srtt, uint64_t& windowSize); diff --git a/quic/handshake/Aead.h b/quic/handshake/Aead.h index 2ed0b6b3e..82a48f3ef 100644 --- a/quic/handshake/Aead.h +++ b/quic/handshake/Aead.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include namespace quic { @@ -24,7 +24,7 @@ class Aead { public: virtual ~Aead() = default; - virtual folly::Optional getKey() const = 0; + virtual Optional getKey() const = 0; /** * Encrypts plaintext inplace. Will throw on error. @@ -53,7 +53,7 @@ class Aead { * Decrypt ciphertext. Will return none if the ciphertext does not decrypt * successfully. May still throw from errors unrelated to ciphertext. */ - virtual folly::Optional> tryDecrypt( + virtual Optional> tryDecrypt( std::unique_ptr&& ciphertext, const folly::IOBuf* associatedData, uint64_t seqNum) const = 0; diff --git a/quic/handshake/BUCK b/quic/handshake/BUCK index 4bcae6d13..e93b025f5 100644 --- a/quic/handshake/BUCK +++ b/quic/handshake/BUCK @@ -8,8 +8,8 @@ mvfst_cpp_library( "Aead.h", ], exported_deps = [ - "//folly:optional", "//folly/io:iobuf", + "//quic/common:optional", ], ) diff --git a/quic/handshake/HandshakeLayer.h b/quic/handshake/HandshakeLayer.h index 03fc233ed..7bfa7bcc5 100644 --- a/quic/handshake/HandshakeLayer.h +++ b/quic/handshake/HandshakeLayer.h @@ -23,8 +23,7 @@ class Handshake { public: virtual ~Handshake() = default; - virtual const folly::Optional& getApplicationProtocol() - const = 0; + virtual const Optional& getApplicationProtocol() const = 0; /** * An API to get oneRttReadCiphers on key rotation. Each call will return a @@ -46,9 +45,9 @@ class Handshake { * context is the context value argument for the TLS exporter. * keyLength is the length of the exported key. */ - virtual folly::Optional> getExportedKeyingMaterial( + virtual Optional> getExportedKeyingMaterial( const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength) = 0; virtual void handshakeConfirmed() { diff --git a/quic/handshake/TransportParameters.cpp b/quic/handshake/TransportParameters.cpp index 85962a3a4..119b57a9e 100644 --- a/quic/handshake/TransportParameters.cpp +++ b/quic/handshake/TransportParameters.cpp @@ -12,12 +12,12 @@ namespace quic { -folly::Optional getIntegerParameter( +Optional getIntegerParameter( TransportParameterId id, const std::vector& parameters) { auto it = findParameter(parameters, id); if (it == parameters.end()) { - return folly::none; + return none; } auto parameterCursor = folly::io::Cursor(it->value.get()); auto parameter = decodeQuicInteger(parameterCursor); @@ -30,12 +30,12 @@ folly::Optional getIntegerParameter( return parameter->first; } -folly::Optional getConnIdParameter( +Optional getConnIdParameter( TransportParameterId id, const std::vector& parameters) { auto it = findParameter(parameters, id); if (it == parameters.end()) { - return folly::none; + return none; } auto value = it->value->clone(); @@ -45,12 +45,12 @@ folly::Optional getConnIdParameter( return ConnectionId(cursor, value->length()); } -folly::Optional getStatelessResetTokenParameter( +Optional getStatelessResetTokenParameter( const std::vector& parameters) { auto it = findParameter(parameters, TransportParameterId::stateless_reset_token); if (it == parameters.end()) { - return folly::none; + return none; } auto value = it->value->clone(); diff --git a/quic/handshake/TransportParameters.h b/quic/handshake/TransportParameters.h index ad57a1bfb..71298fe5d 100644 --- a/quic/handshake/TransportParameters.h +++ b/quic/handshake/TransportParameters.h @@ -126,15 +126,15 @@ inline auto findParameter( }); } -folly::Optional getIntegerParameter( +Optional getIntegerParameter( TransportParameterId id, const std::vector& parameters); -folly::Optional getConnIdParameter( +Optional getConnIdParameter( TransportParameterId id, const std::vector& parameters); -folly::Optional getStatelessResetTokenParameter( +Optional getStatelessResetTokenParameter( const std::vector& parameters); TransportParameter encodeIntegerParameter( diff --git a/quic/handshake/test/Mocks.h b/quic/handshake/test/Mocks.h index 7886cc1c1..534e6251b 100644 --- a/quic/handshake/test/Mocks.h +++ b/quic/handshake/test/Mocks.h @@ -43,7 +43,7 @@ class MockAead : public Aead { public: MOCK_METHOD(size_t, getCipherOverhead, (), (const)); - MOCK_METHOD(folly::Optional, getKey, (), (const)); + MOCK_METHOD(Optional, getKey, (), (const)); MOCK_METHOD( std::unique_ptr, _inplaceEncrypt, @@ -73,13 +73,13 @@ class MockAead : public Aead { } MOCK_METHOD( - folly::Optional>, + Optional>, _tryDecrypt, (std::unique_ptr & ciphertext, const folly::IOBuf* associatedData, uint64_t seqNum), (const)); - folly::Optional> tryDecrypt( + Optional> tryDecrypt( std::unique_ptr&& ciphertext, const folly::IOBuf* associatedData, uint64_t seqNum) const override { diff --git a/quic/happyeyeballs/QuicHappyEyeballsFunctions.cpp b/quic/happyeyeballs/QuicHappyEyeballsFunctions.cpp index 97971fc7c..7233eebdf 100644 --- a/quic/happyeyeballs/QuicHappyEyeballsFunctions.cpp +++ b/quic/happyeyeballs/QuicHappyEyeballsFunctions.cpp @@ -123,7 +123,7 @@ void startHappyEyeballs( void happyEyeballsSetUpSocket( QuicAsyncUDPSocket& socket, - folly::Optional localAddress, + Optional localAddress, const folly::SocketAddress& peerAddress, const TransportSettings& transportSettings, const uint8_t socketTos, diff --git a/quic/happyeyeballs/QuicHappyEyeballsFunctions.h b/quic/happyeyeballs/QuicHappyEyeballsFunctions.h index e722c5203..2da807a70 100644 --- a/quic/happyeyeballs/QuicHappyEyeballsFunctions.h +++ b/quic/happyeyeballs/QuicHappyEyeballsFunctions.h @@ -45,7 +45,7 @@ void startHappyEyeballs( void happyEyeballsSetUpSocket( QuicAsyncUDPSocket& socket, - folly::Optional localAddress, + Optional localAddress, const folly::SocketAddress& peerAddress, const TransportSettings& transportSettings, const uint8_t socketTos, diff --git a/quic/logging/FileQLogger.cpp b/quic/logging/FileQLogger.cpp index 055ce5820..f41349f6f 100644 --- a/quic/logging/FileQLogger.cpp +++ b/quic/logging/FileQLogger.cpp @@ -13,7 +13,7 @@ namespace quic { -void FileQLogger::setDcid(folly::Optional connID) { +void FileQLogger::setDcid(Optional connID) { if (connID.hasValue()) { dcid = connID.value(); if (streaming_) { @@ -21,7 +21,7 @@ void FileQLogger::setDcid(folly::Optional connID) { } } } -void FileQLogger::setScid(folly::Optional connID) { +void FileQLogger::setScid(Optional connID) { if (connID.hasValue()) { scid = connID.value(); } @@ -463,7 +463,7 @@ folly::dynamic FileQLogger::generateSummary( void FileQLogger::addStreamStateUpdate( quic::StreamId id, std::string update, - folly::Optional timeSinceStreamCreation) { + Optional timeSinceStreamCreation) { auto refTime = std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()); diff --git a/quic/logging/FileQLogger.h b/quic/logging/FileQLogger.h index 558f9c371..c00d00d80 100644 --- a/quic/logging/FileQLogger.h +++ b/quic/logging/FileQLogger.h @@ -104,8 +104,7 @@ class FileQLogger : public BaseQLogger { void addStreamStateUpdate( StreamId id, std::string update, - folly::Optional timeSinceStreamCreation) - override; + Optional timeSinceStreamCreation) override; virtual void addConnectionMigrationUpdate(bool intentionalMigration) override; virtual void addPathValidationEvent(bool success) override; void addPriorityUpdate( @@ -123,8 +122,8 @@ class FileQLogger : public BaseQLogger { std::chrono::microseconds startTime, std::chrono::microseconds endTime) const; - void setDcid(folly::Optional connID) override; - void setScid(folly::Optional connID) override; + void setDcid(Optional connID) override; + void setScid(Optional connID) override; private: void setupStream(); diff --git a/quic/logging/QLogger.h b/quic/logging/QLogger.h index 644ebf55f..9ba88d750 100644 --- a/quic/logging/QLogger.h +++ b/quic/logging/QLogger.h @@ -27,8 +27,8 @@ class QLogger { explicit QLogger(VantagePoint vantagePointIn, std::string protocolTypeIn) : vantagePoint(vantagePointIn), protocolType(std::move(protocolTypeIn)) {} - folly::Optional dcid; - folly::Optional scid; + Optional dcid; + Optional scid; VantagePoint vantagePoint; std::string protocolType; QLogger() = delete; @@ -115,7 +115,7 @@ class QLogger { virtual void addStreamStateUpdate( quic::StreamId streamId, std::string update, - folly::Optional timeSinceStreamCreation) = 0; + Optional timeSinceStreamCreation) = 0; virtual void addConnectionMigrationUpdate(bool intentionalMigration) = 0; virtual void addPathValidationEvent(bool success) = 0; virtual void addPriorityUpdate( @@ -125,8 +125,8 @@ class QLogger { virtual void addL4sWeightUpdate(double l4sWeight, uint32_t newEct1, uint32_t newCe) = 0; - virtual void setDcid(folly::Optional connID) = 0; - virtual void setScid(folly::Optional connID) = 0; + virtual void setDcid(Optional connID) = 0; + virtual void setScid(Optional connID) = 0; }; std::string getFlowControlEvent(int offset); diff --git a/quic/logging/QLoggerTypes.cpp b/quic/logging/QLoggerTypes.cpp index ba692ae1b..afcef421d 100644 --- a/quic/logging/QLoggerTypes.cpp +++ b/quic/logging/QLoggerTypes.cpp @@ -845,7 +845,7 @@ folly::dynamic QLogMetricUpdateEvent::toDynamic() const { QLogStreamStateUpdateEvent::QLogStreamStateUpdateEvent( StreamId idIn, std::string updateIn, - folly::Optional timeSinceStreamCreationIn, + Optional timeSinceStreamCreationIn, VantagePoint vantagePoint, std::chrono::microseconds refTimeIn) : id{idIn}, diff --git a/quic/logging/QLoggerTypes.h b/quic/logging/QLoggerTypes.h index 440caf255..aadd02913 100644 --- a/quic/logging/QLoggerTypes.h +++ b/quic/logging/QLoggerTypes.h @@ -194,8 +194,8 @@ class ReadAckFrameLog : public QLogFrame { ReadAckFrame::Vec ackBlocks; std::chrono::microseconds ackDelay; FrameType frameType; - folly::Optional maybeLatestRecvdPacketTime; - folly::Optional maybeLatestRecvdPacketNum; + Optional maybeLatestRecvdPacketTime; + Optional maybeLatestRecvdPacketNum; RecvdPacketsTimestampsRangeVec recvdPacketsTimestampRanges; uint32_t ecnECT0Count; uint32_t ecnECT1Count; @@ -205,9 +205,8 @@ class ReadAckFrameLog : public QLogFrame { const ReadAckFrame::Vec& ackBlocksIn, std::chrono::microseconds ackDelayIn, FrameType frameTypeIn = FrameType::ACK, - folly::Optional maybeLatestRecvdPacketTimeIn = - folly::none, - folly::Optional maybeLatestRecvdPacketNumIn = folly::none, + Optional maybeLatestRecvdPacketTimeIn = none, + Optional maybeLatestRecvdPacketNumIn = none, RecvdPacketsTimestampsRangeVec recvdPacketsTimestampRangesIn = {}, uint32_t ecnECT0CountIn = 0, uint32_t ecnECT1CountIn = 0, @@ -230,8 +229,8 @@ class WriteAckFrameLog : public QLogFrame { WriteAckFrame::AckBlockVec ackBlocks; std::chrono::microseconds ackDelay; FrameType frameType; - folly::Optional maybeLatestRecvdPacketTime; - folly::Optional maybeLatestRecvdPacketNum; + Optional maybeLatestRecvdPacketTime; + Optional maybeLatestRecvdPacketNum; RecvdPacketsTimestampsRangeVec recvdPacketsTimestampRanges; uint32_t ecnECT0Count; uint32_t ecnECT1Count; @@ -241,9 +240,8 @@ class WriteAckFrameLog : public QLogFrame { const WriteAckFrame::AckBlockVec& ackBlocksIn, std::chrono::microseconds ackDelayIn, FrameType frameTypeIn = FrameType::ACK, - folly::Optional maybeLatestRecvdPacketTimeIn = - folly::none, - folly::Optional maybeLatestRecvdPacketNumIn = folly::none, + Optional maybeLatestRecvdPacketTimeIn = none, + Optional maybeLatestRecvdPacketNumIn = none, RecvdPacketsTimestampsRangeVec recvdPacketsTimestampRangesIn = {}, uint32_t ecnECT0CountIn = 0, uint32_t ecnECT1CountIn = 0, @@ -703,13 +701,13 @@ class QLogStreamStateUpdateEvent : public QLogEvent { QLogStreamStateUpdateEvent( StreamId id, std::string update, - folly::Optional timeSinceStreamCreation, + Optional timeSinceStreamCreation, VantagePoint vantagePoint, std::chrono::microseconds refTime); ~QLogStreamStateUpdateEvent() override = default; StreamId id; std::string update; - folly::Optional timeSinceStreamCreation; + Optional timeSinceStreamCreation; FOLLY_NODISCARD folly::dynamic toDynamic() const override; private: diff --git a/quic/logging/test/Mocks.h b/quic/logging/test/Mocks.h index 151a905e9..f2eb3c7f9 100644 --- a/quic/logging/test/Mocks.h +++ b/quic/logging/test/Mocks.h @@ -54,9 +54,7 @@ class MockQLogger : public QLogger { MOCK_METHOD( void, addStreamStateUpdate, - (quic::StreamId, - std::string, - folly::Optional)); + (quic::StreamId, std::string, Optional)); MOCK_METHOD( void, addBandwidthEstUpdate, @@ -65,8 +63,8 @@ class MockQLogger : public QLogger { MOCK_METHOD(void, addAppUnlimitedUpdate, ()); MOCK_METHOD(void, addConnectionMigrationUpdate, (bool)); MOCK_METHOD(void, addPathValidationEvent, (bool)); - MOCK_METHOD(void, setDcid, (folly::Optional)); - MOCK_METHOD(void, setScid, (folly::Optional)); + MOCK_METHOD(void, setDcid, (Optional)); + MOCK_METHOD(void, setScid, (Optional)); MOCK_METHOD(void, addPriorityUpdate, (quic::StreamId, uint8_t, bool)); MOCK_METHOD( void, diff --git a/quic/logging/test/QLoggerTest.cpp b/quic/logging/test/QLoggerTest.cpp index 7cf2f4de5..b4d55542c 100644 --- a/quic/logging/test/QLoggerTest.cpp +++ b/quic/logging/test/QLoggerTest.cpp @@ -640,9 +640,9 @@ TEST_F(QLoggerTest, AddingMultiplePacketEvents) { *buf, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none /* longHeaderOverride */, + none /* longHeaderOverride */, fin, - folly::none /* shortHeaderOverride */, + none /* shortHeaderOverride */, offset); auto regularQuicPacket = packet.packet; @@ -1180,7 +1180,7 @@ TEST_F( ])"); FileQLogger q(VantagePoint::Client); - q.addStreamStateUpdate(streamId, kOnEOM, folly::none); + q.addStreamStateUpdate(streamId, kOnEOM, none); folly::dynamic gotDynamic = q.toDynamic(); gotDynamic["traces"][0]["events"][0][0] = "0"; // hardcode reference time folly::dynamic gotEvents = gotDynamic["traces"][0]["events"]; diff --git a/quic/loss/BUCK b/quic/loss/BUCK index faf35676e..108f08732 100644 --- a/quic/loss/BUCK +++ b/quic/loss/BUCK @@ -16,9 +16,9 @@ mvfst_cpp_library( ], exported_deps = [ "//folly:chrono", - "//folly:optional", "//quic:constants", "//quic/codec:types", + "//quic/common:optional", "//quic/common:time_util", "//quic/congestion_control:congestion_controller", "//quic/flowcontrol:flow_control", diff --git a/quic/loss/QuicLossFunctions.cpp b/quic/loss/QuicLossFunctions.cpp index faa70304d..49ce0d75e 100644 --- a/quic/loss/QuicLossFunctions.cpp +++ b/quic/loss/QuicLossFunctions.cpp @@ -20,7 +20,7 @@ std::chrono::microseconds calculatePTO(const QuicConnectionStateBase& conn) { } bool isPersistentCongestion( - folly::Optional pto, + Optional pto, TimePoint lostPeriodStart, TimePoint lostPeriodEnd, const CongestionController::AckEvent& ack) noexcept { @@ -273,13 +273,13 @@ bool processOutstandingsForLoss( PacketNum largestAcked, const PacketNumberSpace& pnSpace, const InlineMap& largestDsrAckedSequenceNumber, - const folly::Optional& largestNonDsrAckedSequenceNumber, + const Optional& largestNonDsrAckedSequenceNumber, const TimePoint& lossTime, const std::chrono::microseconds& rttSample, const LossVisitor& lossVisitor, std::chrono::microseconds& delayUntilLost, CongestionController::LossEvent& lossEvent, - folly::Optional& observerLossEvent) { + Optional& observerLossEvent) { bool shouldSetTimer = false; auto iter = getFirstOutstandingPacket(conn, pnSpace); while (iter != conn.outstandings.packets.end()) { @@ -290,7 +290,7 @@ bool processOutstandingsForLoss( auto& pkt = *iter; auto currentPacketNum = pkt.packet.header.getPacketSequenceNum(); - folly::Optional maybeCurrentStreamPacketIdx; + Optional maybeCurrentStreamPacketIdx; if (currentPacketNum >= largestAcked) { break; } @@ -404,7 +404,7 @@ bool processOutstandingsForLoss( * This function should be invoked after some event that is possible to * trigger loss detection, for example: packets are acked */ -folly::Optional detectLossPackets( +Optional detectLossPackets( QuicConnectionStateBase& conn, const AckState& ackState, const LossVisitor& lossVisitor, @@ -422,7 +422,7 @@ folly::Optional detectLossPackets( << " delayUntilLost=" << delayUntilLost.count() << "us" << " " << conn; CongestionController::LossEvent lossEvent(lossTime); - folly::Optional observerLossEvent; + Optional observerLossEvent; { const auto socketObserverContainer = conn.getSocketObserverContainer(); if (socketObserverContainer && @@ -441,7 +441,7 @@ folly::Optional detectLossPackets( // These two variables hold DSR and non-DSR sequence numbers not actual packet // numbers InlineMap largestDsrAckedSeqNo; - folly::Optional largestNonDsrAckedSeqNo; + Optional largestNonDsrAckedSeqNo; if (ackEvent) { for (const auto& ackPacket : ackEvent->ackedPackets) { for (auto& [stream, details] : ackPacket.detailsPerStream) { @@ -535,10 +535,10 @@ folly::Optional detectLossPackets( return lossEvent; } } - return folly::none; + return none; } -folly::Optional handleAckForLoss( +Optional handleAckForLoss( QuicConnectionStateBase& conn, const LossVisitor& lossVisitor, CongestionController::AckEvent& ack, diff --git a/quic/loss/QuicLossFunctions.h b/quic/loss/QuicLossFunctions.h index 3f722c8d6..60f7cf3d4 100644 --- a/quic/loss/QuicLossFunctions.h +++ b/quic/loss/QuicLossFunctions.h @@ -8,9 +8,9 @@ #pragma once #include -#include #include #include +#include #include #include #include @@ -37,7 +37,7 @@ std::chrono::microseconds calculatePTO(const QuicConnectionStateBase& conn); * */ bool isPersistentCongestion( - folly::Optional pto, + Optional pto, TimePoint lostPeriodStart, TimePoint lostPeriodEnd, const CongestionController::AckEvent& ack) noexcept; @@ -60,7 +60,7 @@ template std::pair calculateAlarmDuration(const QuicConnectionStateBase& conn) { std::chrono::microseconds alarmDuration; - folly::Optional alarmMethod; + Optional alarmMethod; TimePoint lastSentPacketTime = conn.lossState.lastRetransmittablePacketSentTime; auto lossTimeAndSpace = earliestLossTimer(conn); @@ -191,19 +191,19 @@ bool processOutstandingsForLoss( PacketNum largestAcked, const PacketNumberSpace& pnSpace, const InlineMap& largestDsrAckedSequenceNumber, - const folly::Optional& largestNonDsrAckedSequenceNumber, + const Optional& largestNonDsrAckedSequenceNumber, const TimePoint& lossTime, const std::chrono::microseconds& rttSample, const LossVisitor& lossVisitor, std::chrono::microseconds& delayUntilLost, CongestionController::LossEvent& lossEvent, - folly::Optional& observerLossEvent); + Optional& observerLossEvent); /* * This function should be invoked after some event that is possible to * trigger loss detection, for example: packets are acked */ -folly::Optional detectLossPackets( +Optional detectLossPackets( QuicConnectionStateBase& conn, const AckState& ackState, const LossVisitor& lossVisitor, @@ -265,7 +265,7 @@ void markPacketLoss( RegularQuicWritePacket& packet, bool processed); -folly::Optional handleAckForLoss( +Optional handleAckForLoss( QuicConnectionStateBase& conn, const LossVisitor& lossVisitor, CongestionController::AckEvent& ack, diff --git a/quic/loss/test/QuicLossFunctionsTest.cpp b/quic/loss/test/QuicLossFunctionsTest.cpp index a9ae87c6d..bbc756aac 100644 --- a/quic/loss/test/QuicLossFunctionsTest.cpp +++ b/quic/loss/test/QuicLossFunctionsTest.cpp @@ -45,14 +45,14 @@ auto getOutstandingPacketMatcher( testing::Field( &quic::OutstandingPacketMetadata::lossReorderDistance, testing::Property( - &folly::Optional::hasValue, + &quic::Optional::hasValue, testing::Eq(lostByReorder)))), testing::Field( &quic::OutstandingPacketWrapper::metadata, testing::Field( &quic::OutstandingPacketMetadata::lossTimeoutDividend, testing::Property( - &folly::Optional::hasValue, + &quic::Optional::hasValue, testing::Eq(lostByTimeout)))), testing::Field( &quic::OutstandingPacketWrapper::packet, @@ -95,9 +95,9 @@ class QuicLossFunctionsTest : public TestWithParam { PacketNum sendPacket( QuicConnectionStateBase& conn, TimePoint time, - folly::Optional associatedEvent, + Optional associatedEvent, PacketType packetType, - folly::Optional forcedSize = folly::none, + Optional forcedSize = none, bool isDsr = false); std::unique_ptr createConn() { @@ -189,11 +189,11 @@ auto testingLossMarkFunc(std::vector& lostPackets) { PacketNum QuicLossFunctionsTest::sendPacket( QuicConnectionStateBase& conn, TimePoint time, - folly::Optional associatedEvent, + Optional associatedEvent, PacketType packetType, - folly::Optional forcedSize, + Optional forcedSize, bool isDsr) { - folly::Optional header; + Optional header; switch (packetType) { case PacketType::Initial: header = LongHeader( @@ -338,7 +338,7 @@ TEST_F(QuicLossFunctionsTest, AllPacketsProcessed) { TEST_F(QuicLossFunctionsTest, HasDataToWrite) { auto conn = createConn(); // There needs to be at least one outstanding packet. - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); conn->streamManager->addLoss(1); conn->pendingEvents.setLossDetectionAlarm = true; EXPECT_CALL(timeout, cancelLossTimeout()).Times(2); @@ -354,9 +354,9 @@ TEST_F(QuicLossFunctionsTest, ClearEarlyRetranTimer) { conn->lossState.lrtt = 1s; auto currentTime = Clock::now(); auto firstPacketNum = - sendPacket(*conn, currentTime, folly::none, PacketType::Initial); + sendPacket(*conn, currentTime, none, PacketType::Initial); auto secondPacketNum = - sendPacket(*conn, currentTime, folly::none, PacketType::Initial); + sendPacket(*conn, currentTime, none, PacketType::Initial); ASSERT_GT(secondPacketNum, firstPacketNum); ASSERT_EQ(2, conn->outstandings.packets.size()); // detectLossPackets will set lossTime on Initial space. @@ -396,7 +396,7 @@ TEST_F(QuicLossFunctionsTest, ClearEarlyRetranTimer) { Clock::now()); // Send out a AppData packet that isn't retransmittable - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); conn->pendingEvents.setLossDetectionAlarm = false; // setLossDetectionAlarm will cancel loss timer, and not schedule another one. @@ -416,7 +416,7 @@ TEST_F(QuicLossFunctionsTest, TestOnLossDetectionAlarm) { EXPECT_CALL(*rawCongestionController, onPacketSent(_)) .WillRepeatedly(Return()); - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); MockClock::mockNow = []() { return TimePoint(123ms); }; std::vector lostPacket; MockClock::mockNow = []() { return TimePoint(23ms); }; @@ -431,7 +431,7 @@ TEST_F(QuicLossFunctionsTest, TestOnLossDetectionAlarm) { MockClock::mockNow = []() { return TimePoint(3ms); }; EXPECT_CALL(*quicStats_, onPTO()); - sendPacket(*conn, TimePoint(), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(), none, PacketType::OneRtt); setLossDetectionAlarm(*conn, timeout); EXPECT_CALL(*rawCongestionController, onPacketAckOrLoss(_, _)).Times(0); onLossDetectionAlarm(*conn, testingLossMarkFunc(lostPacket)); @@ -722,7 +722,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThreshold) { lostPacket.push_back(packetNum); }; for (int i = 0; i < 6; ++i) { - sendPacket(*conn, Clock::now(), folly::none, PacketType::Handshake); + sendPacket(*conn, Clock::now(), none, PacketType::Handshake); } EXPECT_EQ(6, conn->outstandings.packetCount[PacketNumberSpace::Handshake]); // Assume some packets are already acked @@ -831,7 +831,7 @@ TEST_F(QuicLossFunctionsTest, TestHandleAckedPacket) { conn->lossState.ptoCount = 10; conn->lossState.reorderingThreshold = 10; - sendPacket(*conn, TimePoint(), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(), none, PacketType::OneRtt); ReadAckFrame ackFrame; ackFrame.largestAcked = conn->lossState.largestSent.value_or(0); @@ -939,8 +939,7 @@ TEST_F(QuicLossFunctionsTest, ReorderingThresholdChecksSamePacketNumberSpace) { }; PacketNum latestSent = 0; for (size_t i = 0; i < conn->lossState.reorderingThreshold + 1; i++) { - latestSent = - sendPacket(*conn, Clock::now(), folly::none, PacketType::Handshake); + latestSent = sendPacket(*conn, Clock::now(), none, PacketType::Handshake); } auto& ackState = getAckState(*conn, PacketNumberSpace::AppData); @@ -1002,8 +1001,8 @@ TEST_F(QuicLossFunctionsTest, TestTimeReordering) { PacketNum largestSent = 0; for (int i = 0; i < 7; ++i) { - largestSent = sendPacket( - *conn, TimePoint(i * 100ms), folly::none, PacketType::OneRtt); + largestSent = + sendPacket(*conn, TimePoint(i * 100ms), none, PacketType::OneRtt); } // Some packets are already acked conn->lossState.srtt = 400ms; @@ -1050,9 +1049,9 @@ TEST_F(QuicLossFunctionsTest, LossTimePreemptsCryptoTimer) { 500ms / conn->transportSettings.timeReorderingThreshDivisor; auto sendTime = Clock::now(); // Send two: - sendPacket(*conn, sendTime, folly::none, PacketType::Handshake); + sendPacket(*conn, sendTime, none, PacketType::Handshake); PacketNum second = - sendPacket(*conn, sendTime + 1ms, folly::none, PacketType::Handshake); + sendPacket(*conn, sendTime + 1ms, none, PacketType::Handshake); auto lossTime = sendTime + 50ms; auto& ackState = getAckState(*conn, PacketNumberSpace::Handshake); @@ -1108,7 +1107,7 @@ TEST_F(QuicLossFunctionsTest, PTONoLongerMarksPacketsToBeRetransmitted) { MockClock::mockNow = [&]() { return startTime; }; std::vector lostPackets; for (auto i = 0; i < kPacketToSendForPTO + 10; i++) { - sendPacket(*conn, startTime, folly::none, PacketType::OneRtt); + sendPacket(*conn, startTime, none, PacketType::OneRtt); setLossDetectionAlarm(*conn, timeout); startTime += 1ms; } @@ -1140,7 +1139,7 @@ TEST_F(QuicLossFunctionsTest, PTOWithHandshakePackets) { auto sentPacketNum = sendPacket( *conn, TimePoint(100ms), - folly::none, + none, (i % 2 ? PacketType::OneRtt : PacketType::Handshake)); expectedLargestLostNum = std::max( expectedLargestLostNum, i % 2 ? sentPacketNum : expectedLargestLostNum); @@ -1295,7 +1294,7 @@ TEST_F(QuicLossFunctionsTest, AlarmDurationHasLossTime) { conn->lossState.srtt = 200ms; conn->lossState.lrtt = 150ms; - sendPacket(*conn, lastPacketSentTime, folly::none, PacketType::OneRtt); + sendPacket(*conn, lastPacketSentTime, none, PacketType::OneRtt); auto duration = calculateAlarmDuration(*conn); EXPECT_EQ(100ms, duration.first); EXPECT_EQ( @@ -1314,7 +1313,7 @@ TEST_F(QuicLossFunctionsTest, AlarmDurationLossTimeIsZero) { conn->lossState.srtt = 200ms; conn->lossState.lrtt = 150ms; - sendPacket(*conn, lastPacketSentTime, folly::none, PacketType::OneRtt); + sendPacket(*conn, lastPacketSentTime, none, PacketType::OneRtt); auto duration = calculateAlarmDuration(*conn); EXPECT_EQ(0ms, duration.first); EXPECT_EQ( @@ -1328,7 +1327,7 @@ TEST_F(QuicLossFunctionsTest, AlarmDurationNonHandshakeOutstanding) { conn->lossState.maxAckDelay = 25ms; TimePoint lastPacketSentTime = Clock::now(); MockClock::mockNow = [=]() { return lastPacketSentTime; }; - sendPacket(*conn, lastPacketSentTime, folly::none, PacketType::OneRtt); + sendPacket(*conn, lastPacketSentTime, none, PacketType::OneRtt); auto duration = calculateAlarmDuration(*conn); EXPECT_EQ(duration.second, LossState::AlarmMethod::PTO); setLossDetectionAlarm(*conn, timeout); @@ -1355,7 +1354,7 @@ TEST_F(QuicLossFunctionsTest, NoSkipLossVisitor) { // Send 5 packets, so when we ack the last one, we mark the first one loss PacketNum lastSent; for (size_t i = 0; i < 5; i++) { - lastSent = sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + lastSent = sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); } auto& ackState = getAckState(*conn, PacketNumberSpace::AppData); @@ -1418,7 +1417,7 @@ TEST_F(QuicLossFunctionsTest, NoDoubleProcess) { // Send 6 packets, so when we ack the last one, we mark the first two loss EXPECT_EQ(1, conn->ackStates.appDataAckState.nextPacketNum); PacketNum lastSent; - lastSent = sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + lastSent = sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); EXPECT_EQ(1, conn->outstandings.packetCount[PacketNumberSpace::AppData]); PacketEvent event(PacketNumberSpace::AppData, lastSent); for (size_t i = 0; i < 6; i++) { @@ -1455,11 +1454,10 @@ TEST_F(QuicLossFunctionsTest, DetectPacketLossClonedPacketsCounter) { PacketNumberSpace::AppData, conn->ackStates.appDataAckState.nextPacketNum); sendPacket(*conn, Clock::now(), packetEvent1, PacketType::OneRtt); - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); - auto ackedPacket = - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); + auto ackedPacket = sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); auto noopLossMarker = [](auto&, auto&, bool) {}; auto& ackState = getAckState(*conn, PacketNumberSpace::AppData); @@ -1565,8 +1563,7 @@ TEST_F(QuicLossFunctionsTest, TotalLossCount) { conn->congestionController = nullptr; PacketNum largestSent = 0; for (int i = 0; i < 10; i++) { - largestSent = - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + largestSent = sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); } EXPECT_EQ(10, conn->outstandings.packets.size()); uint32_t lostPackets = 0; @@ -1601,8 +1598,8 @@ TEST_F(QuicLossFunctionsTest, TestZeroRttRejected) { // By adding an associatedEvent that doesn't exist in the // outstandings.packetEvents, they are all processed and will skip lossVisitor for (auto i = 0; i < 2; i++) { - sendPacket(*conn, TimePoint(), folly::none, PacketType::OneRtt); - sendPacket(*conn, TimePoint(), folly::none, PacketType::ZeroRtt); + sendPacket(*conn, TimePoint(), none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(), none, PacketType::ZeroRtt); } EXPECT_FALSE(conn->outstandings.packets.empty()); EXPECT_EQ(4, conn->outstandings.packets.size()); @@ -1636,7 +1633,7 @@ TEST_F(QuicLossFunctionsTest, TestZeroRttRejectedWithClones) { // By adding an associatedEvent that doesn't exist in the // outstandings.packetEvents, they are all processed and will skip lossVisitor std::set zeroRttPackets; - folly::Optional lastPacketEvent; + Optional lastPacketEvent; for (auto i = 0; i < 2; i++) { auto packetNum = sendPacket(*conn, TimePoint(), lastPacketEvent, PacketType::ZeroRtt); @@ -1644,7 +1641,7 @@ TEST_F(QuicLossFunctionsTest, TestZeroRttRejectedWithClones) { zeroRttPackets.emplace(packetNum); } zeroRttPackets.emplace( - sendPacket(*conn, TimePoint(), folly::none, PacketType::ZeroRtt)); + sendPacket(*conn, TimePoint(), none, PacketType::ZeroRtt)); for (auto zeroRttPacketNum : zeroRttPackets) { PacketEvent zeroRttPacketEvent( PacketNumberSpace::AppData, zeroRttPacketNum); @@ -1697,11 +1694,11 @@ TEST_F(QuicLossFunctionsTest, TimeThreshold) { conn->lossState.srtt = 10ms; auto referenceTime = Clock::now(); auto packet1 = - sendPacket(*conn, referenceTime - 10ms, folly::none, PacketType::OneRtt); + sendPacket(*conn, referenceTime - 10ms, none, PacketType::OneRtt); auto packet2 = sendPacket( *conn, referenceTime + conn->lossState.srtt / 2, - folly::none, + none, PacketType::OneRtt); auto lossVisitor = [&](const auto& /*conn*/, const auto& packet, bool) { EXPECT_EQ(packet1, packet.header.getPacketSequenceNum()); @@ -1724,8 +1721,7 @@ TEST_F(QuicLossFunctionsTest, OutstandingInitialCounting) { conn->lossState.srtt = 100s; PacketNum largestSent = 0; while (largestSent < 10) { - largestSent = - sendPacket(*conn, Clock::now(), folly::none, PacketType::Initial); + largestSent = sendPacket(*conn, Clock::now(), none, PacketType::Initial); } EXPECT_EQ(10, conn->outstandings.packetCount[PacketNumberSpace::Initial]); auto noopLossVisitor = @@ -1751,8 +1747,7 @@ TEST_F(QuicLossFunctionsTest, OutstandingHandshakeCounting) { conn->lossState.srtt = 100s; PacketNum largestSent = 0; while (largestSent < 10) { - largestSent = - sendPacket(*conn, Clock::now(), folly::none, PacketType::Handshake); + largestSent = sendPacket(*conn, Clock::now(), none, PacketType::Handshake); } EXPECT_EQ(10, conn->outstandings.packetCount[PacketNumberSpace::Handshake]); auto noopLossVisitor = @@ -1776,7 +1771,7 @@ TEST_P(QuicLossFunctionsTest, CappedShiftNoCrash) { conn->outstandings.reset(); conn->lossState.ptoCount = std::numeric_limitslossState.ptoCount)>::max(); - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); calculateAlarmDuration(*conn); } @@ -1923,8 +1918,8 @@ TEST_F(QuicLossFunctionsTest, PersistentCongestionNoPTO) { .setDetailsPerStream(AckEvent::AckPacket::DetailsPerStream()) .build()); - EXPECT_FALSE(isPersistentCongestion( - folly::none, currentTime + 1s, currentTime + 8s, ack)); + EXPECT_FALSE( + isPersistentCongestion(none, currentTime + 1s, currentTime + 8s, ack)); } TEST_F(QuicLossFunctionsTest, ObserverLossEventReorder) { @@ -1939,7 +1934,7 @@ TEST_F(QuicLossFunctionsTest, ObserverLossEventReorder) { PacketNum largestSent = 0; for (int i = 0; i < 7; ++i) { largestSent = - sendPacket(*conn, TimePoint(i * 10ms), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(i * 10ms), none, PacketType::OneRtt); } // Some packets are already acked conn->outstandings.packets.erase( @@ -2023,7 +2018,7 @@ TEST_F(QuicLossFunctionsTest, ObserverLossEventTimeout) { PacketNum largestSent = 0; for (int i = 0; i < 7; ++i) { largestSent = - sendPacket(*conn, TimePoint(i * 10ms), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(i * 10ms), none, PacketType::OneRtt); } // setting a very high reordering threshold to force loss by timeout only @@ -2129,7 +2124,7 @@ TEST_F(QuicLossFunctionsTest, ObserverLossEventTimeoutAndReorder) { PacketNum largestSent = 0; for (int i = 0; i < 7; ++i) { largestSent = - sendPacket(*conn, TimePoint(i * 10ms), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(i * 10ms), none, PacketType::OneRtt); } // Some packets are already acked @@ -2215,7 +2210,7 @@ TEST_F(QuicLossFunctionsTest, TotalPacketsMarkedLostByReordering) { PacketNum largestSent = 0; for (int i = 0; i < 7; ++i) { largestSent = - sendPacket(*conn, TimePoint(i * 10ms), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(i * 10ms), none, PacketType::OneRtt); } // Some packets are already acked @@ -2255,7 +2250,7 @@ TEST_F(QuicLossFunctionsTest, TotalPacketsMarkedLostByTimeout) { PacketNum largestSent = 0; for (int i = 0; i < 7; ++i) { largestSent = - sendPacket(*conn, TimePoint(i * 10ms), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(i * 10ms), none, PacketType::OneRtt); } // setting a very high reordering threshold to force loss by timeout only @@ -2288,7 +2283,7 @@ TEST_F(QuicLossFunctionsTest, TotalPacketsMarkedLostByTimeoutPartial) { PacketNum largestSent = 0; for (int i = 0; i < 7; ++i) { largestSent = - sendPacket(*conn, TimePoint(i * 10ms), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(i * 10ms), none, PacketType::OneRtt); } // Some packets are already acked @@ -2327,7 +2322,7 @@ TEST_F(QuicLossFunctionsTest, TotalPacketsMarkedLostByTimeoutAndReordering) { PacketNum largestSent = 0; for (int i = 0; i < 7; ++i) { largestSent = - sendPacket(*conn, TimePoint(i * 10ms), folly::none, PacketType::OneRtt); + sendPacket(*conn, TimePoint(i * 10ms), none, PacketType::OneRtt); } // Some packets are already acked @@ -2526,13 +2521,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRNormal) { lostPacket.push_back(packetNum); }; for (int i = 0; i < 6; ++i) { - sendPacket( - *conn, - Clock::now(), - folly::none, - PacketType::OneRtt, - folly::none, - true); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt, none, true); } // Add some DSR frames for (auto& op : conn->outstandings.packets) { @@ -2543,7 +2532,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRNormal) { 100, false, true, - folly::none, + none, op.packet.header.getPacketSequenceNum()}); op.isDSRPacket = true; conn->outstandings.dsrCount++; @@ -2571,7 +2560,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRNormal) { .build(); AckEvent::AckPacket::DetailsPerStream detailsPerStream; detailsPerStream.recordFrameDelivered( - WriteStreamFrame{0, 10, 100, false, true, folly::none, 9}); + WriteStreamFrame{0, 10, 100, false, true, none, 9}); ack.ackedPackets.emplace_back( CongestionController::AckEvent::AckPacket::Builder() .setPacketNum(9) @@ -2627,13 +2616,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRNormalOverflow) { lostPacket.push_back(packetNum); }; for (int i = 0; i < 6; ++i) { - sendPacket( - *conn, - Clock::now(), - folly::none, - PacketType::OneRtt, - folly::none, - true); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt, none, true); } // Add some DSR frames for (auto& op : conn->outstandings.packets) { @@ -2709,13 +2692,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRIgnoreReorder) { lostPacket.push_back(packetNum); }; for (int i = 0; i < 6; ++i) { - sendPacket( - *conn, - Clock::now(), - folly::none, - PacketType::OneRtt, - folly::none, - true); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt, none, true); } // Add some DSR frames for (auto& op : conn->outstandings.packets) { @@ -2725,13 +2702,13 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRIgnoreReorder) { 100, false, true, - folly::none, + none, op.packet.header.getPacketSequenceNum()}); op.isDSRPacket = true; conn->outstandings.dsrCount++; } // Add another non-DSR after - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); EXPECT_EQ(7, conn->outstandings.packetCount[PacketNumberSpace::AppData]); // Assume some packets are already acked for (auto iter = @@ -2812,7 +2789,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdNonDSRIgnoreReorder) { lostPacket.push_back(packetNum); }; for (int i = 0; i < 6; ++i) { - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); } EXPECT_EQ(6, conn->outstandings.packetCount[PacketNumberSpace::AppData]); // Assume some packets are already acked @@ -2888,7 +2865,7 @@ TEST_F( lostPacket.push_back(packetNum); }; for (int i = 0; i < 6; ++i) { - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); } EXPECT_EQ(6, conn->outstandings.packetCount[PacketNumberSpace::AppData]); // Assume some packets are already acked @@ -2970,13 +2947,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRIgnoreReorderBurst) { lostPacket.push_back(packetNum); }; for (int i = 0; i < 4; ++i) { - sendPacket( - *conn, - Clock::now(), - folly::none, - PacketType::OneRtt, - folly::none, - true); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt, none, true); } // Add some DSR frames and build the ACK auto ack = AckEvent::Builder() @@ -2989,13 +2960,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRIgnoreReorderBurst) { .build(); for (auto& op : conn->outstandings.packets) { WriteStreamFrame f{ - 0, - 10, - 100, - false, - true, - folly::none, - op.packet.header.getPacketSequenceNum()}; + 0, 10, 100, false, true, none, op.packet.header.getPacketSequenceNum()}; AckEvent::AckPacket::DetailsPerStream detailsPerStream; if (op.packet.header.getPacketSequenceNum() != 4) { detailsPerStream.recordFrameDelivered(f); @@ -3013,13 +2978,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRIgnoreReorderBurst) { } // Add another non-DSR burst and ACK all of them for (int i = 0; i < 4; ++i) { - sendPacket( - *conn, - Clock::now(), - folly::none, - PacketType::OneRtt, - folly::none, - false); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt, none, false); auto& op = *getLastOutstandingPacket(*conn, PacketNumberSpace::AppData); ack.ackedPackets.emplace_back( CongestionController::AckEvent::AckPacket::Builder() @@ -3031,10 +2990,9 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdDSRIgnoreReorderBurst) { .build()); } // Add one more DSR packet from the same stream, ACKed - sendPacket( - *conn, Clock::now(), folly::none, PacketType::OneRtt, folly::none, true); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt, none, true); auto& op = *getLastOutstandingPacket(*conn, PacketNumberSpace::AppData); - WriteStreamFrame f{0, 10, 100, false, true, folly::none, 5}; + WriteStreamFrame f{0, 10, 100, false, true, none, 5}; AckEvent::AckPacket::DetailsPerStream detailsPerStream; detailsPerStream.recordFrameDelivered(f); op.packet.frames.emplace_back(f); @@ -3094,13 +3052,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdNonDSRIgnoreReorderBurst) { lostPacket.push_back(packetNum); }; for (int i = 0; i < 4; ++i) { - sendPacket( - *conn, - Clock::now(), - folly::none, - PacketType::OneRtt, - folly::none, - false); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt, none, false); } // Add some non-DSR frames and build the ACK auto ack = AckEvent::Builder() @@ -3112,7 +3064,7 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdNonDSRIgnoreReorderBurst) { .setAckDelay(0us) .build(); for (auto& op : conn->outstandings.packets) { - WriteStreamFrame f{0, 10, 100, false, false, folly::none, 0}; + WriteStreamFrame f{0, 10, 100, false, false, none, 0}; AckEvent::AckPacket::DetailsPerStream detailsPerStream; if (op.packet.header.getPacketSequenceNum() != 4) { detailsPerStream.recordFrameDelivered(f); @@ -3129,16 +3081,10 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdNonDSRIgnoreReorderBurst) { } // Add a DSR burst and ACK all of them for (int i = 0; i < 4; ++i) { - sendPacket( - *conn, - Clock::now(), - folly::none, - PacketType::OneRtt, - folly::none, - true); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt, none, true); auto& op = *getLastOutstandingPacket(*conn, PacketNumberSpace::AppData); WriteStreamFrame f{ - 4, 10, 100, false, true, folly::none, conn->outstandings.dsrCount++}; + 4, 10, 100, false, true, none, conn->outstandings.dsrCount++}; AckEvent::AckPacket::DetailsPerStream detailsPerStream; detailsPerStream.recordFrameDelivered(f); ack.ackedPackets.emplace_back( @@ -3152,9 +3098,9 @@ TEST_F(QuicLossFunctionsTest, TestReorderingThresholdNonDSRIgnoreReorderBurst) { op.isDSRPacket = true; } // Add one more non-DSR packet from the same stream, ACKed - sendPacket(*conn, Clock::now(), folly::none, PacketType::OneRtt); + sendPacket(*conn, Clock::now(), none, PacketType::OneRtt); auto& op = *getLastOutstandingPacket(*conn, PacketNumberSpace::AppData); - WriteStreamFrame f{0, 10, 100, false, false, folly::none, 0}; + WriteStreamFrame f{0, 10, 100, false, false, none, 0}; AckEvent::AckPacket::DetailsPerStream detailsPerStream; detailsPerStream.recordFrameDelivered(f); op.packet.frames.emplace_back(f); diff --git a/quic/observer/SocketObserverInterface.cpp b/quic/observer/SocketObserverInterface.cpp index 55c444fe1..61d82a5c1 100644 --- a/quic/observer/SocketObserverInterface.cpp +++ b/quic/observer/SocketObserverInterface.cpp @@ -34,21 +34,21 @@ SocketObserverInterface::WriteEvent::Builder::setLastPacketSentTime( SocketObserverInterface::WriteEvent::Builder&& SocketObserverInterface::WriteEvent::Builder::setLastPacketSentTime( - const folly::Optional& maybeLastPacketSentTimeIn) { + const Optional& maybeLastPacketSentTimeIn) { maybeLastPacketSentTime = maybeLastPacketSentTimeIn; return std::move(*this); } SocketObserverInterface::WriteEvent::Builder&& SocketObserverInterface::WriteEvent::Builder::setCwndInBytes( - const folly::Optional& maybeCwndInBytesIn) { + const Optional& maybeCwndInBytesIn) { maybeCwndInBytes = maybeCwndInBytesIn; return std::move(*this); } SocketObserverInterface::WriteEvent::Builder&& SocketObserverInterface::WriteEvent::Builder::setWritableBytes( - const folly::Optional& maybeWritableBytesIn) { + const Optional& maybeWritableBytesIn) { maybeWritableBytes = maybeWritableBytesIn; return std::move(*this); } @@ -90,21 +90,21 @@ SocketObserverInterface::AppLimitedEvent::Builder::setLastPacketSentTime( SocketObserverInterface::AppLimitedEvent::Builder&& SocketObserverInterface::AppLimitedEvent::Builder::setLastPacketSentTime( - const folly::Optional& maybeLastPacketSentTimeIn) { + const Optional& maybeLastPacketSentTimeIn) { maybeLastPacketSentTime = maybeLastPacketSentTimeIn; return std::move(*this); } SocketObserverInterface::AppLimitedEvent::Builder&& SocketObserverInterface::AppLimitedEvent::Builder::setCwndInBytes( - const folly::Optional& maybeCwndInBytesIn) { + const Optional& maybeCwndInBytesIn) { maybeCwndInBytes = maybeCwndInBytesIn; return std::move(*this); } SocketObserverInterface::AppLimitedEvent::Builder&& SocketObserverInterface::AppLimitedEvent::Builder::setWritableBytes( - const folly::Optional& maybeWritableBytesIn) { + const Optional& maybeWritableBytesIn) { maybeWritableBytes = maybeWritableBytesIn; return std::move(*this); } @@ -156,7 +156,7 @@ void SocketObserverInterface::PacketsWrittenEvent:: const auto startIt = outstandingPackets.end() - static_cast(numAckElicitingPacketsWritten); bool needFullWalk = false; - folly::Optional maybePrevNumAckElicitingPacketsSent; + Optional maybePrevNumAckElicitingPacketsSent; for (auto it = startIt; it != outstandingPackets.end(); it++) { if (writeCount != it->metadata.writeCount) { @@ -245,21 +245,21 @@ SocketObserverInterface::PacketsWrittenEvent::Builder::setLastPacketSentTime( SocketObserverInterface::PacketsWrittenEvent::Builder&& SocketObserverInterface::PacketsWrittenEvent::Builder::setLastPacketSentTime( - const folly::Optional& maybeLastPacketSentTimeIn) { + const Optional& maybeLastPacketSentTimeIn) { maybeLastPacketSentTime = maybeLastPacketSentTimeIn; return std::move(*this); } SocketObserverInterface::PacketsWrittenEvent::Builder&& SocketObserverInterface::PacketsWrittenEvent::Builder::setCwndInBytes( - const folly::Optional& maybeCwndInBytesIn) { + const Optional& maybeCwndInBytesIn) { maybeCwndInBytes = maybeCwndInBytesIn; return std::move(*this); } SocketObserverInterface::PacketsWrittenEvent::Builder&& SocketObserverInterface::PacketsWrittenEvent::Builder::setWritableBytes( - const folly::Optional& maybeWritableBytesIn) { + const Optional& maybeWritableBytesIn) { maybeWritableBytes = maybeWritableBytesIn; return std::move(*this); } diff --git a/quic/observer/SocketObserverInterface.h b/quic/observer/SocketObserverInterface.h index b08e93024..a5ed85f1f 100644 --- a/quic/observer/SocketObserverInterface.h +++ b/quic/observer/SocketObserverInterface.h @@ -52,7 +52,7 @@ class SocketObserverInterface { // // The presence of an error code does NOT indicate that a "problem" caused // the socket to close, since an error code can be an application timeout. - folly::Optional maybeCloseReason; + Optional maybeCloseReason; // Default equality comparator available in C++20. // @@ -98,26 +98,26 @@ class SocketObserverInterface { const uint64_t writeCount; // Timestamp when packet was last written. - const folly::Optional maybeLastPacketSentTime; + const Optional maybeLastPacketSentTime; // CWND in bytes. // // Optional to handle cases where congestion controller not used. - const folly::Optional maybeCwndInBytes; + const Optional maybeCwndInBytes; // Writable bytes. // // Optional to handle cases where congestion controller not used. - const folly::Optional maybeWritableBytes; + const Optional maybeWritableBytes; struct BuilderFields { - folly::Optional< + Optional< std::reference_wrapper>> maybeOutstandingPacketsRef; - folly::Optional maybeWriteCount; - folly::Optional maybeLastPacketSentTime; - folly::Optional maybeCwndInBytes; - folly::Optional maybeWritableBytes; + Optional maybeWriteCount; + Optional maybeLastPacketSentTime; + Optional maybeCwndInBytes; + Optional maybeWritableBytes; explicit BuilderFields() = default; }; @@ -127,11 +127,10 @@ class SocketObserverInterface { Builder&& setWriteCount(const uint64_t writeCountIn); Builder&& setLastPacketSentTime(const TimePoint& lastPacketSentTimeIn); Builder&& setLastPacketSentTime( - const folly::Optional& maybeLastPacketSentTimeIn); - Builder&& setCwndInBytes( - const folly::Optional& maybeCwndInBytesIn); + const Optional& maybeLastPacketSentTimeIn); + Builder&& setCwndInBytes(const Optional& maybeCwndInBytesIn); Builder&& setWritableBytes( - const folly::Optional& maybeWritableBytesIn); + const Optional& maybeWritableBytesIn); WriteEvent build() &&; explicit Builder() = default; }; @@ -157,11 +156,10 @@ class SocketObserverInterface { Builder&& setWriteCount(const uint64_t writeCountIn); Builder&& setLastPacketSentTime(const TimePoint& lastPacketSentTimeIn); Builder&& setLastPacketSentTime( - const folly::Optional& maybeLastPacketSentTimeIn); - Builder&& setCwndInBytes( - const folly::Optional& maybeCwndInBytesIn); + const Optional& maybeLastPacketSentTimeIn); + Builder&& setCwndInBytes(const Optional& maybeCwndInBytesIn); Builder&& setWritableBytes( - const folly::Optional& maybeWritableBytesIn); + const Optional& maybeWritableBytesIn); AppLimitedEvent build() &&; explicit Builder() = default; }; @@ -189,9 +187,9 @@ class SocketObserverInterface { const uint64_t numBytesWritten; struct BuilderFields : public WriteEvent::BuilderFields { - folly::Optional maybeNumPacketsWritten; - folly::Optional maybeNumAckElicitingPacketsWritten; - folly::Optional maybeNumBytesWritten; + Optional maybeNumPacketsWritten; + Optional maybeNumAckElicitingPacketsWritten; + Optional maybeNumBytesWritten; explicit BuilderFields() = default; }; @@ -201,15 +199,14 @@ class SocketObserverInterface { Builder&& setWriteCount(const uint64_t writeCountIn); Builder&& setLastPacketSentTime(const TimePoint& lastPacketSentTimeIn); Builder&& setLastPacketSentTime( - const folly::Optional& maybeLastPacketSentTimeIn); + const Optional& maybeLastPacketSentTimeIn); Builder&& setNumPacketsWritten(const uint64_t numPacketsWrittenIn); Builder&& setNumAckElicitingPacketsWritten( const uint64_t numAckElicitingPacketsWrittenIn); Builder&& setNumBytesWritten(const uint64_t numBytesWrittenIn); - Builder&& setCwndInBytes( - const folly::Optional& maybeCwndInBytesIn); + Builder&& setCwndInBytes(const Optional& maybeCwndInBytesIn); Builder&& setWritableBytes( - const folly::Optional& maybeWritableBytesIn); + const Optional& maybeWritableBytesIn); PacketsWrittenEvent build() &&; explicit Builder() = default; }; @@ -237,9 +234,9 @@ class SocketObserverInterface { const uint8_t packetTos; struct BuilderFields { - folly::Optional maybePacketReceiveTime; - folly::Optional maybePacketNumBytes; - folly::Optional maybePacketTos; + Optional maybePacketReceiveTime; + Optional maybePacketNumBytes; + Optional maybePacketTos; explicit BuilderFields() = default; }; @@ -268,9 +265,9 @@ class SocketObserverInterface { std::vector receivedPackets; struct BuilderFields { - folly::Optional maybeReceiveLoopTime; - folly::Optional maybeNumPacketsReceived; - folly::Optional maybeNumBytesReceived; + Optional maybeReceiveLoopTime; + Optional maybeNumPacketsReceived; + Optional maybeNumBytesReceived; std::vector receivedPackets; explicit BuilderFields() = default; }; @@ -297,7 +294,7 @@ class SocketObserverInterface { const std::vector& ackEvents; struct BuilderFields { - folly::Optional>> + Optional>> maybeAckEventsRef; explicit BuilderFields() = default; }; @@ -368,7 +365,7 @@ class SocketObserverInterface { std::chrono::microseconds rttSample; std::chrono::microseconds ackDelay; const quic::OutstandingPacketMetadata metadata; - const folly::Optional + const Optional lastAckedPacketInfo; }; diff --git a/quic/observer/test/SocketObserverInterfaceTest.cpp b/quic/observer/test/SocketObserverInterfaceTest.cpp index 051cbac1a..85c909891 100644 --- a/quic/observer/test/SocketObserverInterfaceTest.cpp +++ b/quic/observer/test/SocketObserverInterfaceTest.cpp @@ -19,11 +19,11 @@ class SocketObserverInterfaceTest : public ::testing::Test { * Fields in OutstandingPacketWrapper that are relevant to this test. */ struct OutstandingPacketRelevantFields { - folly::Optional maybePnSpace; - folly::Optional maybePacketNum; - folly::Optional maybeWriteCount; - folly::Optional maybeNumPacketsWritten; - folly::Optional maybeNumAckElicitingPacketsWritten; + Optional maybePnSpace; + Optional maybePacketNum; + Optional maybeWriteCount; + Optional maybeNumPacketsWritten; + Optional maybeNumAckElicitingPacketsWritten; }; static OutstandingPacketWrapper buildOutstandingPacket( @@ -82,8 +82,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(10) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(0) .setNumAckElicitingPacketsWritten(0) .setNumBytesWritten(0) @@ -121,8 +121,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(10) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(0) .setNumAckElicitingPacketsWritten(0) .setNumBytesWritten(0) @@ -151,8 +151,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(10) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(1) .setNumAckElicitingPacketsWritten(0) .setNumBytesWritten(0) @@ -190,8 +190,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(10) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(1) .setNumAckElicitingPacketsWritten(0) .setNumBytesWritten(0) @@ -249,8 +249,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(1) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(3) .setNumAckElicitingPacketsWritten(3) .setNumBytesWritten(0) @@ -328,8 +328,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(1) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(3) .setNumAckElicitingPacketsWritten(3) .setNumBytesWritten(0) @@ -408,8 +408,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(1) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(3) .setNumAckElicitingPacketsWritten(3) .setNumBytesWritten(0) @@ -487,8 +487,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(3) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(1) .setNumAckElicitingPacketsWritten(1) .setNumBytesWritten(0) @@ -552,8 +552,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(3) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(1) .setNumAckElicitingPacketsWritten(1) .setNumBytesWritten(0) @@ -627,8 +627,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(2) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(1) .setNumAckElicitingPacketsWritten(1) .setNumBytesWritten(0) @@ -722,8 +722,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(2) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(3) .setNumAckElicitingPacketsWritten(3) .setNumBytesWritten(0) @@ -781,8 +781,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(9) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(1) .setNumAckElicitingPacketsWritten(1) .setNumBytesWritten(0) @@ -826,8 +826,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(9) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(2) .setNumAckElicitingPacketsWritten(1) .setNumBytesWritten(0) @@ -881,8 +881,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(9) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(2) .setNumAckElicitingPacketsWritten(2) .setNumBytesWritten(0) @@ -944,8 +944,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(9) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(3) .setNumAckElicitingPacketsWritten(2) .setNumBytesWritten(0) @@ -1027,8 +1027,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(9) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(2) .setNumAckElicitingPacketsWritten(2) .setNumBytesWritten(0) @@ -1100,8 +1100,8 @@ TEST_F(SocketObserverInterfaceTest, InvokeForEachNewOutstandingPacketOrdered) { .setOutstandingPackets(outstandingPackets) .setWriteCount(9) .setLastPacketSentTime(TimePoint()) - .setCwndInBytes(folly::none) - .setWritableBytes(folly::none) + .setCwndInBytes(none) + .setWritableBytes(none) .setNumPacketsWritten(1) .setNumAckElicitingPacketsWritten(1) .setNumBytesWritten(0) diff --git a/quic/samples/echo/EchoClient.h b/quic/samples/echo/EchoClient.h index 2b9e00951..9555a0fdd 100644 --- a/quic/samples/echo/EchoClient.h +++ b/quic/samples/echo/EchoClient.h @@ -251,7 +251,7 @@ class EchoClient : public quic::QuicSocket::ConnectionSetupCallback, auto sendMessageInStream = [&]() { if (message == "/close") { - quicClient_->close(folly::none); + quicClient_->close(none); closed = true; return; } diff --git a/quic/samples/echo/LogQuicStats.h b/quic/samples/echo/LogQuicStats.h index 23eeea25f..e94d4865e 100644 --- a/quic/samples/echo/LogQuicStats.h +++ b/quic/samples/echo/LogQuicStats.h @@ -110,8 +110,7 @@ class LogQuicStats : public quic::QuicTransportStatsCallback { VLOG(2) << prefix_ << __func__; } - void onConnectionClose( - folly::Optional code = folly::none) override { + void onConnectionClose(Optional code = none) override { VLOG(2) << prefix_ << __func__ << " reason=" << quic::toString(code.value_or(LocalErrorCode::NO_ERROR)); } diff --git a/quic/server/BUCK b/quic/server/BUCK index 1e7251db4..8bc248e6a 100644 --- a/quic/server/BUCK +++ b/quic/server/BUCK @@ -33,7 +33,6 @@ mvfst_cpp_library( ":accept_observer", "//common/network:mvfst_hooks", # @manual "//folly:conv", - "//folly:optional", "//folly/chrono:conv", "//folly/experimental/io:io_uring_backend", "//folly/io:iobuf", @@ -41,6 +40,7 @@ mvfst_cpp_library( "//folly/portability:gflags", "//folly/system:thread_id", "//quic/codec:header_codec", + "//quic/common:optional", "//quic/common:socket_util", "//quic/congestion_control:bbr", "//quic/congestion_control:copa", @@ -94,8 +94,8 @@ mvfst_cpp_library( "SlidingWindowRateLimiter.h", ], exported_deps = [ - "//folly:optional", "//quic:constants", + "//quic/common:optional", ], ) diff --git a/quic/server/QuicServer.cpp b/quic/server/QuicServer.cpp index 39868482d..f80db6264 100644 --- a/quic/server/QuicServer.cpp +++ b/quic/server/QuicServer.cpp @@ -415,7 +415,7 @@ void QuicServer::routeDataToWorker( const folly::SocketAddress& client, RoutingData&& routingData, NetworkData&& networkData, - folly::Optional quicVersion, + Optional quicVersion, folly::EventBase*, bool isForwardedData) { // figure out worker idx diff --git a/quic/server/QuicServer.h b/quic/server/QuicServer.h index aa5bb7b3b..5a928327c 100644 --- a/quic/server/QuicServer.h +++ b/quic/server/QuicServer.h @@ -32,7 +32,7 @@ class QuicServer : public QuicServerWorker::WorkerCallback, public std::enable_shared_from_this { public: using TransportSettingsOverrideFn = - std::function( + std::function( const quic::TransportSettings&, const folly::IPAddress&)>; @@ -360,7 +360,7 @@ class QuicServer : public QuicServerWorker::WorkerCallback, const folly::SocketAddress& client, RoutingData&& routingData, NetworkData&& networkData, - folly::Optional quicVersion, + Optional quicVersion, folly::EventBase* workerEvb, bool isForwardedData = false) override; @@ -431,7 +431,7 @@ class QuicServer : public QuicServerWorker::WorkerCallback, // factory used to create specific instance of Congestion control algorithm std::shared_ptr ccFactory_; - folly::Optional healthCheckToken_; + Optional healthCheckToken_; // vector of all the listening fds on each quic server worker std::vector listeningFDs_; ProcessId processId_{ProcessId::ZERO}; @@ -458,7 +458,7 @@ class QuicServer : public QuicServerWorker::WorkerCallback, std::function count; std::chrono::seconds window; }; - folly::Optional rateLimit_; + Optional rateLimit_; std::function unfinishedHandshakeLimitFn_{[]() { return 1048576; }}; diff --git a/quic/server/QuicServerPacketRouter.h b/quic/server/QuicServerPacketRouter.h index 68287127d..e72b2880b 100644 --- a/quic/server/QuicServerPacketRouter.h +++ b/quic/server/QuicServerPacketRouter.h @@ -46,14 +46,14 @@ struct RoutingData { // // Source connection may not be present for short header packets. - folly::Optional sourceConnId; + Optional sourceConnId; RoutingData( HeaderForm headerFormIn, bool isInitialIn, bool is0RttIn, ConnectionId destinationConnIdIn, - folly::Optional sourceConnIdIn) + Optional sourceConnIdIn) : headerForm(headerFormIn), isInitial(isInitialIn), is0Rtt(is0RttIn), diff --git a/quic/server/QuicServerTransport.cpp b/quic/server/QuicServerTransport.cpp index 6b40d4865..86fb28a6a 100644 --- a/quic/server/QuicServerTransport.cpp +++ b/quic/server/QuicServerTransport.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include #include @@ -534,7 +534,7 @@ void QuicServerTransport::maybeWriteNewSessionTicket() { conn_->qLogger->addTransportStateUpdate(kWriteNst); } newSessionTicketWrittenTimestamp_ = Clock::now(); - folly::Optional cwndHint = folly::none; + Optional cwndHint = none; if (conn_->transportSettings.includeCwndHintsInSessionTicket && conn_->congestionController) { VLOG(7) << "Writing a new session ticket with cwnd=" @@ -1195,7 +1195,7 @@ void QuicServerTransport::logTimeBasedStats() const { } } -folly::Optional> +Optional> QuicServerTransport::getPeerTransportParams() const { if (serverConn_ && serverConn_->serverHandshakeLayer) { auto maybeParams = @@ -1204,7 +1204,7 @@ QuicServerTransport::getPeerTransportParams() const { return maybeParams->parameters; } } - return folly::none; + return none; } void QuicServerTransport::setCongestionControl(CongestionControlType type) { diff --git a/quic/server/QuicServerTransport.h b/quic/server/QuicServerTransport.h index 60753c293..849b4380b 100644 --- a/quic/server/QuicServerTransport.h +++ b/quic/server/QuicServerTransport.h @@ -169,9 +169,9 @@ class QuicServerTransport * context is the context value argument for the TLS exporter. * keyLength is the length of the exported key. */ - folly::Optional> getExportedKeyingMaterial( + Optional> getExportedKeyingMaterial( const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength) const override { return serverConn_->serverHandshakeLayer->getExportedKeyingMaterial( label, context, keyLength); @@ -182,7 +182,7 @@ class QuicServerTransport */ void logTimeBasedStats() const; - folly::Optional> getPeerTransportParams() + Optional> getPeerTransportParams() const override; void setCongestionControl(CongestionControlType type) override; @@ -250,8 +250,8 @@ class QuicServerTransport std::shared_ptr ctx_; bool notifiedRouting_{false}; bool notifiedConnIdBound_{false}; - folly::Optional newSessionTicketWrittenTimestamp_; - folly::Optional newSessionTicketWrittenCwndHint_; + Optional newSessionTicketWrittenTimestamp_; + Optional newSessionTicketWrittenCwndHint_; QuicServerConnectionState* serverConn_; std::unordered_map< uint64_t, diff --git a/quic/server/QuicServerWorker.cpp b/quic/server/QuicServerWorker.cpp index 99fbd65c3..cb9e4411b 100644 --- a/quic/server/QuicServerWorker.cpp +++ b/quic/server/QuicServerWorker.cpp @@ -238,8 +238,7 @@ bool QuicServerWorker::maybeSendVersionNegotiationPacketOrDrop( bool isInitial, LongHeaderInvariant& invariant, size_t datagramLen) { - folly::Optional> - versionNegotiationPacket; + Optional> versionNegotiationPacket; if (isInitial && datagramLen < kMinInitialPacketSize) { VLOG(3) << "Dropping initial packet due to invalid size"; QUIC_STATS( @@ -442,12 +441,12 @@ void QuicServerWorker::handleNetworkData( false, /* isInitial */ false, /* is0Rtt */ std::move(maybeParsedShortHeader->destinationConnId), - folly::none); + none); return forwardNetworkData( client, std::move(routingData), NetworkData(std::move(udpPacket)), - folly::none, /* quicVersion */ + none, /* quicVersion */ isForwardedData); } } else if ( @@ -599,7 +598,7 @@ void QuicServerWorker::forwardNetworkData( const folly::SocketAddress& client, RoutingData&& routingData, NetworkData&& networkData, - folly::Optional quicVersion, + Optional quicVersion, bool isForwardedData) { // if it's not Client initial or ZeroRtt, AND if the connectionId version // mismatches: forward if pktForwarding is enabled else dropPacket @@ -642,7 +641,7 @@ void QuicServerWorker::setPacingTimer( QuicServerTransport::Ptr QuicServerWorker::makeTransport( QuicVersion quicVersion, const folly::SocketAddress& client, - const folly::Optional& srcConnId, + const Optional& srcConnId, const ConnectionId& dstConnId, bool validNewToken) { // create 'accepting' transport @@ -759,7 +758,7 @@ void QuicServerWorker::dispatchPacketData( const folly::SocketAddress& client, RoutingData&& routingData, NetworkData&& networkData, - folly::Optional quicVersion, + Optional quicVersion, bool isForwardedData) noexcept { DCHECK(socket_); CHECK(transportFactory_); @@ -997,23 +996,23 @@ void QuicServerWorker::sendResetPacket( QUIC_STATS(statsCallback_, onStatelessReset); } -folly::Optional QuicServerWorker::maybeGetEncryptedToken( +Optional QuicServerWorker::maybeGetEncryptedToken( folly::io::Cursor& cursor) { // Move cursor to the byte right after the initial byte if (!cursor.canAdvance(1)) { - return folly::none; + return none; } auto initialByte = cursor.readBE(); // We already know this is an initial packet, which uses a long header auto parsedLongHeader = parseLongHeader(initialByte, cursor); if (!parsedLongHeader || !parsedLongHeader->parsedLongHeader.has_value()) { - return folly::none; + return none; } auto header = parsedLongHeader->parsedLongHeader.value().header; if (!header.hasToken()) { - return folly::none; + return none; } return header.getToken(); } diff --git a/quic/server/QuicServerWorker.h b/quic/server/QuicServerWorker.h index 290f11b13..de56822d5 100644 --- a/quic/server/QuicServerWorker.h +++ b/quic/server/QuicServerWorker.h @@ -152,7 +152,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback, public: using TransportSettingsOverrideFn = - std::function( + std::function( const quic::TransportSettings&, const folly::IPAddress&)>; @@ -166,7 +166,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback, const folly::SocketAddress& client, RoutingData&& routingData, NetworkData&& networkData, - folly::Optional quicVersion, + Optional quicVersion, folly::EventBase* workerEvb, bool isForwardedData) = 0; }; @@ -428,7 +428,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback, const folly::SocketAddress& client, RoutingData&& routingData, NetworkData&& networkData, - folly::Optional quicVersion, + Optional quicVersion, bool isForwardedData = false) noexcept; using ConnIdToTransportMap = folly:: @@ -541,8 +541,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback, /** * Tries to get the encrypted retry token from a client initial packet */ - folly::Optional maybeGetEncryptedToken( - folly::io::Cursor& cursor); + Optional maybeGetEncryptedToken(folly::io::Cursor& cursor); bool validRetryToken( std::string& encryptedToken, @@ -600,14 +599,14 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback, const folly::SocketAddress& client, RoutingData&& routingData, NetworkData&& networkData, - folly::Optional quicVersion, + Optional quicVersion, bool isForwardedData = false); // Create transport and invoke appropriate setters QuicServerTransport::Ptr makeTransport( QuicVersion quicVersion, const folly::SocketAddress& client, - const folly::Optional& srcConnId, + const Optional& srcConnId, const ConnectionId& dstConnId, bool validNewToken); @@ -653,7 +652,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback, // Same value as transportSettings_.numGROBuffers_ if the kernel // supports GRO. otherwise 1 uint32_t numGROBuffers_{kDefaultNumGROBuffers}; - folly::Optional healthCheckToken_; + Optional healthCheckToken_; std::function rejectNewConnections_{[]() { return false; }}; std::function isBlockListedSrcPort_{ [](uint16_t) { return false; }}; @@ -681,7 +680,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback, // Rate limits the creation of new connections for this worker. std::unique_ptr newConnRateLimiter_; - folly::Optional> unfinishedHandshakeLimitFn_; + Optional> unfinishedHandshakeLimitFn_; // EventRecvmsgCallback data std::unique_ptr msgHdr_; diff --git a/quic/server/SlidingWindowRateLimiter.h b/quic/server/SlidingWindowRateLimiter.h index 6645af350..bc8e7a64d 100644 --- a/quic/server/SlidingWindowRateLimiter.h +++ b/quic/server/SlidingWindowRateLimiter.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -37,7 +37,7 @@ class SlidingWindowRateLimiter : public RateLimiter { private: const std::function count_; const std::chrono::microseconds window_; - folly::Optional currentWindowStartPoint_{folly::none}; + Optional currentWindowStartPoint_{none}; uint64_t countInPrevWindow_{0}; uint64_t countInCurWindow_{0}; }; diff --git a/quic/server/handshake/AppToken.cpp b/quic/server/handshake/AppToken.cpp index 7d810250b..2725beb99 100644 --- a/quic/server/handshake/AppToken.cpp +++ b/quic/server/handshake/AppToken.cpp @@ -18,7 +18,7 @@ TicketTransportParameters createTicketTransportParameters( uint64_t initialMaxStreamDataUni, uint64_t initialMaxStreamsBidi, uint64_t initialMaxStreamsUni, - folly::Optional cwndHintBytes) { + Optional cwndHintBytes) { TicketTransportParameters params; params.parameters.push_back( encodeIntegerParameter(TransportParameterId::idle_timeout, idleTimeout)); diff --git a/quic/server/handshake/AppToken.h b/quic/server/handshake/AppToken.h index ba966f794..22ba67dbd 100644 --- a/quic/server/handshake/AppToken.h +++ b/quic/server/handshake/AppToken.h @@ -36,6 +36,6 @@ TicketTransportParameters createTicketTransportParameters( uint64_t initialMaxStreamDataUni, uint64_t initialMaxStreamsBidi, uint64_t initialMaxStreamsUni, - folly::Optional cwndHintBytes = folly::none); + Optional cwndHintBytes = none); } // namespace quic diff --git a/quic/server/handshake/BUCK b/quic/server/handshake/BUCK index 8462636cf..2d584ba38 100644 --- a/quic/server/handshake/BUCK +++ b/quic/server/handshake/BUCK @@ -76,8 +76,8 @@ mvfst_cpp_library( exported_deps = [ "//fizz/server:protocol", "//folly:function", - "//folly:optional", "//folly/io:iobuf", + "//quic/common:optional", ], external_deps = [ "glog", diff --git a/quic/server/handshake/DefaultAppTokenValidator.cpp b/quic/server/handshake/DefaultAppTokenValidator.cpp index 74c86b111..2ce93378b 100644 --- a/quic/server/handshake/DefaultAppTokenValidator.cpp +++ b/quic/server/handshake/DefaultAppTokenValidator.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include diff --git a/quic/server/handshake/DefaultAppTokenValidator.h b/quic/server/handshake/DefaultAppTokenValidator.h index 3aa759975..a33f4b6d5 100644 --- a/quic/server/handshake/DefaultAppTokenValidator.h +++ b/quic/server/handshake/DefaultAppTokenValidator.h @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include diff --git a/quic/server/handshake/ServerHandshake.cpp b/quic/server/handshake/ServerHandshake.cpp index 1f64354e5..251750031 100644 --- a/quic/server/handshake/ServerHandshake.cpp +++ b/quic/server/handshake/ServerHandshake.cpp @@ -172,7 +172,7 @@ ServerHandshake::Phase ServerHandshake::getPhase() const { return phase_; } -folly::Optional +Optional ServerHandshake::getClientTransportParams() { return transportParams_->getClientTransportParams(); } @@ -185,15 +185,14 @@ const fizz::server::State& ServerHandshake::getState() const { return state_; } -folly::Optional> -ServerHandshake::getExportedKeyingMaterial( +Optional> ServerHandshake::getExportedKeyingMaterial( const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength) { const auto cipherSuite = state_.cipher(); const auto& ems = state_.exporterMasterSecret(); if (!ems.hasValue() || !cipherSuite.hasValue()) { - return folly::none; + return none; } auto ekm = fizz::Exporter::getExportedKeyingMaterial( @@ -201,15 +200,14 @@ ServerHandshake::getExportedKeyingMaterial( cipherSuite.value(), ems.value()->coalesce(), label, - context == folly::none ? nullptr : folly::IOBuf::wrapBuffer(*context), + context == none ? nullptr : folly::IOBuf::wrapBuffer(*context), keyLength); std::vector result(ekm->coalesce()); return result; } -const folly::Optional& ServerHandshake::getApplicationProtocol() - const { +const Optional& ServerHandshake::getApplicationProtocol() const { return state_.alpn(); } @@ -303,7 +301,7 @@ void ServerHandshake::processPendingEvents() { } } -const folly::Optional& ServerHandshake::getAppToken() const { +const Optional& ServerHandshake::getAppToken() const { return state_.appToken(); } diff --git a/quic/server/handshake/ServerHandshake.h b/quic/server/handshake/ServerHandshake.h index 3982d7030..69e747dc1 100644 --- a/quic/server/handshake/ServerHandshake.h +++ b/quic/server/handshake/ServerHandshake.h @@ -180,7 +180,7 @@ class ServerHandshake : public Handshake { /** * Returns the negotiated transport parameters from the client. */ - virtual folly::Optional getClientTransportParams(); + virtual Optional getClientTransportParams(); /** * Returns whether all the events that the handshake needs are complete. @@ -195,15 +195,15 @@ class ServerHandshake : public Handshake { /** * Returns the exporter master secret from the handshake. */ - folly::Optional> getExportedKeyingMaterial( + Optional> getExportedKeyingMaterial( const std::string& label, - const folly::Optional& context, + const Optional& context, uint16_t keyLength) override; /** * Returns the negotiated ALPN from the handshake. */ - const folly::Optional& getApplicationProtocol() const override; + const Optional& getApplicationProtocol() const override; /** * Given secret_n, returns secret_n+1 to be used for generating the next Aead @@ -245,7 +245,7 @@ class ServerHandshake : public Handshake { /** * Returns the AppToken seen in session ticket if the session was resumed. */ - const folly::Optional& getAppToken() const; + const Optional& getAppToken() const; protected: Phase phase_{Phase::Handshake}; @@ -275,7 +275,7 @@ class ServerHandshake : public Handshake { folly::IOBufQueue appDataReadBuf_{folly::IOBufQueue::cacheChainLength()}; HandshakeCallback* callback_{nullptr}; - folly::Optional> error_; + Optional> error_; std::unique_ptr handshakeReadCipher_; std::unique_ptr oneRttReadCipher_; diff --git a/quic/server/handshake/ServerTransportParametersExtension.h b/quic/server/handshake/ServerTransportParametersExtension.h index 8250ab109..56dd79b3a 100644 --- a/quic/server/handshake/ServerTransportParametersExtension.h +++ b/quic/server/handshake/ServerTransportParametersExtension.h @@ -123,7 +123,7 @@ class ServerTransportParametersExtension : public fizz::ServerExtensions { return exts; } - const folly::Optional& getClientTransportParams() { + const Optional& getClientTransportParams() { return clientTransportParameters_; } @@ -139,7 +139,7 @@ class ServerTransportParametersExtension : public fizz::ServerExtensions { std::chrono::milliseconds idleTimeout_; uint64_t ackDelayExponent_; uint64_t maxRecvPacketSize_; - folly::Optional clientTransportParameters_; + Optional clientTransportParameters_; StatelessResetToken token_; ConnectionId initialSourceCid_; ConnectionId originalDestinationCid_; diff --git a/quic/server/handshake/TokenGenerator.cpp b/quic/server/handshake/TokenGenerator.cpp index 7c545a315..7cf543e19 100644 --- a/quic/server/handshake/TokenGenerator.cpp +++ b/quic/server/handshake/TokenGenerator.cpp @@ -25,7 +25,7 @@ TokenGenerator::TokenGenerator(TokenSecret secret) : cipher_(kCipherContexts) { cipher_.setSecrets(secrets); } -folly::Optional TokenGenerator::encryptToken( +Optional TokenGenerator::encryptToken( const QuicAddrValidationToken& token) { // Generate the retry token in plaintext auto plainTextToken = token.getPlaintextToken(); diff --git a/quic/server/handshake/TokenGenerator.h b/quic/server/handshake/TokenGenerator.h index bd8c77892..66196002d 100644 --- a/quic/server/handshake/TokenGenerator.h +++ b/quic/server/handshake/TokenGenerator.h @@ -22,7 +22,7 @@ class TokenGenerator { public: explicit TokenGenerator(TokenSecret secret); - folly::Optional encryptToken(const QuicAddrValidationToken& token); + Optional encryptToken(const QuicAddrValidationToken& token); uint64_t decryptToken(Buf encryptedToken, Buf aeadAssocData); diff --git a/quic/server/handshake/test/AppTokenTest.cpp b/quic/server/handshake/test/AppTokenTest.cpp index 6ddcfa4f1..fa4390dce 100644 --- a/quic/server/handshake/test/AppTokenTest.cpp +++ b/quic/server/handshake/test/AppTokenTest.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -21,7 +21,7 @@ namespace quic { namespace test { void expectAppTokenEqual( - const folly::Optional& decodedAppToken, + const Optional& decodedAppToken, const AppToken& appToken) { EXPECT_TRUE(decodedAppToken.has_value()); diff --git a/quic/server/handshake/test/BUCK b/quic/server/handshake/test/BUCK index 87f77576b..916fbc328 100644 --- a/quic/server/handshake/test/BUCK +++ b/quic/server/handshake/test/BUCK @@ -51,8 +51,8 @@ cpp_unittest( ], deps = [ "//fizz/server:resumption_state", - "//folly:optional", "//quic:constants", + "//quic/common:optional", "//quic/fizz/server/handshake:handshake_app_token", "//quic/server/state:server", ], @@ -66,9 +66,9 @@ cpp_unittest( deps = [ "fbsource//third-party/googletest:gmock", "//fizz/server:resumption_state", - "//folly:optional", "//quic:constants", "//quic/api/test:mocks", + "//quic/common:optional", "//quic/fizz/server/handshake:fizz_server_handshake", "//quic/fizz/server/handshake:handshake_app_token", "//quic/server/handshake:default_app_token_validator", diff --git a/quic/server/handshake/test/DefaultAppTokenValidatorTest.cpp b/quic/server/handshake/test/DefaultAppTokenValidatorTest.cpp index 43f5c5388..29aee0174 100644 --- a/quic/server/handshake/test/DefaultAppTokenValidatorTest.cpp +++ b/quic/server/handshake/test/DefaultAppTokenValidatorTest.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -49,7 +49,7 @@ TEST(DefaultAppTokenValidatorTest, TestValidParams) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { return true; }; DefaultAppTokenValidator validator(&conn); EXPECT_CALL(*quicStats, onZeroRttAccepted()); @@ -82,7 +82,7 @@ TEST(DefaultAppTokenValidatorTest, TestValidOptionalParameter) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { return true; }; DefaultAppTokenValidator validator(&conn); EXPECT_CALL(*quicStats, onZeroRttAccepted()).Times(1); @@ -117,7 +117,7 @@ TEST( ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { return true; }; DefaultAppTokenValidator validator(&conn); EXPECT_CALL(*quicStats, onZeroRttRejected()).Times(0); @@ -139,7 +139,7 @@ TEST(DefaultAppTokenValidatorTest, TestInvalidNullAppToken) { conn.version = QuicVersion::MVFST; ResumptionState resState; - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { EXPECT_TRUE(false); return true; @@ -160,7 +160,7 @@ TEST(DefaultAppTokenValidatorTest, TestInvalidEmptyTransportParams) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { EXPECT_TRUE(false); return true; @@ -202,7 +202,7 @@ TEST(DefaultAppTokenValidatorTest, TestInvalidMissingParams) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { EXPECT_TRUE(false); return true; @@ -236,7 +236,7 @@ TEST(DefaultAppTokenValidatorTest, TestInvalidRedundantParameter) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { EXPECT_TRUE(false); return true; @@ -271,7 +271,7 @@ TEST(DefaultAppTokenValidatorTest, TestInvalidDecreasedInitialMaxStreamData) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { EXPECT_TRUE(false); return true; @@ -301,7 +301,7 @@ TEST(DefaultAppTokenValidatorTest, TestChangedIdleTimeout) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { EXPECT_TRUE(false); return true; @@ -333,7 +333,7 @@ TEST(DefaultAppTokenValidatorTest, TestDecreasedInitialMaxStreams) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { EXPECT_TRUE(false); return true; @@ -368,7 +368,7 @@ TEST(DefaultAppTokenValidatorTest, TestInvalidAppParams) { ResumptionState resState; resState.appToken = encodeAppToken(appToken); - conn.earlyDataAppParamsValidator = [](const folly::Optional&, + conn.earlyDataAppParamsValidator = [](const Optional&, const Buf&) { return false; }; DefaultAppTokenValidator validator(&conn); EXPECT_FALSE(validator.validate(resState)); @@ -400,10 +400,8 @@ class SourceAddressTokenTest : public Test { ResumptionState resState; resState.appToken = encodeAppToken(appToken_); - conn_.earlyDataAppParamsValidator = [=](const folly::Optional&, - const Buf&) { - return acceptZeroRtt; - }; + conn_.earlyDataAppParamsValidator = + [=](const Optional&, const Buf&) { return acceptZeroRtt; }; DefaultAppTokenValidator validator(&conn_); EXPECT_EQ(validator.validate(resState), acceptZeroRtt); } diff --git a/quic/server/handshake/test/ServerHandshakeTest.cpp b/quic/server/handshake/test/ServerHandshakeTest.cpp index 44e27e97a..bfdd12297 100644 --- a/quic/server/handshake/test/ServerHandshakeTest.cpp +++ b/quic/server/handshake/test/ServerHandshakeTest.cpp @@ -143,7 +143,7 @@ class ServerHandshakeTest : public Test { verifier, hostname, cachedPsk, - folly::Optional>(folly::none), + Optional>(none), std::make_shared(clientExtensions)); } @@ -370,14 +370,13 @@ class ServerHandshakeTest : public Test { TEST_F(ServerHandshakeTest, TestGetExportedKeyingMaterial) { // Sanity check. getExportedKeyingMaterial() should return nullptr prior to // an handshake. - auto ekm = handshake->getExportedKeyingMaterial( - "EXPORTER-Some-Label", folly::none, 32); + auto ekm = + handshake->getExportedKeyingMaterial("EXPORTER-Some-Label", none, 32); EXPECT_TRUE(!ekm.has_value()); clientServerRound(); serverClientRound(); - ekm = handshake->getExportedKeyingMaterial( - "EXPORTER-Some-Label", folly::none, 32); + ekm = handshake->getExportedKeyingMaterial("EXPORTER-Some-Label", none, 32); ASSERT_TRUE(ekm.has_value()); EXPECT_EQ(ekm->size(), 32); @@ -440,8 +439,8 @@ class AsyncRejectingTicketCipher : public fizz::server::TicketCipher { public: ~AsyncRejectingTicketCipher() override = default; - folly::SemiFuture, std::chrono::seconds>>> + folly::SemiFuture< + Optional, std::chrono::seconds>>> encrypt(fizz::server::ResumptionState) const override { if (!encryptAsync_) { return std::make_pair(folly::IOBuf::create(0), 2s); @@ -449,7 +448,7 @@ class AsyncRejectingTicketCipher : public fizz::server::TicketCipher { encryptAsync_ = false; return std::move(encryptFuture_).deferValue([](auto&&) { VLOG(1) << "got ticket async"; - return folly::makeSemiFuture, std::chrono::seconds>>>( std::make_pair(folly::IOBuf::create(0), 2s)); }); @@ -471,13 +470,13 @@ class AsyncRejectingTicketCipher : public fizz::server::TicketCipher { } folly::SemiFuture< - std::pair>> + std::pair>> decrypt(std::unique_ptr) const override { if (!decryptAsync_) { if (error_) { throw std::runtime_error("test decrypt error"); } - return std::make_pair(fizz::PskType::Rejected, folly::none); + return std::make_pair(fizz::PskType::Rejected, none); } else { decryptAsync_ = false; return std::move(decryptFuture_).deferValue([&](auto&&) { @@ -485,10 +484,9 @@ class AsyncRejectingTicketCipher : public fizz::server::TicketCipher { if (error_) { throw std::runtime_error("test decrypt error"); } - return folly::makeSemiFuture>>( - std::make_pair(fizz::PskType::Rejected, folly::none)); + return folly::makeSemiFuture< + std::pair>>( + std::make_pair(fizz::PskType::Rejected, none)); }); } } @@ -657,7 +655,7 @@ TEST_F(ServerHandshakeHRRTest, TestAsyncCancel) { promise.setValue(); evb.loop(); - EXPECT_EQ(handshake->getApplicationProtocol(), folly::none); + EXPECT_EQ(handshake->getApplicationProtocol(), none); expectOneRttCipher(false); } @@ -774,7 +772,7 @@ class ServerHandshakeZeroRttDefaultAppTokenValidatorTest public: ~AcceptingTicketCipher() override = default; - folly::SemiFuture, std::chrono::seconds>>> encrypt(fizz::server::ResumptionState) const override { // Fake handshake, no need todo anything here. @@ -791,9 +789,8 @@ class ServerHandshakeZeroRttDefaultAppTokenValidatorTest resState.serverCert = psk.serverCert; } - folly::SemiFuture>> + folly::SemiFuture< + std::pair>> decrypt(std::unique_ptr) const override { return std::make_pair(fizz::PskType::Resumption, std::move(resState)); } diff --git a/quic/server/state/ServerStateMachine.cpp b/quic/server/state/ServerStateMachine.cpp index 5695b0fd4..a38f46286 100644 --- a/quic/server/state/ServerStateMachine.cpp +++ b/quic/server/state/ServerStateMachine.cpp @@ -538,7 +538,7 @@ void updateWritableByteLimitOnRecvPacket(QuicServerConnectionState& conn) { void maybeUpdateTransportFromAppToken( QuicServerConnectionState& conn, - const folly::Optional& tokenBuf) { + const Optional& tokenBuf) { if (!tokenBuf) { return; } @@ -1544,7 +1544,7 @@ void onServerCloseOpenState(QuicServerConnectionState& conn) { conn.state = ServerState::Closed; } -folly::Optional +Optional QuicServerConnectionState::createAndAddNewSelfConnId() { // Should be set right after server transport construction. CHECK(connIdAlgo); @@ -1568,7 +1568,7 @@ QuicServerConnectionState::createAndAddNewSelfConnId() { LOG_IF(ERROR, encodedTimes == kConnIdEncodingRetryLimit) << "Quic CIDRejector rejected all conneectionIDs"; if (encodedCid.hasError()) { - return folly::none; + return none; } QUIC_STATS(statsCallback, onConnectionIdCreated, encodedTimes); auto newConnIdData = diff --git a/quic/server/state/ServerStateMachine.h b/quic/server/state/ServerStateMachine.h index 05ccea28a..8fe8e8d78 100644 --- a/quic/server/state/ServerStateMachine.h +++ b/quic/server/state/ServerStateMachine.h @@ -77,7 +77,7 @@ struct ConnectionMigrationState { std::vector previousPeerAddresses; // Congestion state and rtt stats of last validated peer - folly::Optional lastCongestionAndRtt; + Optional lastCongestionAndRtt; }; /** @@ -105,7 +105,7 @@ struct QuicServerConnectionState : public QuicConnectionStateBase { ConnectionMigrationState migrationState; // Parameters to generate server chosen connection id - folly::Optional serverConnIdParams; + Optional serverConnIdParams; // ConnectionIdAlgo implementation to encode and decode ConnectionId with // various info, such as routing related info. @@ -122,14 +122,14 @@ struct QuicServerConnectionState : public QuicConnectionStateBase { // Whether transport parameters from psk match current server parameters. // A false value indicates 0-rtt is rejected. - folly::Optional transportParamsMatching; + Optional transportParamsMatching; - folly::Optional maybeCwndHintBytes; + Optional maybeCwndHintBytes; // Whether source address token matches client ip. // A false value indicates either 0-rtt is rejected or inflight bytes are // limited until CFIN depending on matching policy. - folly::Optional sourceTokenMatching; + Optional sourceTokenMatching; // Server address of VIP. Currently used as input for stateless reset token. folly::SocketAddress serverAddr; @@ -152,9 +152,9 @@ struct QuicServerConnectionState : public QuicConnectionStateBase { MaxPacingRateKnobState maxPacingRateKnobState{}; // Sequence number of the last received MAX_PACING_RATE_KNOB_SEQUENCED. - folly::Optional maybeLastMaxPacingRateKnobSeqNum{folly::none}; + Optional maybeLastMaxPacingRateKnobSeqNum{none}; - folly::Optional createAndAddNewSelfConnId() override; + Optional createAndAddNewSelfConnId() override; QuicServerConnectionState( std::shared_ptr handshakeFactory) @@ -224,7 +224,7 @@ void updateWritableByteLimitOnRecvPacket(QuicServerConnectionState& conn); void maybeUpdateTransportFromAppToken( QuicServerConnectionState& conn, - const folly::Optional& appToken); + const Optional& appToken); void onConnectionMigration( QuicServerConnectionState& conn, diff --git a/quic/server/test/Mocks.h b/quic/server/test/Mocks.h index eb557479b..299bb662b 100644 --- a/quic/server/test/Mocks.h +++ b/quic/server/test/Mocks.h @@ -67,7 +67,7 @@ class MockWorkerCallback : public QuicServerWorker::WorkerCallback { (const folly::SocketAddress&, std::unique_ptr&, std::unique_ptr&, - folly::Optional, + Optional, bool isForwardedData)); MOCK_METHOD( @@ -76,14 +76,14 @@ class MockWorkerCallback : public QuicServerWorker::WorkerCallback { (const folly::SocketAddress&, std::unique_ptr&, std::unique_ptr&, - folly::Optional, + Optional, bool isForwardedData)); void routeDataToWorker( const folly::SocketAddress& client, RoutingData&& routingDataIn, NetworkData&& networkDataIn, - folly::Optional quicVersion, + Optional quicVersion, folly::EventBase*, bool isForwardedData = false) { auto routingData = std::make_unique(std::move(routingDataIn)); @@ -157,8 +157,8 @@ class MockQuicServerTransport : public QuicServerTransport { nullptr, nullptr) {} MOCK_CONST_METHOD0(getOneRttCipherInfo, CipherInfo()); - MOCK_CONST_METHOD0(getServerConnectionId, folly::Optional()); - MOCK_CONST_METHOD0(getClientConnectionId, folly::Optional()); + MOCK_CONST_METHOD0(getServerConnectionId, Optional()); + MOCK_CONST_METHOD0(getClientConnectionId, Optional()); MOCK_CONST_METHOD0(getPeerAddress, folly::SocketAddress&()); }; diff --git a/quic/server/test/QuicClientServerIntegrationTest.cpp b/quic/server/test/QuicClientServerIntegrationTest.cpp index d045e1c8a..336fb634c 100644 --- a/quic/server/test/QuicClientServerIntegrationTest.cpp +++ b/quic/server/test/QuicClientServerIntegrationTest.cpp @@ -54,7 +54,7 @@ class ServerTransportParameters : public testing::Test { } void TearDown() override { if (client_) { - client_->close(folly::none); + client_->close(none); } evb_.loop(); } diff --git a/quic/server/test/QuicServerTest.cpp b/quic/server/test/QuicServerTest.cpp index b64a4e9f0..8ca19f6f2 100644 --- a/quic/server/test/QuicServerTest.cpp +++ b/quic/server/test/QuicServerTest.cpp @@ -166,7 +166,7 @@ class QuicServerWorkerTest : public Test { auto cb = [&](const folly::SocketAddress& addr, std::unique_ptr& routingData, std::unique_ptr& networkData, - folly::Optional quicVersion, + Optional quicVersion, bool isForwardedData) { worker_->dispatchPacketData( addr, @@ -342,8 +342,7 @@ void QuicServerWorkerTest::testSendReset( auto aead = createNoOpAead(); // Make the decrypt fail EXPECT_CALL(*aead, _tryDecrypt(_, _, _)) - .WillRepeatedly( - Invoke([&](auto&, auto, auto) { return folly::none; })); + .WillRepeatedly(Invoke([&](auto&, auto, auto) { return none; })); codec.setOneRttReadCipher(std::move(aead)); codec.setOneRttHeaderCipher(test::createNoOpHeaderCipher()); StatelessResetToken token = generateStatelessResetToken(); @@ -359,16 +358,12 @@ void QuicServerWorkerTest::testSendReset( })); RoutingData routingData( - HeaderForm::Short, - false, - false, - shortHeader.getConnectionId(), - folly::none); + HeaderForm::Short, false, false, shortHeader.getConnectionId(), none); worker_->dispatchPacketData( kClientAddr, std::move(routingData), NetworkData(packet->clone(), Clock::now(), 0), - folly::none); + none); eventbase_.loopIgnoreKeepAlive(); } @@ -418,12 +413,12 @@ TEST_F(QuicServerWorkerTest, SmallPacketTestNoReset) { false, false, shortHeaderConnId.getConnectionId(), - folly::none); + none); worker_->dispatchPacketData( kClientAddr, std::move(routingData), NetworkData(data->clone(), Clock::now(), 0), - folly::none); + none); eventbase_.loopIgnoreKeepAlive(); } @@ -710,13 +705,12 @@ TEST_F(QuicServerWorkerTest, QuicServerMultipleConnIdsRouting) { EXPECT_CALL( *transport_, onNetworkData(kClientAddr, NetworkDataMatches(*data))) .Times(1); - RoutingData routingData2( - HeaderForm::Short, false, false, connId, folly::none); + RoutingData routingData2(HeaderForm::Short, false, false, connId, none); worker_->dispatchPacketData( kClientAddr, std::move(routingData2), NetworkData(data->clone(), Clock::now(), 0), - folly::none); + none); eventbase_.loopIgnoreKeepAlive(); auto connId2 = connId; @@ -728,13 +722,12 @@ TEST_F(QuicServerWorkerTest, QuicServerMultipleConnIdsRouting) { EXPECT_CALL( *transport_, onNetworkData(kClientAddr, NetworkDataMatches(*data))) .Times(1); - RoutingData routingData3( - HeaderForm::Short, false, false, connId2, folly::none); + RoutingData routingData3(HeaderForm::Short, false, false, connId2, none); worker_->dispatchPacketData( kClientAddr, std::move(routingData3), NetworkData(data->clone(), Clock::now(), 0), - folly::none); + none); eventbase_.loopIgnoreKeepAlive(); EXPECT_CALL(*transport_, setRoutingCallback(nullptr)); @@ -829,12 +822,12 @@ TEST_F(QuicServerWorkerTest, QuicServerNewConnection) { false, false, shortHeaderConnId.getConnectionId(), - folly::none); + none); worker_->dispatchPacketData( kClientAddr, std::move(routingData), NetworkData(data->clone(), Clock::now(), 0), - folly::none); + none); eventbase_.loopIgnoreKeepAlive(); ConnectionId newConnId = getTestConnectionId(hostId_); @@ -863,12 +856,12 @@ TEST_F(QuicServerWorkerTest, QuicServerNewConnection) { false, false, shortHeaderConnId.getConnectionId(), - folly::none); + none); worker_->dispatchPacketData( kClientAddr, std::move(routingData2), NetworkData(data->clone(), Clock::now(), 0), - folly::none); + none); eventbase_.loopIgnoreKeepAlive(); // routing by address after transport_'s connid available, but before @@ -900,12 +893,12 @@ TEST_F(QuicServerWorkerTest, QuicServerNewConnection) { false, false, shortHeaderConnId2.getConnectionId(), - folly::none); + none); worker_->dispatchPacketData( clientAddr2, std::move(routingData3), NetworkData(data->clone(), Clock::now(), 0), - folly::none); + none); eventbase_.loopIgnoreKeepAlive(); EXPECT_CALL(*transport_, setRoutingCallback(nullptr)).Times(2); @@ -961,7 +954,7 @@ TEST_F(QuicServerWorkerTest, QuicShedTest) { *quicStats_, onPacketDropped( PacketDropReason(PacketDropReason::CANNOT_MAKE_TRANSPORT))); - folly::Optional versionPacket; + Optional versionPacket; EXPECT_CALL(*socketPtr_, write(_, _)) .WillOnce(Invoke([&](const SocketAddress&, const std::unique_ptr& writtenData) { @@ -1436,7 +1429,7 @@ auto createInitialStream( streamData->computeChainDataLength(), streamData->computeChainDataLength(), true, - folly::none /* skipLenHint */); + none /* skipLenHint */); EXPECT_TRUE(dataLen); writeStreamFrameData(builder, std::move(streamData), *dataLen); return packetToBuf(std::move(builder).buildPacket()); @@ -1814,7 +1807,7 @@ void QuicServerWorkerTakeoverTest::testNoPacketForwarding( auto cb = [&](const folly::SocketAddress& addr, std::unique_ptr& /* routingData */, std::unique_ptr& /* networkData */, - folly::Optional /* quicVersion */, + Optional /* quicVersion */, bool isForwardedData) { EXPECT_EQ(addr.getIPAddress(), clientAddr.getIPAddress()); EXPECT_EQ(addr.getPort(), clientAddr.getPort()); @@ -1916,7 +1909,7 @@ void QuicServerWorkerTakeoverTest::testPacketForwarding( auto cb = [&](const folly::SocketAddress& client, std::unique_ptr& routingData, std::unique_ptr& networkData, - folly::Optional quicVersion, + Optional quicVersion, bool isForwardedData) { takeoverWorker_->dispatchPacketData( client, @@ -1981,7 +1974,7 @@ TEST_F(QuicServerWorkerTakeoverTest, QuicServerTakeoverProcessForwardedPkt) { auto cb = [&](const folly::SocketAddress& addr, std::unique_ptr& /* routingData */, std::unique_ptr& networkData, - folly::Optional /* quicVersion */, + Optional /* quicVersion */, bool isForwardedData) { // verify that it is the original client address EXPECT_EQ(addr.getIPAddress(), clientAddr.getIPAddress()); @@ -2002,7 +1995,7 @@ TEST_F(QuicServerWorkerTakeoverTest, QuicServerTakeoverProcessForwardedPkt) { auto workerCb = [&](const folly::SocketAddress& client, std::unique_ptr& routingData, std::unique_ptr& networkData, - folly::Optional quicVersion, + Optional quicVersion, bool isForwardedData) { takeoverWorker_->dispatchPacketData( client, @@ -2915,7 +2908,7 @@ void QuicServerTest::testReset(Buf packet) { auto aead = createNoOpAead(); // Make the decrypt fail EXPECT_CALL(*aead, _tryDecrypt(_, _, _)) - .WillRepeatedly(Invoke([&](auto&, auto, auto) { return folly::none; })); + .WillRepeatedly(Invoke([&](auto&, auto, auto) { return none; })); codec.setOneRttReadCipher(std::move(aead)); codec.setOneRttHeaderCipher(test::createNoOpHeaderCipher()); StatelessResetToken token = generateStatelessResetToken(); diff --git a/quic/server/test/QuicServerTransportTest.cpp b/quic/server/test/QuicServerTransportTest.cpp index d7656953f..522fc217b 100644 --- a/quic/server/test/QuicServerTransportTest.cpp +++ b/quic/server/test/QuicServerTransportTest.cpp @@ -29,7 +29,7 @@ using ByteEvent = QuicTransportBase::ByteEvent; auto constexpr kTestMaxPacingRate = std::numeric_limits::max(); } // namespace -folly::Optional getFrameIfPresent( +Optional getFrameIfPresent( std::vector>& socketWrites, QuicReadCodec& readCodec, QuicFrame::Type frameType) { @@ -48,7 +48,7 @@ folly::Optional getFrameIfPresent( return frame; } } - return folly::none; + return none; } bool verifyFramePresent( @@ -59,7 +59,7 @@ bool verifyFramePresent( } struct MigrationParam { - folly::Optional clientSentActiveConnIdTransportParam; + Optional clientSentActiveConnIdTransportParam; }; class QuicServerTransportTest : public QuicServerTransportAfterStartTestBase { @@ -92,7 +92,7 @@ TEST_F(QuicServerTransportTest, TestReadMultipleStreams) { buf1->computeChainDataLength(), buf1->computeChainDataLength(), true, - folly::none /* skipLenHint */); + none /* skipLenHint */); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, buf1->computeChainDataLength()); writeStreamFrameData(builder, buf1->clone(), buf1->computeChainDataLength()); @@ -104,7 +104,7 @@ TEST_F(QuicServerTransportTest, TestReadMultipleStreams) { buf1->computeChainDataLength(), buf1->computeChainDataLength(), true, - folly::none /* skipLenHint */); + none /* skipLenHint */); ASSERT_TRUE(dataLen); ASSERT_EQ(*dataLen, buf1->computeChainDataLength()); writeStreamFrameData(builder, buf2->clone(), buf2->computeChainDataLength()); @@ -114,13 +114,13 @@ TEST_F(QuicServerTransportTest, TestReadMultipleStreams) { // Clear out the existing acks to make sure that we are the cause of the acks. server->getNonConstConn().ackStates.initialAckState->acks.clear(); server->getNonConstConn().ackStates.initialAckState->largestRecvdPacketTime = - folly::none; + none; server->getNonConstConn().ackStates.handshakeAckState->acks.clear(); server->getNonConstConn() - .ackStates.handshakeAckState->largestRecvdPacketTime = folly::none; + .ackStates.handshakeAckState->largestRecvdPacketTime = none; server->getNonConstConn().ackStates.appDataAckState.acks.clear(); server->getNonConstConn().ackStates.appDataAckState.largestRecvdPacketTime = - folly::none; + none; EXPECT_CALL(*quicStats_, onNewQuicStream()).Times(2); // for x08, x0C deliverData(packetToBuf(packet)); @@ -556,7 +556,7 @@ TEST_F(QuicServerTransportTest, NoDataExceptCloseProcessedAfterClosing) { buf->computeChainDataLength(), buf->computeChainDataLength(), true, - folly::none /* skipLenHint */); + none /* skipLenHint */); writeStreamFrameData(builder, buf->clone(), buf->computeChainDataLength()); std::string errMsg = "Mind the gap"; ConnectionCloseFrame connClose( @@ -768,7 +768,7 @@ TEST_F(QuicServerTransportTest, ReceiveRstStreamNonExistentAndOtherFrame) { data->computeChainDataLength(), data->computeChainDataLength(), false, - folly::none /* skipLenHint */); + none /* skipLenHint */); writeStreamFrameData(builder2, data->clone(), data->computeChainDataLength()); auto packetObject = std::move(builder2).buildPacket(); auto packet2 = packetToBuf(std::move(packetObject)); @@ -1032,7 +1032,7 @@ TEST_F(QuicServerTransportTest, RecvStopSendingFrameAfterHalfCloseRemote) { 0, 10, true, - folly::none /* skipLenHint */); + none /* skipLenHint */); ASSERT_TRUE(dataLen.has_value()); ASSERT_EQ(*dataLen, 0); writeFrame(QuicSimpleFrame(stopSendingFrame), builder); @@ -1126,7 +1126,7 @@ TEST_F(QuicServerTransportTest, RecvStopSendingFrameAfterReset) { EXPECT_CALL( connCallback, onStopSending(_, GenericApplicationErrorCode::UNKNOWN)) .WillOnce(Invoke([&](StreamId /*sid*/, ApplicationErrorCode /*e*/) { - server->close(folly::none); + server->close(none); })); EXPECT_THROW(deliverData(packetToBuf(packet)), std::runtime_error); } @@ -1796,7 +1796,7 @@ INSTANTIATE_TEST_SUITE_P( QuicServerTransportMigrationTests, QuicServerTransportAllowMigrationTest, Values( - MigrationParam{folly::none}, + MigrationParam{none}, MigrationParam{2}, MigrationParam{4}, MigrationParam{9}, @@ -3509,7 +3509,7 @@ TEST_F( data->computeChainDataLength(), data->computeChainDataLength(), /*fin=*/true, - /*skipLenHint=*/folly::none); + /*skipLenHint=*/none); writeStreamFrameData( builder, data->clone(), @@ -3550,7 +3550,7 @@ TEST_F( data->computeChainDataLength(), data->computeChainDataLength(), /*eof=*/true, - /*skipLenHint=*/folly::none); + /*skipLenHint=*/none); writeStreamFrameData( builder, data->clone(), @@ -3591,7 +3591,7 @@ TEST_F( data->computeChainDataLength(), data->computeChainDataLength(), /*eof=*/true, - /*skipLenHint=*/folly::none); + /*skipLenHint=*/none); writeStreamFrameData( builder, data->clone(), @@ -4064,7 +4064,7 @@ TEST_F( EXPECT_CALL(handshakeFinishedCallback, onHandshakeFinished()); recvClientFinished(); loopForWrites(); - EXPECT_EQ(server->getConn().writableBytesLimit, folly::none); + EXPECT_EQ(server->getConn().writableBytesLimit, none); std::vector indices = getQLogEventIndices(QLogEventType::TransportStateUpdate, qLogger); @@ -4447,7 +4447,7 @@ TEST_P( *data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none, + none, false)); deliverData(std::move(packetData)); EXPECT_EQ(server->getConn().streamManager->streamCount(), 0); @@ -4551,7 +4551,7 @@ class QuicServerTransportHandshakeTest void expectWriteNewSessionTicket() override { std::string appParams("APP params"); server->setEarlyDataAppParamsFunctions( - [](const folly::Optional&, const Buf&) { return false; }, + [](const Optional&, const Buf&) { return false; }, [=]() -> Buf { return folly::IOBuf::copyBuffer(appParams); }); EXPECT_CALL(*getFakeHandshakeLayer(), writeNewSessionTicket(_)) .WillOnce(Invoke([=](const AppToken& appToken) { diff --git a/quic/server/test/QuicServerTransportTestUtil.h b/quic/server/test/QuicServerTransportTestUtil.h index ea235eab8..ae8dc8e90 100644 --- a/quic/server/test/QuicServerTransportTestUtil.h +++ b/quic/server/test/QuicServerTransportTestUtil.h @@ -277,9 +277,9 @@ class QuicServerTransportTestBase : public virtual testing::Test { data, 0 /* cipherOverhead */, 0 /* largestAcked */, - folly::none /* longHeaderOverride */, + none /* longHeaderOverride */, eof, - folly::none, + none, offset)); deliverData(packetData->clone()); return packetData; @@ -352,7 +352,7 @@ class QuicServerTransportTestBase : public virtual testing::Test { virtual void expectWriteNewSessionTicket() { server->setEarlyDataAppParamsFunctions( - [](const folly::Optional&, const Buf&) { return false; }, + [](const Optional&, const Buf&) { return false; }, []() -> Buf { return nullptr; }); EXPECT_CALL(*getFakeHandshakeLayer(), writeNewSessionTicket(testing::_)) .Times(1); @@ -587,9 +587,9 @@ class QuicServerTransportTestBase : public virtual testing::Test { testing::NiceMock connCallback; testing::NiceMock routingCallback; testing::NiceMock handshakeFinishedCallback; - folly::Optional clientConnectionId; - folly::Optional initialDestinationConnectionId; - folly::Optional serverConnectionId; + Optional clientConnectionId; + Optional initialDestinationConnectionId; + Optional serverConnectionId; std::unique_ptr clientReadCodec; std::vector serverWrites; std::shared_ptr serverCtx; diff --git a/quic/server/test/ServerStateMachineTest.cpp b/quic/server/test/ServerStateMachineTest.cpp index 4d2d2b829..58abad009 100644 --- a/quic/server/test/ServerStateMachineTest.cpp +++ b/quic/server/test/ServerStateMachineTest.cpp @@ -338,7 +338,7 @@ TEST(ServerStateMachineTest, TestEncodeKnobFrameSupportedParamDisabled) { struct advertisedMaxStreamGroupstestStruct { uint64_t peerMaxGroupsIn; - folly::Optional expectedTransportSettingVal; + Optional expectedTransportSettingVal; }; class ServerStateMachineAdvertisedMaxStreamGroupsParamTest @@ -371,7 +371,7 @@ INSTANTIATE_TEST_SUITE_P( ServerStateMachineAdvertisedMaxStreamGroupsParamTest, ServerStateMachineAdvertisedMaxStreamGroupsParamTest, ::testing::Values( - advertisedMaxStreamGroupstestStruct{0, folly::none}, + advertisedMaxStreamGroupstestStruct{0, none}, advertisedMaxStreamGroupstestStruct{16, 16})); } // namespace test diff --git a/quic/state/AckEvent.cpp b/quic/state/AckEvent.cpp index 5aa4606ae..fc7001374 100644 --- a/quic/state/AckEvent.cpp +++ b/quic/state/AckEvent.cpp @@ -50,10 +50,10 @@ AckEvent::AckPacket::AckPacket( uint64_t nonDsrPacketSequenceNumberIn, const OutstandingPacketMetadata& outstandingPacketMetadataIn, // NOLINT const DetailsPerStream& detailsPerStreamIn, // NOLINT - folly::Optional + Optional lastAckedPacketInfoIn, bool isAppLimitedIn, - folly::Optional&& receiveRelativeTimeStampUsec) + Optional&& receiveRelativeTimeStampUsec) : packetNum(packetNumIn), nonDsrPacketSequenceNumber(nonDsrPacketSequenceNumberIn), outstandingPacketMetadata(outstandingPacketMetadataIn), // NOLINT @@ -104,7 +104,7 @@ AckEvent::AckPacket::Builder&& AckEvent::AckPacket::Builder::setAppLimited( AckEvent::AckPacket::Builder&& AckEvent::AckPacket::Builder::setReceiveDeltaTimeStamp( - folly::Optional&& receiveTimeStampIn) { + Optional&& receiveTimeStampIn) { receiveRelativeTimeStampUsec = receiveTimeStampIn; return std::move(*this); } @@ -118,10 +118,9 @@ AckEvent::AckPacket AckEvent::AckPacket::Builder::build() && { nonDsrPacketSequenceNumber.value(), *outstandingPacketMetadata, detailsPerStream.value(), - lastAckedPacketInfo - ? folly::Optional( - *lastAckedPacketInfo) - : folly::none, + lastAckedPacketInfo ? Optional( + *lastAckedPacketInfo) + : none, isAppLimited, std::move(receiveRelativeTimeStampUsec)); } diff --git a/quic/state/AckEvent.h b/quic/state/AckEvent.h index d0a47fea8..f9be00ba9 100644 --- a/quic/state/AckEvent.h +++ b/quic/state/AckEvent.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include #include @@ -117,7 +117,7 @@ struct AckEvent { // the reason that this is an optional type is that we construct an // AckEvent first, then go through the acked packets that are still // outstanding and figure out the largest newly acked packet along the way. - folly::Optional largestNewlyAckedPacket; + Optional largestNewlyAckedPacket; // when largestNewlyAckedPacket was sent TimePoint largestNewlyAckedPacketSentTime; @@ -125,17 +125,17 @@ struct AckEvent { // RTT sample with ack delay included. // // not available if largestAckedPacket already acked or declared lost - folly::Optional rttSample; + Optional rttSample; // RTT sample with ack delay removed. // // not available if largestAckedPacket already acked or declared lost - folly::Optional rttSampleNoAckDelay; + Optional rttSampleNoAckDelay; // Congestion controller state after processing of AckEvent. // // Optional to handle cases where congestion controller not used. - folly::Optional ccState; + Optional ccState; /** * Booleans grouped together to avoid padding. @@ -159,7 +159,7 @@ struct AckEvent { OutstandingPacketMetadata outstandingPacketMetadata; struct StreamDetails { - folly::Optional streamPacketIdx; + Optional streamPacketIdx; // definition for DupAckedStreamIntervalSet // we expect this to be rare, any thus only allocate a single position @@ -244,11 +244,10 @@ struct AckEvent { // LastAckedPacketInfo from this acked packet'r original sent // OutstandingPacketWrapper structure. - folly::Optional - lastAckedPacketInfo; + Optional lastAckedPacketInfo; // Delta RX Timestamp of the current packet relative to the previous packet // (or connection start time). - folly::Optional receiveRelativeTimeStampUsec; + Optional receiveRelativeTimeStampUsec; // Whether this packet was sent when CongestionController is in // app-limited state. @@ -265,19 +264,18 @@ struct AckEvent { OutstandingPacketWrapper::LastAckedPacketInfo* lastAckedPacketInfoIn); Builder&& setAppLimited(bool appLimitedIn); Builder&& setReceiveDeltaTimeStamp( - folly::Optional&& - receiveRelativeTimeStampUsec); + Optional&& receiveRelativeTimeStampUsec); AckPacket build() &&; explicit Builder() = default; private: - folly::Optional packetNum; - folly::Optional nonDsrPacketSequenceNumber; + Optional packetNum; + Optional nonDsrPacketSequenceNumber; OutstandingPacketMetadata* outstandingPacketMetadata{nullptr}; - folly::Optional detailsPerStream; + Optional detailsPerStream; OutstandingPacketWrapper::LastAckedPacketInfo* lastAckedPacketInfo{ nullptr}; - folly::Optional receiveRelativeTimeStampUsec; + Optional receiveRelativeTimeStampUsec; bool isAppLimited{false}; }; @@ -287,22 +285,21 @@ struct AckEvent { uint64_t nonDsrPacketSequenceNumberIn, const OutstandingPacketMetadata& outstandingPacketMetadataIn, // NOLINT const DetailsPerStream& detailsPerStreamIn, // NOLINT - folly::Optional + Optional lastAckedPacketInfoIn, bool isAppLimitedIn, - folly::Optional&& - receiveRelativeTimeStampUsec); + Optional&& receiveRelativeTimeStampUsec); }; // Information about each packet ACKed during this event std::vector ackedPackets; struct BuilderFields { - folly::Optional maybeAckTime; - folly::Optional maybeAdjustedAckTime; - folly::Optional maybeAckDelay; - folly::Optional maybePacketNumberSpace; - folly::Optional maybeLargestAckedPacket; + Optional maybeAckTime; + Optional maybeAdjustedAckTime; + Optional maybeAckDelay; + Optional maybePacketNumberSpace; + Optional maybeLargestAckedPacket; bool isImplicitAck{false}; uint32_t ecnECT0Count{0}; uint32_t ecnECT1Count{0}; diff --git a/quic/state/AckHandlers.cpp b/quic/state/AckHandlers.cpp index ee7299276..d55dbc233 100644 --- a/quic/state/AckHandlers.cpp +++ b/quic/state/AckHandlers.cpp @@ -156,15 +156,15 @@ AckEvent processAckFrame( // Store first outstanding packet number to ignore old receive timestamps. const auto& firstOutstandingPacket = getFirstOutstandingPacket(conn, PacketNumberSpace::AppData); - folly::Optional firstPacketNum = + Optional firstPacketNum = (firstOutstandingPacket != conn.outstandings.packets.end()) ? folly::make_optional(firstOutstandingPacket->getPacketSequenceNum()) - : folly::none; + : none; uint64_t dsrPacketsAcked = 0; - folly::Optional + Optional lastAckedPacketSentTime; - folly::Optional spuriousLossEvent; + Optional spuriousLossEvent; // Used for debug only. const auto originalPacketCount = conn.outstandings.packetCount; const auto originalNumOutstanding = conn.outstandings.numOutstanding(); @@ -338,7 +338,7 @@ AckEvent processAckFrame( ? folly::make_optional( std::chrono::ceil( rttSample - frame.ackDelay)) - : folly::none; + : none; // update transport RTT updateRtt(conn, rttSample, frame.ackDelay); @@ -440,15 +440,15 @@ AckEvent processAckFrame( // Part 1: Record delivery offset prior to running ackVisitor. struct PreAckVisitorState { const uint64_t ackIntervalSetVersion; - const folly::Optional maybeLargestDeliverableOffset; + const Optional maybeLargestDeliverableOffset; }; QuicStreamState* maybeAckedStreamState = nullptr; const auto maybePreAckVisitorState = [&conn, &maybeAckedStreamState]( - const auto& packetFrame) -> folly::Optional { + const auto& packetFrame) -> Optional { // check if it's a WriteStreamFrame being ACKed if (packetFrame.type() != QuicWriteFrame::Type::WriteStreamFrame) { - return folly::none; + return none; } // check if the stream is alive (could be ACK for dead stream) @@ -456,7 +456,7 @@ AckEvent processAckFrame( maybeAckedStreamState = conn.streamManager->findStream(ackedFrame.streamId); if (!maybeAckedStreamState) { - return folly::none; + return none; } // stream is alive and frame is WriteStreamFrame @@ -510,7 +510,7 @@ AckEvent processAckFrame( maybeRxTimestamp != packetReceiveTimeStamps.end() ? folly::make_optional( std::chrono::microseconds(maybeRxTimestamp->second)) - : folly::none) + : none) .build()); } if (lastAckedPacketSentTime) { @@ -550,8 +550,9 @@ AckEvent processAckFrame( // congestion period. Alternatively we could consider every lost block // and check if any of them constitute persistent congestion. lossEvent->persistentCongestion = isPersistentCongestion( - conn.lossState.srtt == 0s ? folly::none - : folly::Optional(calculatePTO(conn)), + conn.lossState.srtt == 0s + ? none + : Optional(calculatePTO(conn)), *lossEvent->smallestLostSentTime, *lossEvent->largestLostSentTime, ack); @@ -631,7 +632,7 @@ void parseAckReceiveTimestamps( const QuicConnectionStateBase& conn, const quic::ReadAckFrame& frame, folly::F14FastMap& packetReceiveTimeStamps, - folly::Optional firstPacketNum) { + Optional firstPacketNum) { if (frame.frameType != FrameType::ACK_RECEIVE_TIMESTAMPS) { return; } diff --git a/quic/state/AckHandlers.h b/quic/state/AckHandlers.h index 8b37988cd..1ba509a42 100644 --- a/quic/state/AckHandlers.h +++ b/quic/state/AckHandlers.h @@ -75,7 +75,7 @@ void parseAckReceiveTimestamps( const QuicConnectionStateBase& conn, const quic::ReadAckFrame& frame, folly::F14FastMap& packetReceiveTimeStamps, - folly::Optional firstPacketNum); + Optional firstPacketNum); /** * Update the outgoing ECN marking count for an outstanding packet that has been diff --git a/quic/state/AckStates.h b/quic/state/AckStates.h index a6c84fac6..346c90494 100644 --- a/quic/state/AckStates.h +++ b/quic/state/AckStates.h @@ -17,26 +17,26 @@ namespace quic { // Ack and PacketNumber states. This is per-packet number space. struct AckState : WriteAckFrameState { // Largest ack that has been written to a packet - folly::Optional largestAckScheduled; + Optional largestAckScheduled; // Count of outstanding packets received with only non-retransmittable data. uint64_t numNonRxPacketsRecvd{0}; // The receive time of the largest ack packet - folly::Optional largestRecvdPacketTime; + Optional largestRecvdPacketTime; // Largest received packet numbers on the connection. - folly::Optional largestRecvdPacketNum; + Optional largestRecvdPacketNum; // Latest packet number acked by peer - folly::Optional largestAckedByPeer; + Optional largestAckedByPeer; // Largest received packet number at the time we sent our last close message. - folly::Optional largestReceivedAtLastCloseSent; + Optional largestReceivedAtLastCloseSent; // Packet sequence number for largest non-dsr packet acked by peer. - folly::Optional largestNonDsrSequenceNumberAckedByPeer; + Optional largestNonDsrSequenceNumberAckedByPeer; // Next PacketNum we will send for packet in this packet number space PacketNum nextPacketNum{0}; // Incremented for each non-DSR packet. uint64_t nonDsrPacketSequenceNumber{0}; uint64_t reorderThreshold{0}; - folly::Optional tolerance; - folly::Optional ackFrequencySequenceNumber; + Optional tolerance; + Optional ackFrequencySequenceNumber; // Flag indicating that if we need to send ack immediately. This will be set // to true in either of the following cases: // - we got packets with retransmittable data and haven't sent the diff --git a/quic/state/BUCK b/quic/state/BUCK index 9b0890265..8382de7ee 100644 --- a/quic/state/BUCK +++ b/quic/state/BUCK @@ -33,8 +33,8 @@ mvfst_cpp_library( ], exported_deps = [ ":quic_priority_queue", - "//folly:optional", "//quic:constants", + "//quic/common:optional", ], ) @@ -120,7 +120,6 @@ mvfst_cpp_library( ":retransmission_policy", ":stats_callback", ":transport_settings", - "//folly:optional", "//folly/container:f14_hash", "//folly/io:iobuf", "//folly/io/async:delayed_destruction", @@ -129,6 +128,7 @@ mvfst_cpp_library( "//quic/codec:types", "//quic/common:buf_accessor", "//quic/common:circular_deque", + "//quic/common:optional", "//quic/common:small_collections", "//quic/congestion_control:congestion_controller", "//quic/congestion_control:packet_processor", @@ -211,10 +211,10 @@ mvfst_cpp_library( "QuicTransportStatsCallback.h", ], exported_deps = [ - "//folly:optional", "//folly/functional:invoke", "//quic:constants", "//quic:exception", + "//quic/common:optional", ], ) @@ -292,8 +292,8 @@ mvfst_cpp_library( ], exported_deps = [ ":outstanding_packet", - "//folly:optional", "//quic/codec:types", + "//quic/common:optional", "//quic/common:small_collections", "//quic/congestion_control:congestion_controller", ], diff --git a/quic/state/LossState.h b/quic/state/LossState.h index 8f5077085..5b2b299bf 100644 --- a/quic/state/LossState.h +++ b/quic/state/LossState.h @@ -16,19 +16,19 @@ struct LossState { enum class AlarmMethod { EarlyRetransmitOrReordering, PTO }; // Latest packet number sent // TODO: this also needs to be 3 numbers now... - folly::Optional largestSent; + Optional largestSent; // Timer for time reordering detection or early retransmit alarm. - EnumArray> lossTimes; + EnumArray> lossTimes; // Max ack delay received from peer. std::chrono::microseconds maxAckDelay{0us}; // minimum rtt. AckDelay isn't excluded from this. std::chrono::microseconds mrtt{kDefaultMinRtt}; // minimum rtt measured from samples with AckDelay excluded. - folly::Optional maybeMrttNoAckDelay; + Optional maybeMrttNoAckDelay; // Last raw RTT value; unlike lrtt, this will always contain any ACK delay. - folly::Optional maybeLrtt; + Optional maybeLrtt; // Last raw ACK delay value. - folly::Optional maybeLrttAckDelay; + Optional maybeLrttAckDelay; // Smooth rtt. std::chrono::microseconds srtt{0us}; // Latest rtt. @@ -36,16 +36,16 @@ struct LossState { // Rtt var. std::chrono::microseconds rttvar{0us}; // The sent time of the latest acked packet. - folly::Optional lastAckedPacketSentTime; + Optional lastAckedPacketSentTime; // The latest time a packet is acked. - folly::Optional lastAckedTime; + Optional lastAckedTime; // The latest time a packet is acked, minus ack delay. - folly::Optional adjustedLastAckedTime; + Optional adjustedLastAckedTime; // The time when last retranmittable packet is sent for every packet number. // space TimePoint lastRetransmittablePacketSentTime; // The time when the last packet was sent. - folly::Optional maybeLastPacketSentTime; + Optional maybeLastPacketSentTime; // Total number of bytes sent on this connection. This is after encoding. uint64_t totalBytesSent{0}; // Total number of bytes received on this connection. This is before decoding. diff --git a/quic/state/OutstandingPacket.h b/quic/state/OutstandingPacket.h index bf20b2a4a..fffa82be0 100644 --- a/quic/state/OutstandingPacket.h +++ b/quic/state/OutstandingPacket.h @@ -36,7 +36,7 @@ struct OutstandingPacketMetadata { // Has value if the packet is lost by timeout. The value is the loss timeout // dividend that was used to declare this packet. - folly::Optional lossTimeoutDividend; + Optional lossTimeoutDividend; // Has value if the packet is lost by reorder. The value is the distance // between this packet and the acknowleded packet when it was declared lost @@ -49,7 +49,7 @@ struct OutstandingPacketMetadata { uint64_t streamBytesSent{0}; uint64_t newStreamBytesSent{0}; - folly::Optional maybeFirstNewStreamByteOffset; + Optional maybeFirstNewStreamByteOffset; }; using MapType = InlineMap; @@ -102,7 +102,7 @@ struct OutstandingPacketMetadata { // was sent. std::chrono::microseconds totalAppLimitedTimeUsecs{0}; - folly::Optional lossReorderDistance; + Optional lossReorderDistance; // Bytes in flight on this connection including this packet itself when this // packet is sent. @@ -172,13 +172,13 @@ struct OutstandingPacket { totalBytesSent(totalBytesSentIn), totalBytesAcked(totalBytesAckedIn) {} }; - folly::Optional lastAckedPacketInfo; + Optional lastAckedPacketInfo; // PacketEvent associated with this OutstandingPacketWrapper. This will be a - // folly::none if the packet isn't a clone and hasn't been cloned. - folly::Optional associatedEvent; + // none if the packet isn't a clone and hasn't been cloned. + Optional associatedEvent; - folly::Optional nonDsrPacketSequenceNumber; + Optional nonDsrPacketSequenceNumber; // Whether this is a DSR packet. A DSR packet's stream data isn't written // by transport directly. diff --git a/quic/state/PendingPathRateLimiter.h b/quic/state/PendingPathRateLimiter.h index adc0d33c3..6d13882c6 100644 --- a/quic/state/PendingPathRateLimiter.h +++ b/quic/state/PendingPathRateLimiter.h @@ -6,8 +6,8 @@ */ #pragma once -#include #include +#include #include namespace quic { @@ -35,7 +35,7 @@ class PendingPathRateLimiter { private: const uint64_t maxCredit_; uint64_t credit_; - folly::Optional lastChecked_; + Optional lastChecked_; }; } // namespace quic diff --git a/quic/state/QuicStateFunctions.cpp b/quic/state/QuicStateFunctions.cpp index ddbd552db..02c0177b9 100644 --- a/quic/state/QuicStateFunctions.cpp +++ b/quic/state/QuicStateFunctions.cpp @@ -353,7 +353,7 @@ bool hasReceivedUdpPackets(const QuicConnectionStateBase& conn) noexcept { appDataAckState.largestRecvdPacketNum; } -folly::Optional& getLossTime( +Optional& getLossTime( QuicConnectionStateBase& conn, PacketNumberSpace pnSpace) noexcept { return conn.lossState.lossTimes[pnSpace]; @@ -363,17 +363,17 @@ bool canSetLossTimerForAppData(const QuicConnectionStateBase& conn) noexcept { return conn.oneRttWriteCipher != nullptr; } -std::pair, PacketNumberSpace> earliestLossTimer( +std::pair, PacketNumberSpace> earliestLossTimer( const QuicConnectionStateBase& conn) noexcept { bool considerAppData = canSetLossTimerForAppData(conn); return earliestTimeAndSpace(conn.lossState.lossTimes, considerAppData); } -std::pair, PacketNumberSpace> earliestTimeAndSpace( - const EnumArray>& times, +std::pair, PacketNumberSpace> earliestTimeAndSpace( + const EnumArray>& times, bool considerAppData) noexcept { - std::pair, PacketNumberSpace> res = { - folly::none, PacketNumberSpace::Initial}; + std::pair, PacketNumberSpace> res = { + none, PacketNumberSpace::Initial}; for (PacketNumberSpace pns : times.keys()) { if (!times[pns]) { continue; diff --git a/quic/state/QuicStateFunctions.h b/quic/state/QuicStateFunctions.h index 6114a26d9..ca9654b79 100644 --- a/quic/state/QuicStateFunctions.h +++ b/quic/state/QuicStateFunctions.h @@ -96,17 +96,17 @@ bool hasNotReceivedNewPacketsSinceLastCloseSent( void updateLargestReceivedUdpPacketsAtLastCloseSent( QuicConnectionStateBase& conn) noexcept; -folly::Optional& getLossTime( +Optional& getLossTime( QuicConnectionStateBase& conn, PacketNumberSpace pnSpace) noexcept; bool canSetLossTimerForAppData(const QuicConnectionStateBase& conn) noexcept; -std::pair, PacketNumberSpace> earliestLossTimer( +std::pair, PacketNumberSpace> earliestLossTimer( const QuicConnectionStateBase& conn) noexcept; -std::pair, PacketNumberSpace> earliestTimeAndSpace( - const EnumArray>& times, +std::pair, PacketNumberSpace> earliestTimeAndSpace( + const EnumArray>& times, bool considerAppData) noexcept; uint64_t maximumConnectionIdsToIssue(const QuicConnectionStateBase& conn); diff --git a/quic/state/QuicStreamFunctions.cpp b/quic/state/QuicStreamFunctions.cpp index 74db90566..9f552a684 100644 --- a/quic/state/QuicStreamFunctions.cpp +++ b/quic/state/QuicStreamFunctions.cpp @@ -95,7 +95,7 @@ void appendDataToReadBufferCommon( auto bufferEndOffset = buffer.offset + buffer.data.chainLength(); - folly::Optional bufferEofOffset; + Optional bufferEofOffset; if (buffer.eof) { bufferEofOffset = bufferEndOffset; } else if (buffer.data.chainLength() == 0) { @@ -151,8 +151,8 @@ void appendDataToReadBufferCommon( // Start overlap will point to the first buffer that overlaps with the // current buffer and End overlap will point to the last buffer that overlaps. // They must always be set together. - folly::Optional startOverlap; - folly::Optional endOverlap; + Optional startOverlap; + Optional endOverlap; StreamBuffer* current = &buffer; bool currentAlreadyInserted = false; @@ -430,26 +430,24 @@ uint64_t getLargestWriteOffsetSeen(const QuicStreamState& stream) { stream.writeBufMeta.offset + stream.writeBufMeta.length)); } -folly::Optional getLargestWriteOffsetTxed( - const QuicStreamState& stream) { +Optional getLargestWriteOffsetTxed(const QuicStreamState& stream) { // currentWriteOffset is really nextWriteOffset // when 0, it indicates nothing has been written yet if (stream.currentWriteOffset == 0 && stream.writeBufMeta.offset == 0) { - return folly::none; + return none; } uint64_t currentWriteOffset = std::max(stream.currentWriteOffset, stream.writeBufMeta.offset); return currentWriteOffset - 1; } -folly::Optional getLargestDeliverableOffset( - const QuicStreamState& stream) { +Optional getLargestDeliverableOffset(const QuicStreamState& stream) { // If the acked intervals is not empty, then the furthest acked interval // starting at zero is the next offset. If there is no interval starting at // zero then we cannot deliver any offsets. if (stream.ackedIntervals.empty() || stream.ackedIntervals.front().start != 0) { - return folly::none; + return none; } return stream.ackedIntervals.front().end; } diff --git a/quic/state/QuicStreamFunctions.h b/quic/state/QuicStreamFunctions.h index 63a78f767..1e6aeef0c 100644 --- a/quic/state/QuicStreamFunctions.h +++ b/quic/state/QuicStreamFunctions.h @@ -105,17 +105,15 @@ uint64_t getLargestWriteOffsetSeen(const QuicStreamState& stream); /** * Get the largest write offset the stream has transmitted / written to socket. * - * If no bytes have been written to the socket yet, returns folly::none. + * If no bytes have been written to the socket yet, returns none. */ -folly::Optional getLargestWriteOffsetTxed( - const QuicStreamState& stream); +Optional getLargestWriteOffsetTxed(const QuicStreamState& stream); /** * Get the the highest acked offset (if any) that we can execute delivery * callbacks on. */ -folly::Optional getLargestDeliverableOffset( - const QuicStreamState& stream); +Optional getLargestDeliverableOffset(const QuicStreamState& stream); /** * Get the version associated with the stream's ACK IntervalSet. diff --git a/quic/state/QuicStreamManager.cpp b/quic/state/QuicStreamManager.cpp index c67f68414..170fa9a06 100644 --- a/quic/state/QuicStreamManager.cpp +++ b/quic/state/QuicStreamManager.cpp @@ -281,7 +281,7 @@ QuicStreamManager::getOrCreateOpenedLocalStream(StreamId streamId) { QuicStreamState* QuicStreamManager::getStream( StreamId streamId, - folly::Optional streamGroupId) { + Optional streamGroupId) { if (isRemoteStream(nodeType_, streamId)) { auto stream = getOrCreatePeerStream(streamId, std::move(streamGroupId)); updateAppIdleState(); @@ -306,7 +306,7 @@ QuicStreamState* QuicStreamManager::getStream( folly::Expected QuicStreamManager::createNextBidirectionalStream( - folly::Optional streamGroupId) { + Optional streamGroupId) { auto stream = createStream(nextBidirectionalStreamId_, std::move(streamGroupId)); if (stream.hasValue()) { @@ -323,7 +323,7 @@ QuicStreamManager::createNextBidirectionalStreamGroup() { folly::Expected QuicStreamManager::createNextUnidirectionalStream( - folly::Optional streamGroupId) { + Optional streamGroupId) { auto stream = createStream(nextUnidirectionalStreamId_, std::move(streamGroupId)); if (stream.hasValue()) { @@ -334,7 +334,7 @@ QuicStreamManager::createNextUnidirectionalStream( QuicStreamState* FOLLY_NULLABLE QuicStreamManager::instantiatePeerStream( StreamId streamId, - folly::Optional groupId) { + Optional groupId) { if (groupId) { auto& seenSet = isUnidirectionalStream(streamId) ? peerUnidirectionalStreamGroupsSeen_ @@ -388,7 +388,7 @@ QuicStreamManager::createNextStreamGroup( QuicStreamState* FOLLY_NULLABLE QuicStreamManager::getOrCreatePeerStream( StreamId streamId, - folly::Optional streamGroupId) { + Optional streamGroupId) { // This function maintains 3 invariants: // 1. Streams below nextAcceptableStreamId are streams that have been // seen before. Everything above can be opened. @@ -485,7 +485,7 @@ QuicStreamState* FOLLY_NULLABLE QuicStreamManager::getOrCreatePeerStream( folly::Expected QuicStreamManager::createStream( StreamId streamId, - folly::Optional streamGroupId) { + Optional streamGroupId) { if (nodeType_ == QuicNodeType::Client && !isClientStream(streamId)) { throw QuicTransportException( "Attempted creating non-client stream on client", diff --git a/quic/state/QuicStreamManager.h b/quic/state/QuicStreamManager.h index 297bc13c5..2bd680534 100644 --- a/quic/state/QuicStreamManager.h +++ b/quic/state/QuicStreamManager.h @@ -236,7 +236,7 @@ class QuicStreamManager { */ folly::Expected createStream( StreamId streamId, - folly::Optional streamGroupId = folly::none); + Optional streamGroupId = none); /* * Create a new bidirectional stream group. @@ -248,8 +248,7 @@ class QuicStreamManager { * Create and return the state for the next available bidirectional stream. */ folly::Expected - createNextBidirectionalStream( - folly::Optional streamGroupId = folly::none); + createNextBidirectionalStream(Optional streamGroupId = none); /* * Create a new unidirectional stream group. @@ -261,16 +260,14 @@ class QuicStreamManager { * Create and return the state for the next available unidirectional stream. */ folly::Expected - createNextUnidirectionalStream( - folly::Optional streamGroupId = folly::none); + createNextUnidirectionalStream(Optional streamGroupId = none); /* * Return the stream state or create it if the state has not yet been created. * Note that this is only valid for streams that are currently open. */ - QuicStreamState* FOLLY_NULLABLE getStream( - StreamId streamId, - folly::Optional streamGroupId = folly::none); + QuicStreamState* FOLLY_NULLABLE + getStream(StreamId streamId, Optional streamGroupId = none); /* * Remove all the state for a stream that is being closed. @@ -348,12 +345,12 @@ class QuicStreamManager { * * If the maximum has been reached, empty optional returned. */ - folly::Optional nextAcceptablePeerBidirectionalStreamId() { + Optional nextAcceptablePeerBidirectionalStreamId() { const auto max = maxRemoteBidirectionalStreamId_; const auto next = nextAcceptablePeerBidirectionalStreamId_; CHECK_GE(max, next); if (max == next) { - return folly::none; + return none; } return next; } @@ -363,12 +360,12 @@ class QuicStreamManager { * * If the maximum has been reached, empty optional returned. */ - folly::Optional nextAcceptablePeerUnidirectionalStreamId() { + Optional nextAcceptablePeerUnidirectionalStreamId() { const auto max = maxRemoteUnidirectionalStreamId_; const auto next = nextAcceptablePeerUnidirectionalStreamId_; CHECK_GE(max, next); if (max == next) { - return folly::none; + return none; } return next; } @@ -378,12 +375,12 @@ class QuicStreamManager { * * If the maximum has been reached, empty optional returned. */ - folly::Optional nextAcceptableLocalBidirectionalStreamId() { + Optional nextAcceptableLocalBidirectionalStreamId() { const auto max = maxLocalBidirectionalStreamId_; const auto next = nextAcceptableLocalBidirectionalStreamId_; CHECK_GE(max, next); if (max == next) { - return folly::none; + return none; } return next; } @@ -393,12 +390,12 @@ class QuicStreamManager { * * If the maximum has been reached, empty optional returned. */ - folly::Optional nextAcceptableLocalUnidirectionalStreamId() { + Optional nextAcceptableLocalUnidirectionalStreamId() { const auto max = maxLocalUnidirectionalStreamId_; const auto next = nextAcceptableLocalUnidirectionalStreamId_; CHECK_GE(max, next); if (max == next) { - return folly::none; + return none; } return next; } @@ -626,7 +623,7 @@ class QuicStreamManager { * if any. This is potentially updated every time a bidirectional stream is * closed. Calling this function "consumes" the update. */ - folly::Optional remoteBidirectionalStreamLimitUpdate() { + Optional remoteBidirectionalStreamLimitUpdate() { auto ret = remoteBidirectionalStreamLimitUpdate_; remoteBidirectionalStreamLimitUpdate_.reset(); return ret; @@ -637,7 +634,7 @@ class QuicStreamManager { * if any. This is potentially updated every time a unidirectional stream is * closed. Calling this function "consumes" the update. */ - folly::Optional remoteUnidirectionalStreamLimitUpdate() { + Optional remoteUnidirectionalStreamLimitUpdate() { auto ret = remoteUnidirectionalStreamLimitUpdate_; remoteUnidirectionalStreamLimitUpdate_.reset(); return ret; @@ -718,10 +715,10 @@ class QuicStreamManager { /* * Pop a deliverable stream id and return it. */ - folly::Optional popDeliverable() { + Optional popDeliverable() { auto itr = deliverableStreams_.begin(); if (itr == deliverableStreams_.end()) { - return folly::none; + return none; } StreamId ret = *itr; deliverableStreams_.erase(itr); @@ -766,10 +763,10 @@ class QuicStreamManager { /* * Pop a TX stream id and return it. */ - folly::Optional popTx() { + Optional popTx() { auto itr = txStreams_.begin(); if (itr == txStreams_.end()) { - return folly::none; + return none; } else { StreamId ret = *itr; txStreams_.erase(itr); @@ -835,10 +832,10 @@ class QuicStreamManager { /* * Pop and return a stream which has had its flow control updated. */ - folly::Optional popFlowControlUpdated() { + Optional popFlowControlUpdated() { auto itr = flowControlUpdated_.begin(); if (itr == flowControlUpdated_.end()) { - return folly::none; + return none; } else { StreamId ret = *itr; flowControlUpdated_.erase(itr); @@ -1061,7 +1058,7 @@ class QuicStreamManager { QuicStreamState* FOLLY_NULLABLE getOrCreatePeerStream( StreamId streamId, - folly::Optional streamGroupId = folly::none); + Optional streamGroupId = none); void setMaxRemoteBidirectionalStreamsInternal( uint64_t maxStreams, @@ -1074,9 +1071,8 @@ class QuicStreamManager { void notifyStreamPriorityChanges(); // helper to create a new peer stream. - QuicStreamState* FOLLY_NULLABLE instantiatePeerStream( - StreamId streamId, - folly::Optional groupId); + QuicStreamState* FOLLY_NULLABLE + instantiatePeerStream(StreamId streamId, Optional groupId); folly::Expected createNextStreamGroup( StreamGroupId& groupId, @@ -1135,11 +1131,11 @@ class QuicStreamManager { // Contains the value of a stream window update that should be sent for // remote bidirectional streams. - folly::Optional remoteBidirectionalStreamLimitUpdate_; + Optional remoteBidirectionalStreamLimitUpdate_; // Contains the value of a stream window update that should be sent for // remote bidirectional streams. - folly::Optional remoteUnidirectionalStreamLimitUpdate_; + Optional remoteUnidirectionalStreamLimitUpdate_; uint64_t numControlStreams_{0}; diff --git a/quic/state/QuicTransportStatsCallback.h b/quic/state/QuicTransportStatsCallback.h index 97ea372b1..6d9b6a987 100644 --- a/quic/state/QuicTransportStatsCallback.h +++ b/quic/state/QuicTransportStatsCallback.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include @@ -102,8 +102,7 @@ class QuicTransportStatsCallback { // connection level metrics: virtual void onNewConnection() = 0; - virtual void onConnectionClose( - folly::Optional code = folly::none) = 0; + virtual void onConnectionClose(Optional code = none) = 0; virtual void onConnectionCloseZeroBytesWritten() = 0; diff --git a/quic/state/SimpleFrameFunctions.cpp b/quic/state/SimpleFrameFunctions.cpp index 85d2f7575..be89c93ff 100644 --- a/quic/state/SimpleFrameFunctions.cpp +++ b/quic/state/SimpleFrameFunctions.cpp @@ -16,14 +16,14 @@ void sendSimpleFrame(QuicConnectionStateBase& conn, QuicSimpleFrame frame) { conn.pendingEvents.frames.emplace_back(std::move(frame)); } -folly::Optional updateSimpleFrameOnPacketClone( +Optional updateSimpleFrameOnPacketClone( QuicConnectionStateBase& conn, const QuicSimpleFrame& frame) { switch (frame.type()) { case QuicSimpleFrame::Type::StopSendingFrame: if (!conn.streamManager->streamExists( frame.asStopSendingFrame()->streamId)) { - return folly::none; + return none; } return QuicSimpleFrame(frame); case QuicSimpleFrame::Type::PathChallengeFrame: @@ -31,7 +31,7 @@ folly::Optional updateSimpleFrameOnPacketClone( // or a different path validation was scheduled if (!conn.outstandingPathValidation || *frame.asPathChallengeFrame() != *conn.outstandingPathValidation) { - return folly::none; + return none; } return QuicSimpleFrame(frame); case QuicSimpleFrame::Type::PathResponseFrame: diff --git a/quic/state/SimpleFrameFunctions.h b/quic/state/SimpleFrameFunctions.h index 16637f760..ba463fefd 100644 --- a/quic/state/SimpleFrameFunctions.h +++ b/quic/state/SimpleFrameFunctions.h @@ -21,7 +21,7 @@ void sendSimpleFrame(QuicConnectionStateBase& conn, QuicSimpleFrame frame); * Update connection state and the frame on clone of the given simple frame. * Returns the updated simple frame. */ -folly::Optional updateSimpleFrameOnPacketClone( +Optional updateSimpleFrameOnPacketClone( QuicConnectionStateBase& conn, const QuicSimpleFrame& frame); diff --git a/quic/state/StateData.cpp b/quic/state/StateData.cpp index c6f279840..cc21098e9 100644 --- a/quic/state/StateData.cpp +++ b/quic/state/StateData.cpp @@ -45,7 +45,7 @@ QuicStreamState::QuicStreamState(StreamId idIn, QuicConnectionStateBase& connIn) QuicStreamState::QuicStreamState( StreamId idIn, - const folly::Optional& groupIdIn, + const Optional& groupIdIn, QuicConnectionStateBase& connIn) : QuicStreamState(idIn, connIn) { groupId = groupIdIn; diff --git a/quic/state/StateData.h b/quic/state/StateData.h index 6f11e0478..2504ee693 100644 --- a/quic/state/StateData.h +++ b/quic/state/StateData.h @@ -33,9 +33,9 @@ #include #include -#include #include #include +#include #include #include @@ -333,7 +333,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { // When server receives early data attempt without valid source address token, // server will limit bytes in flight to avoid amplification attack. // This limit should be cleared and set back to max after CFIN is received. - folly::Optional writableBytesLimit; + Optional writableBytesLimit; std::unique_ptr pathValidationLimiter; @@ -365,7 +365,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { // current (updated) phase. The peer must acknowledge this packet in the same // phase, responding in a different phase is a protocol violation. Once the // packet is acked, this value will be cleared. - folly::Optional oneRttWritePendingVerificationPacketNumber; + Optional oneRttWritePendingVerificationPacketNumber; // Write cipher for packets with initial keys. std::unique_ptr initialWriteCipher; @@ -381,13 +381,13 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { uint64_t peerActiveConnectionIdLimit{0}; // The destination connection id used in client's initial packet. - folly::Optional clientChosenDestConnectionId; + Optional clientChosenDestConnectionId; // The source connection id used in client's initial packet. - folly::Optional clientConnectionId; + Optional clientConnectionId; // The current server chosen connection id. - folly::Optional serverConnectionId; + Optional serverConnectionId; // Connection ids issued by self. std::vector selfConnectionIds; @@ -396,18 +396,18 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { std::vector peerConnectionIds; // Connection ids to be unbinded soon (server only) - folly::Optional> connIdsRetiringSoon; + Optional> connIdsRetiringSoon; // ConnectionIdAlgo implementation to encode and decode ConnectionId with // various info, such as routing related info. ConnectionIdAlgo* connIdAlgo{nullptr}; // Negotiated version. - folly::Optional version; + Optional version; // Original advertised version. Only meaningful to clients. // TODO: move to client only conn state. - folly::Optional originalVersion; + Optional originalVersion; // Original address used by the peer when first establishing the connection. folly::SocketAddress originalPeerAddress; @@ -416,13 +416,13 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { folly::SocketAddress peerAddress; // Local address. INADDR_ANY if not set. - folly::Optional localAddress; + Optional localAddress; // Local error on the connection. - folly::Optional localConnectionError; + Optional localConnectionError; // Error sent on the connection by the peer. - folly::Optional peerConnectionError; + Optional peerConnectionError; // Supported versions in order of preference. Only meaningful to clients. // TODO: move to client only conn state. @@ -431,15 +431,15 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { // The endpoint attempts to create a new self connection id with sequence // number and stateless reset token for itself, and if successful, returns it // and updates the connection's state to ensure its peer can use it. - virtual folly::Optional createAndAddNewSelfConnId() { - return folly::none; + virtual Optional createAndAddNewSelfConnId() { + return none; } uint64_t nextSelfConnectionIdSequence{0}; struct PendingEvents { Resets resets; - folly::Optional pathChallenge; + Optional pathChallenge; FrameList frames; @@ -511,7 +511,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { // The sum of length of data in all the stream buffers. uint64_t sumCurStreamBufferLen{0}; // The packet number in which we got the last largest max data. - folly::Optional largestMaxOffsetReceived; + Optional largestMaxOffsetReceived; // The following are advertised by the peer, and are set to zero initially // so that we cannot send any data until we know the peer values. // The initial max stream offset for peer-initiated bidirectional streams. @@ -521,7 +521,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { // The initial max stream offset for unidirectional streams. uint64_t peerAdvertisedInitialMaxStreamOffsetUni{0}; // Time at which the last flow control update was sent by the transport. - folly::Optional timeOfLastFlowControlUpdate; + Optional timeOfLastFlowControlUpdate; }; // Current state of flow control. @@ -537,7 +537,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { PendingWriteBatch pendingWriteBatch_; // The outstanding path challenge - folly::Optional outstandingPathValidation; + Optional outstandingPathValidation; // Settings for transports. TransportSettings transportSettings; @@ -547,7 +547,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { // The value of the peer's min_ack_delay, for creating ACK_FREQUENCY and // IMMEDIATE_ACK frames. - folly::Optional peerMinAckDelay; + Optional peerMinAckDelay; // Idle timeout advertised by the peer. Initially sets it to the maximum value // until the handshake sets the timeout. @@ -600,7 +600,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { /** * Eerie data app params functions. */ - folly::Function&, const Buf&) const> + folly::Function&, const Buf&) const> earlyDataAppParamsValidator; folly::Function earlyDataAppParamsGetter; @@ -677,16 +677,15 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { DatagramState datagramState; // Peer max stream groups advertised. - folly::Optional peerAdvertisedMaxStreamGroups; + Optional peerAdvertisedMaxStreamGroups; // Sequence number to use for the next ACK_FREQUENCY frame uint64_t nextAckFrequencyFrameSequenceNumber{0}; // GSO supported on conn. - folly::Optional gsoSupported; + Optional gsoSupported; - folly::Optional - maybePeerAckReceiveTimestampsConfig; + Optional maybePeerAckReceiveTimestampsConfig; bool peerAdvertisedKnobFrameSupport{false}; // Retransmission policies map. @@ -694,7 +693,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { retransmissionPolicies; struct SocketCmsgsState { - folly::Optional additionalCmsgs; + Optional additionalCmsgs; // The write count which this SocketCmsgs state is intended for. // This is used to make sure this cmsgs list does not end up used // for multiple writes. diff --git a/quic/state/StreamData.h b/quic/state/StreamData.h index 4b5bc8de8..40579ae61 100644 --- a/quic/state/StreamData.h +++ b/quic/state/StreamData.h @@ -153,7 +153,7 @@ struct QuicStreamLike { // either from FIN or RST. Right now we use one value to represent both FIN // and RST. We may split write EOF into two values in the future. // Read side eof offset. - folly::Optional finalReadOffset; + Optional finalReadOffset; // Current cumulative number of packets sent for this stream. It only counts // egress packets that contains a *new* STREAM frame for this stream. @@ -284,7 +284,7 @@ struct QuicStreamState : public QuicStreamLike { QuicStreamState( StreamId idIn, - const folly::Optional& groupIdIn, + const Optional& groupIdIn, QuicConnectionStateBase& connIn); QuicStreamState(QuicStreamState&&) = default; @@ -324,17 +324,17 @@ struct QuicStreamState : public QuicStreamLike { StreamId id; // ID of the group the stream belongs to. - folly::Optional groupId; + Optional groupId; // Write side eof offset. This represents only the final FIN offset. - folly::Optional finalWriteOffset; + Optional finalWriteOffset; struct StreamFlowControlState { uint64_t windowSize{0}; uint64_t advertisedMaxOffset{0}; uint64_t peerAdvertisedMaxOffset{0}; // Time at which the last flow control update was sent by the transport. - folly::Optional timeOfLastFlowControlUpdate; + Optional timeOfLastFlowControlUpdate; // A flag indicating if the stream has a pending blocked frame to the peer // (blocked frame sent, but a stream flow control update has not been // received yet). Set when we write a blocked data frame on the stream; @@ -345,9 +345,9 @@ struct QuicStreamState : public QuicStreamLike { StreamFlowControlState flowControlState; // Stream level read error occurred. - folly::Optional streamReadError; + Optional streamReadError; // Stream level write error occurred. - folly::Optional streamWriteError; + Optional streamWriteError; // State machine data StreamSendState sendState{StreamSendState::Open}; @@ -362,7 +362,7 @@ struct QuicStreamState : public QuicStreamLike { bool isControl{false}; // The last time we detected we were head of line blocked on the stream. - folly::Optional lastHolbTime; + Optional lastHolbTime; // The total amount of time we are head line blocked on the stream. std::chrono::microseconds totalHolbTime{0us}; diff --git a/quic/state/TransportSettings.h b/quic/state/TransportSettings.h index 776dfc83e..60b39d296 100644 --- a/quic/state/TransportSettings.h +++ b/quic/state/TransportSettings.h @@ -7,8 +7,8 @@ #pragma once -#include #include +#include #include #include #include @@ -66,7 +66,7 @@ struct CongestionControlConfig { }; // Used by: BBR1 - folly::Optional ackFrequencyConfig; + Optional ackFrequencyConfig; // Used by: BBR2 // Whether BBR2 should not use inflightHi when settings its cwnd. @@ -148,7 +148,7 @@ struct TransportSettings { CongestionControlType::Cubic}; // Param to determine sensitivity of CongestionController to latency. Only // used by Copa. - folly::Optional copaDeltaParam; + Optional copaDeltaParam; // Whether to use Copa's RTT standing feature. Only used by Copa. bool copaUseRttStanding{false}; // The max UDP packet size we are willing to receive. @@ -225,7 +225,7 @@ struct TransportSettings { // The minimum amount of time in microseconds by which an ack can be delayed // Setting a value here also indicates to the peer that it can send // ACK_FREQUENCY and IMMEDIATE_ACK frames - folly::Optional minAckDelay; + Optional minAckDelay; // Limits the amount of data that should be buffered in a QuicSocket. // If the amount of data in the buffer equals or exceeds this amount, then // the callback registered through notifyPendingWriteOnConnection() will @@ -236,11 +236,10 @@ struct TransportSettings { // Whether or not the socket should gracefully drain on close bool shouldDrain{true}; // default stateless reset secret for stateless reset token - folly::Optional> + Optional> statelessResetTokenSecret; // retry token secret used for encryption/decryption - folly::Optional> - retryTokenSecret; + Optional> retryTokenSecret; // Default initial RTT std::chrono::microseconds initialRtt{kDefaultInitialRtt}; // The active_connection_id_limit that is sent to the peer. @@ -341,7 +340,7 @@ struct TransportSettings { // If structure is not initialized, ACK receive timestamps are // not requested from peer regardless of whether the peer // supports them. - folly::Optional + Optional maybeAckReceiveTimestampsConfigSentToPeer; // Maximum number of received packet timestamps stored per ACK. This will be @@ -362,9 +361,8 @@ struct TransportSettings { // Whether to initiate key updates bool initiateKeyUpdate{false}; // How many packets to send before initiating the first key update. - // This is reset to folly::none after the first key update is initiated. - folly::Optional firstKeyUpdatePacketCount{ - kFirstKeyUpdatePacketCount}; + // This is reset to none after the first key update is initiated. + Optional firstKeyUpdatePacketCount{kFirstKeyUpdatePacketCount}; // How many packets to send before initiating periodic key updates uint64_t keyUpdatePacketCountInterval{kDefaultKeyUpdatePacketCountInterval}; diff --git a/quic/state/TransportSettingsFunctions.cpp b/quic/state/TransportSettingsFunctions.cpp index b99e6e2da..dcc584d0b 100644 --- a/quic/state/TransportSettingsFunctions.cpp +++ b/quic/state/TransportSettingsFunctions.cpp @@ -104,15 +104,15 @@ quic::CongestionControlConfig parseCongestionControlConfig( return ccaConfig; } -// Same as parse function but returns folly::none on error instead of throwing. -folly::Optional tryParseCongestionControlConfig( +// Same as parse function but returns none on error instead of throwing. +Optional tryParseCongestionControlConfig( const std::string& ccaConfigJson) { try { quic::CongestionControlConfig ccaConfig; ccaConfig = parseCongestionControlConfig(ccaConfigJson); return ccaConfig; } catch (const std::exception&) { - return folly::none; + return none; } folly::assume_unreachable(); } diff --git a/quic/state/TransportSettingsFunctions.h b/quic/state/TransportSettingsFunctions.h index c8c4cb90f..87a5fe9ff 100644 --- a/quic/state/TransportSettingsFunctions.h +++ b/quic/state/TransportSettingsFunctions.h @@ -23,7 +23,7 @@ void populateAckFrequencyConfig( quic::CongestionControlConfig parseCongestionControlConfig( const std::string& ccaConfigJson); -// Same as parse function but returns folly::none on error instead of throwing. -folly::Optional tryParseCongestionControlConfig( +// Same as parse function but returns none on error instead of throwing. +Optional tryParseCongestionControlConfig( const std::string& ccaConfigJson); } // namespace quic diff --git a/quic/state/stream/test/StreamStateMachineTest.cpp b/quic/state/stream/test/StreamStateMachineTest.cpp index 365eb0d70..8708bb127 100644 --- a/quic/state/stream/test/StreamStateMachineTest.cpp +++ b/quic/state/stream/test/StreamStateMachineTest.cpp @@ -146,7 +146,7 @@ TEST_F(QuicOpenStateTest, AckStream) { auto conn = createConn(); auto stream = conn->streamManager->createNextBidirectionalStream().value(); - folly::Optional serverChosenConnId = *conn->clientConnectionId; + Optional serverChosenConnId = *conn->clientConnectionId; serverChosenConnId.value().data()[0] ^= 0x01; EventBase evb; auto qEvb = std::make_shared(&evb); @@ -181,7 +181,7 @@ TEST_F(QuicOpenStateTest, AckStreamMulti) { auto conn = createConn(); auto stream = conn->streamManager->createNextBidirectionalStream().value(); - folly::Optional serverChosenConnId = *conn->clientConnectionId; + Optional serverChosenConnId = *conn->clientConnectionId; serverChosenConnId.value().data()[0] ^= 0x01; EventBase evb; auto qEvb = std::make_shared(&evb); @@ -247,7 +247,7 @@ TEST_F(QuicOpenStateTest, RetxBufferSortedAfterAck) { EventBase evb; auto qEvb = std::make_shared(&evb); quic::test::MockAsyncUDPSocket socket(qEvb); - folly::Optional serverChosenConnId = *conn->clientConnectionId; + Optional serverChosenConnId = *conn->clientConnectionId; serverChosenConnId.value().data()[0] ^= 0x01; auto buf1 = IOBuf::copyBuffer("Alice"); diff --git a/quic/state/test/AckEventTestUtil.h b/quic/state/test/AckEventTestUtil.h index 25b601af5..9152e6ddf 100644 --- a/quic/state/test/AckEventTestUtil.h +++ b/quic/state/test/AckEventTestUtil.h @@ -43,7 +43,7 @@ struct AckEventStreamDetailsMatcherBuilder { } private: - folly::Optional maybeStreamId; + Optional maybeStreamId; DupAckedStreamIntervals dupAckedStreamIntervals; }; diff --git a/quic/state/test/AckHandlersTest.cpp b/quic/state/test/AckHandlersTest.cpp index 8313005b1..4f6b4e1c1 100644 --- a/quic/state/test/AckHandlersTest.cpp +++ b/quic/state/test/AckHandlersTest.cpp @@ -2399,8 +2399,7 @@ TEST_P(AckHandlersTest, AckEventCreation) { .WillOnce(Return(writableBytes)); EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); - EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + EXPECT_CALL(*rawCongestionController, getBandwidth()).WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); // check the AckEvent returned by processAckFrame so everything is filled @@ -2528,8 +2527,7 @@ TEST_P(AckHandlersTest, AckEventCreationSingleWrite) { .WillOnce(Return(writableBytes)); EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); - EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + EXPECT_CALL(*rawCongestionController, getBandwidth()).WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); // check the AckEvent returned by processAckFrame so everything is filled @@ -3362,15 +3360,14 @@ TEST_P(AckHandlersTest, AckEventCreationInvalidAckDelay) { ackTime - getSentTime(9)), ack->rttSample); EXPECT_EQ( - folly::none, // ack delay > RTT, so not set + none, // ack delay > RTT, so not set ack->rttSampleNoAckDelay); })); EXPECT_CALL(*rawCongestionController, getWritableBytes()) .WillOnce(Return(writableBytes)); EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); - EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + EXPECT_CALL(*rawCongestionController, getBandwidth()).WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); processAckFrame( @@ -3470,8 +3467,7 @@ TEST_P(AckHandlersTest, AckEventCreationRttMinusAckDelayIsZero) { .WillOnce(Return(writableBytes)); EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); - EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + EXPECT_CALL(*rawCongestionController, getBandwidth()).WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); processAckFrame( @@ -3598,7 +3594,7 @@ TEST_P(AckHandlersTest, AckEventCreationReorderingLargestPacketAcked) { EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + .WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); processAckFrame( @@ -3641,8 +3637,8 @@ TEST_P(AckHandlersTest, AckEventCreationReorderingLargestPacketAcked) { Pointee( getAckPacketMatcher(4, getWriteCount(4), getSentTime(4)))); - EXPECT_EQ(folly::none, ack->rttSample); // no RTT sample - EXPECT_EQ(folly::none, ack->rttSampleNoAckDelay); // no RTT sample + EXPECT_EQ(none, ack->rttSample); // no RTT sample + EXPECT_EQ(none, ack->rttSampleNoAckDelay); // no RTT sample EXPECT_THAT(ack->ackedPackets, SizeIs(1)); EXPECT_THAT( ack->ackedPackets, @@ -3654,7 +3650,7 @@ TEST_P(AckHandlersTest, AckEventCreationReorderingLargestPacketAcked) { EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + .WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); processAckFrame( @@ -3696,8 +3692,8 @@ TEST_P(AckHandlersTest, AckEventCreationReorderingLargestPacketAcked) { Pointee( getAckPacketMatcher(6, getWriteCount(6), getSentTime(6)))); - EXPECT_EQ(folly::none, ack->rttSample); // no RTT sample - EXPECT_EQ(folly::none, ack->rttSampleNoAckDelay); // no RTT sample + EXPECT_EQ(none, ack->rttSample); // no RTT sample + EXPECT_EQ(none, ack->rttSampleNoAckDelay); // no RTT sample EXPECT_THAT(ack->ackedPackets, SizeIs(2)); EXPECT_THAT( ack->ackedPackets, @@ -3710,7 +3706,7 @@ TEST_P(AckHandlersTest, AckEventCreationReorderingLargestPacketAcked) { EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + .WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); processAckFrame( @@ -3829,7 +3825,7 @@ TEST_P(AckHandlersTest, AckEventCreationNoMatchingPacketDueToLoss) { EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + .WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); processAckFrame( @@ -3953,8 +3949,7 @@ TEST_P(AckHandlersTest, ImplictAckEventCreation) { .WillOnce(Return(writableBytes)); EXPECT_CALL(*rawCongestionController, getCongestionWindow()) .WillOnce(Return(congestionWindow)); - EXPECT_CALL(*rawCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + EXPECT_CALL(*rawCongestionController, getBandwidth()).WillOnce(Return(none)); EXPECT_CALL(*rawPacketProcessor, onPacketAck(_)).Times(1); processAckFrame( @@ -4368,7 +4363,7 @@ class AckEventForAppDataTest : public Test { auto buildEmptyPacket( const PacketNumberSpace pnSpace, const bool shortHeader = false) { - folly::Optional header; + Optional header; if (shortHeader) { header = ShortHeader( ProtectionType::KeyPhaseZero, @@ -4433,7 +4428,7 @@ class AckEventForAppDataTest : public Test { const TimePoint timepoint = Clock::now()) { updateConnection( *conn_, - folly::none, + none, packet.packet, timepoint, getEncodedSize(packet), diff --git a/quic/state/test/MockQuicStats.h b/quic/state/test/MockQuicStats.h index 92c434066..d71a452cc 100644 --- a/quic/state/test/MockQuicStats.h +++ b/quic/state/test/MockQuicStats.h @@ -35,7 +35,7 @@ class MockQuicStats : public QuicTransportStatsCallback { MOCK_METHOD(void, onConnectionRateLimited, ()); MOCK_METHOD(void, onConnectionWritableBytesLimited, ()); MOCK_METHOD(void, onNewConnection, ()); - MOCK_METHOD(void, onConnectionClose, (folly::Optional)); + MOCK_METHOD(void, onConnectionClose, (Optional)); MOCK_METHOD(void, onConnectionCloseZeroBytesWritten, ()); MOCK_METHOD(void, onPeerAddressChanged, ()); MOCK_METHOD(void, onNewQuicStream, ()); diff --git a/quic/state/test/Mocks.h b/quic/state/test/Mocks.h index ba9e82afc..5847ad37a 100644 --- a/quic/state/test/Mocks.h +++ b/quic/state/test/Mocks.h @@ -34,7 +34,7 @@ class MockCongestionController : public CongestionController { (const AckEvent* FOLLY_NULLABLE, const LossEvent* FOLLY_NULLABLE)); MOCK_METHOD(uint64_t, getWritableBytes, (), (const)); MOCK_METHOD(uint64_t, getCongestionWindow, (), (const)); - MOCK_METHOD(folly::Optional, getBandwidth, (), (const)); + MOCK_METHOD(Optional, getBandwidth, (), (const)); MOCK_METHOD(void, onSpuriousLoss, ()); MOCK_METHOD(CongestionControlType, type, (), (const)); MOCK_METHOD(void, setAppIdle, (bool, TimePoint)); @@ -60,14 +60,14 @@ class MockPacketProcessor : public PacketProcessor { onPacketDestroyed, (const OutstandingPacketWrapper&), (override)); - MOCK_METHOD(folly::Optional, prewrite, (), (override)); + MOCK_METHOD(Optional, prewrite, (), (override)); }; class MockThrottlingSignalProvider : public ThrottlingSignalProvider { public: ~MockThrottlingSignalProvider() override = default; MOCK_METHOD( - folly::Optional, + Optional, getCurrentThrottlingSignal, (), (override)); diff --git a/quic/state/test/QuicStreamFunctionsTest.cpp b/quic/state/test/QuicStreamFunctionsTest.cpp index 2c60f8834..78fb00411 100644 --- a/quic/state/test/QuicStreamFunctionsTest.cpp +++ b/quic/state/test/QuicStreamFunctionsTest.cpp @@ -2125,7 +2125,7 @@ TEST_F(QuicStreamFunctionsTest, StreamLargestWriteOffsetTxedNothingTxed) { QuicStreamState stream(3, conn); stream.currentWriteOffset = 0; stream.writeBufMeta.offset = 0; - EXPECT_EQ(folly::none, getLargestWriteOffsetTxed(stream)); + EXPECT_EQ(none, getLargestWriteOffsetTxed(stream)); } TEST_F( @@ -2197,7 +2197,7 @@ TEST_F( TEST_F(QuicStreamFunctionsTest, StreamNextOffsetToDeliverNothingAcked) { QuicStreamState stream(3, conn); stream.currentWriteOffset = 100; - EXPECT_EQ(folly::none, getLargestDeliverableOffset(stream)); + EXPECT_EQ(none, getLargestDeliverableOffset(stream)); } TEST_F(QuicStreamFunctionsTest, StreamNextOffsetToDeliverAllAcked) { diff --git a/quic/state/test/QuicStreamManagerTest.cpp b/quic/state/test/QuicStreamManagerTest.cpp index 7243fd8e9..f94f99293 100644 --- a/quic/state/test/QuicStreamManagerTest.cpp +++ b/quic/state/test/QuicStreamManagerTest.cpp @@ -468,8 +468,8 @@ TEST_P(QuicStreamManagerTest, NextAcceptableLocalUnidirectionalStreamIdLimit) { // create next local stream, then check that limit is applied manager.createStream(serverStreamId2); - EXPECT_EQ(folly::none, manager.nextAcceptableLocalUnidirectionalStreamId()); - EXPECT_EQ(folly::none, manager.nextAcceptableLocalUnidirectionalStreamId()); + EXPECT_EQ(none, manager.nextAcceptableLocalUnidirectionalStreamId()); + EXPECT_EQ(none, manager.nextAcceptableLocalUnidirectionalStreamId()); } TEST_P(QuicStreamManagerTest, NextAcceptableLocalBidirectionalStreamIdLimit) { @@ -499,8 +499,8 @@ TEST_P(QuicStreamManagerTest, NextAcceptableLocalBidirectionalStreamIdLimit) { // create next local stream, then check that limit is applied manager.createStream(serverStreamId2); - EXPECT_EQ(folly::none, manager.nextAcceptableLocalBidirectionalStreamId()); - EXPECT_EQ(folly::none, manager.nextAcceptableLocalBidirectionalStreamId()); + EXPECT_EQ(none, manager.nextAcceptableLocalBidirectionalStreamId()); + EXPECT_EQ(none, manager.nextAcceptableLocalBidirectionalStreamId()); } TEST_P(QuicStreamManagerTest, NextAcceptablePeerUnidirectionalStreamId) { @@ -595,8 +595,8 @@ TEST_P(QuicStreamManagerTest, NextAcceptablePeerUnidirectionalStreamIdLimit) { // open next stream, then check that limit is applied manager.getStream(clientStreamId2); - EXPECT_EQ(folly::none, manager.nextAcceptablePeerUnidirectionalStreamId()); - EXPECT_EQ(folly::none, manager.nextAcceptablePeerUnidirectionalStreamId()); + EXPECT_EQ(none, manager.nextAcceptablePeerUnidirectionalStreamId()); + EXPECT_EQ(none, manager.nextAcceptablePeerUnidirectionalStreamId()); } TEST_P(QuicStreamManagerTest, NextAcceptablePeerBidirectionalStreamIdLimit) { @@ -623,8 +623,8 @@ TEST_P(QuicStreamManagerTest, NextAcceptablePeerBidirectionalStreamIdLimit) { // open next stream, then check that limit is applied manager.getStream(clientStreamId2); - EXPECT_EQ(folly::none, manager.nextAcceptablePeerBidirectionalStreamId()); - EXPECT_EQ(folly::none, manager.nextAcceptablePeerBidirectionalStreamId()); + EXPECT_EQ(none, manager.nextAcceptablePeerBidirectionalStreamId()); + EXPECT_EQ(none, manager.nextAcceptablePeerBidirectionalStreamId()); } TEST_P(QuicStreamManagerTest, TestClearActionable) { diff --git a/quic/state/test/StateDataTest.cpp b/quic/state/test/StateDataTest.cpp index 1a7e285f6..c0fdee57c 100644 --- a/quic/state/test/StateDataTest.cpp +++ b/quic/state/test/StateDataTest.cpp @@ -31,8 +31,7 @@ TEST_F(StateDataTest, CongestionControllerState) { .WillOnce(Return(1000)); EXPECT_CALL(*mockCongestionController, getWritableBytes()) .WillOnce(Return(2000)); - EXPECT_CALL(*mockCongestionController, getBandwidth()) - .WillOnce(Return(folly::none)); + EXPECT_CALL(*mockCongestionController, getBandwidth()).WillOnce(Return(none)); EXPECT_THAT( mockCongestionController->getState(), testing::AllOf( @@ -40,8 +39,7 @@ TEST_F(StateDataTest, CongestionControllerState) { &CongestionController::State::congestionWindowBytes, 1000), testing::Field(&CongestionController::State::writableBytes, 2000), testing::Field( - &CongestionController::State::maybeBandwidthBitsPerSec, - folly::none))); + &CongestionController::State::maybeBandwidthBitsPerSec, none))); { Bandwidth testBandwidth( 300 /* bytes delivered */, 20us /* time interval */); @@ -84,8 +82,7 @@ TEST_F(StateDataTest, CongestionControllerState) { &CongestionController::State::congestionWindowBytes, 3000), testing::Field(&CongestionController::State::writableBytes, 4000), testing::Field( - &CongestionController::State::maybeBandwidthBitsPerSec, - folly::none))); + &CongestionController::State::maybeBandwidthBitsPerSec, none))); } } diff --git a/quic/tools/tperf/tperf.cpp b/quic/tools/tperf/tperf.cpp index 5b2ceebef..a6fd0ce2f 100644 --- a/quic/tools/tperf/tperf.cpp +++ b/quic/tools/tperf/tperf.cpp @@ -559,7 +559,7 @@ class TPerfClient : public quic::QuicSocket::ConnectionSetupCallback, } void timeoutExpired() noexcept override { - quicClient_->closeNow(folly::none); + quicClient_->closeNow(none); constexpr double bytesPerMegabit = 131072; LOG(INFO) << "Received " << receivedBytes_ << " bytes in " << duration_.count() << " seconds."; diff --git a/quic/xsk/BUCK b/quic/xsk/BUCK index 6366102cb..85deae011 100644 --- a/quic/xsk/BUCK +++ b/quic/xsk/BUCK @@ -60,5 +60,6 @@ cpp_library( "//folly:network_address", "//folly/container:f14_hash", "//folly/io:iobuf", + "//quic/common:optional", ], ) diff --git a/quic/xsk/XskSender.cpp b/quic/xsk/XskSender.cpp index 712e0a2c3..335044ff2 100644 --- a/quic/xsk/XskSender.cpp +++ b/quic/xsk/XskSender.cpp @@ -39,7 +39,7 @@ XskSender::~XskSender() { } } -folly::Optional XskSender::getXskBuffer(bool isIpV6) { +quic::Optional XskSender::getXskBuffer(bool isIpV6) { auto guard = xskSenderConfig_.xskPerThread ? std::unique_lock() : std::unique_lock(m_); @@ -51,7 +51,7 @@ folly::Optional XskSender::getXskBuffer(bool isIpV6) { auto maybeFreeUmemLoc = getFreeUmemIndex(); if (!maybeFreeUmemLoc.hasValue()) { - return folly::none; + return quic::none; } XskBuffer xskBuffer; @@ -411,9 +411,9 @@ xdp_desc* XskSender::getTxDescriptor() { return result; } -folly::Optional XskSender::getFreeUmemIndex() { +quic::Optional XskSender::getFreeUmemIndex() { if (freeUmemIndices_.empty()) { - return folly::none; + return quic::none; } uint32_t freeLoc = freeUmemIndices_.front(); freeUmemIndices_.pop(); diff --git a/quic/xsk/XskSender.h b/quic/xsk/XskSender.h index b8812a00a..51d213f76 100644 --- a/quic/xsk/XskSender.h +++ b/quic/xsk/XskSender.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -111,7 +112,7 @@ class XskSender { ~XskSender(); - folly::Optional getXskBuffer(bool isIpV6); + quic::Optional getXskBuffer(bool isIpV6); void writeXskBuffer( const XskBuffer& xskBuffer, @@ -162,7 +163,7 @@ class XskSender { xdp_desc* getTxDescriptor(); - folly::Optional getFreeUmemIndex(); + quic::Optional getFreeUmemIndex(); void getFreeUmemFrames();