mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-08 09:42:06 +03:00
Introduce QuicError struct
Summary: Instead of using std::pair everywhere Reviewed By: mjoras Differential Revision: D34146686 fbshipit-source-id: dfe48f43775de868aba06a5b9b5a004e5793bdbb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6689a66364
commit
cecc1ba279
@@ -255,26 +255,24 @@ std::string toString(QuicErrorCode code) {
|
|||||||
folly::assume_unreachable();
|
folly::assume_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toString(
|
std::string toString(const QuicError& error) {
|
||||||
const std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>&
|
|
||||||
error) {
|
|
||||||
std::string err;
|
std::string err;
|
||||||
switch (error.first.type()) {
|
switch (error.code.type()) {
|
||||||
case QuicErrorCode::Type::ApplicationErrorCode:
|
case QuicErrorCode::Type::ApplicationErrorCode:
|
||||||
err = "ApplicationError: " +
|
err = "ApplicationError: " +
|
||||||
toString(*error.first.asApplicationErrorCode()) + ", ";
|
toString(*error.code.asApplicationErrorCode()) + ", ";
|
||||||
break;
|
break;
|
||||||
case QuicErrorCode::Type::LocalErrorCode:
|
case QuicErrorCode::Type::LocalErrorCode:
|
||||||
err = "LocalError: " +
|
err = "LocalError: " +
|
||||||
folly::to<std::string>(toString(*error.first.asLocalErrorCode())) +
|
folly::to<std::string>(toString(*error.code.asLocalErrorCode())) +
|
||||||
", ";
|
", ";
|
||||||
break;
|
break;
|
||||||
case QuicErrorCode::Type::TransportErrorCode:
|
case QuicErrorCode::Type::TransportErrorCode:
|
||||||
err = "TransportError: " + toString(*error.first.asTransportErrorCode()) +
|
err = "TransportError: " + toString(*error.code.asTransportErrorCode()) +
|
||||||
", ";
|
", ";
|
||||||
}
|
}
|
||||||
if (error.second) {
|
if (!error.message.empty()) {
|
||||||
err = folly::to<std::string>(err, error.second.value());
|
err = folly::to<std::string>(err, error.message);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,18 @@ namespace quic {
|
|||||||
|
|
||||||
DECLARE_VARIANT_TYPE(QuicErrorCode, QUIC_ERROR_CODE)
|
DECLARE_VARIANT_TYPE(QuicErrorCode, QUIC_ERROR_CODE)
|
||||||
|
|
||||||
|
struct QuicError {
|
||||||
|
QuicError(QuicErrorCode codeIn, const std::string& messageIn)
|
||||||
|
: code(codeIn), message(messageIn) {}
|
||||||
|
explicit QuicError(QuicErrorCode codeIn) : code(codeIn) {}
|
||||||
|
bool operator==(const QuicError& other) const {
|
||||||
|
return code == other.code && message == other.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
QuicErrorCode code;
|
||||||
|
std::string message;
|
||||||
|
};
|
||||||
|
|
||||||
class QuicTransportException : public std::runtime_error {
|
class QuicTransportException : public std::runtime_error {
|
||||||
public:
|
public:
|
||||||
explicit QuicTransportException(
|
explicit QuicTransportException(
|
||||||
@@ -99,8 +111,7 @@ folly::StringPiece toString(LocalErrorCode code);
|
|||||||
// copy on return here as well.
|
// copy on return here as well.
|
||||||
std::string toString(TransportErrorCode code);
|
std::string toString(TransportErrorCode code);
|
||||||
std::string toString(QuicErrorCode code);
|
std::string toString(QuicErrorCode code);
|
||||||
std::string toString(
|
std::string toString(const QuicError& error);
|
||||||
const std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>& error);
|
|
||||||
|
|
||||||
std::string cryptoErrorToString(TransportErrorCode code);
|
std::string cryptoErrorToString(TransportErrorCode code);
|
||||||
std::vector<TransportErrorCode> getAllTransportErrorCodes();
|
std::vector<TransportErrorCode> getAllTransportErrorCodes();
|
||||||
@@ -111,10 +122,7 @@ inline std::ostream& operator<<(std::ostream& os, const QuicErrorCode& error) {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::ostream& operator<<(
|
inline std::ostream& operator<<(std::ostream& os, const QuicError& error) {
|
||||||
std::ostream& os,
|
|
||||||
const std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>&
|
|
||||||
error) {
|
|
||||||
os << toString(error);
|
os << toString(error);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
@@ -386,8 +386,7 @@ class Observer {
|
|||||||
*/
|
*/
|
||||||
virtual void close(
|
virtual void close(
|
||||||
QuicSocket* /* socket */,
|
QuicSocket* /* socket */,
|
||||||
const folly::Optional<
|
const folly::Optional<QuicError>& /* errorOpt */) noexcept {}
|
||||||
std::pair<QuicErrorCode, std::string>>& /* errorOpt */) noexcept {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* evbAttach() will be invoked when a new event base is attached to this
|
* evbAttach() will be invoked when a new event base is attached to this
|
||||||
|
@@ -48,8 +48,7 @@ class QuicSocket {
|
|||||||
/**
|
/**
|
||||||
* Invoked when the connection setup fails.
|
* Invoked when the connection setup fails.
|
||||||
*/
|
*/
|
||||||
virtual void onConnectionSetupError(
|
virtual void onConnectionSetupError(QuicError code) noexcept = 0;
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the transport is ready to send/receive data.
|
* Called when the transport is ready to send/receive data.
|
||||||
@@ -110,8 +109,7 @@ class QuicSocket {
|
|||||||
/**
|
/**
|
||||||
* Invoked when the connection closed in error
|
* Invoked when the connection closed in error
|
||||||
*/
|
*/
|
||||||
virtual void onConnectionError(
|
virtual void onConnectionError(QuicError code) noexcept = 0;
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when more bidirectional streams become available for creation
|
* Called when more bidirectional streams become available for creation
|
||||||
@@ -333,8 +331,7 @@ class QuicSocket {
|
|||||||
* Close this socket with a drain period. If closing with an error, it may be
|
* Close this socket with a drain period. If closing with an error, it may be
|
||||||
* specified.
|
* specified.
|
||||||
*/
|
*/
|
||||||
virtual void close(
|
virtual void close(folly::Optional<QuicError> errorCode) = 0;
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> errorCode) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close this socket gracefully, by waiting for all the streams to be idle
|
* Close this socket gracefully, by waiting for all the streams to be idle
|
||||||
@@ -346,8 +343,7 @@ class QuicSocket {
|
|||||||
* Close this socket without a drain period. If closing with an error, it may
|
* Close this socket without a drain period. If closing with an error, it may
|
||||||
* be specified.
|
* be specified.
|
||||||
*/
|
*/
|
||||||
virtual void closeNow(
|
virtual void closeNow(folly::Optional<QuicError> errorCode) = 0;
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> errorCode) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the event base associated with this socket
|
* Returns the event base associated with this socket
|
||||||
@@ -532,10 +528,7 @@ class QuicSocket {
|
|||||||
/**
|
/**
|
||||||
* Called from the transport layer when there is an error on the stream.
|
* Called from the transport layer when there is an error on the stream.
|
||||||
*/
|
*/
|
||||||
virtual void readError(
|
virtual void readError(StreamId id, QuicError error) noexcept = 0;
|
||||||
StreamId id,
|
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -661,10 +654,7 @@ class QuicSocket {
|
|||||||
* Called from the transport layer during peek time when there is an error
|
* Called from the transport layer during peek time when there is an error
|
||||||
* on the stream.
|
* on the stream.
|
||||||
*/
|
*/
|
||||||
virtual void peekError(
|
virtual void peekError(StreamId id, QuicError error) noexcept = 0;
|
||||||
StreamId id,
|
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual folly::Expected<folly::Unit, LocalErrorCode> setPeekCallback(
|
virtual folly::Expected<folly::Unit, LocalErrorCode> setPeekCallback(
|
||||||
@@ -824,16 +814,14 @@ class QuicSocket {
|
|||||||
*/
|
*/
|
||||||
virtual void onStreamWriteError(
|
virtual void onStreamWriteError(
|
||||||
StreamId /* id */,
|
StreamId /* id */,
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>
|
QuicError /* error */) noexcept {}
|
||||||
/* error */) noexcept {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when a connection is being torn down after
|
* Invoked when a connection is being torn down after
|
||||||
* notifyPendingWriteOnConnection has been called
|
* notifyPendingWriteOnConnection has been called
|
||||||
*/
|
*/
|
||||||
virtual void onConnectionWriteError(
|
virtual void onConnectionWriteError(QuicError
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>
|
/* error */) noexcept {}
|
||||||
/* error */) noexcept {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -356,8 +356,7 @@ void QuicStreamAsyncTransport::readAvailable(
|
|||||||
|
|
||||||
void QuicStreamAsyncTransport::readError(
|
void QuicStreamAsyncTransport::readError(
|
||||||
quic::StreamId /*streamId*/,
|
quic::StreamId /*streamId*/,
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
QuicError error) noexcept {
|
||||||
error) noexcept {
|
|
||||||
ex_ = folly::AsyncSocketException(
|
ex_ = folly::AsyncSocketException(
|
||||||
folly::AsyncSocketException::UNKNOWN,
|
folly::AsyncSocketException::UNKNOWN,
|
||||||
folly::to<std::string>("Quic read error: ", toString(error)));
|
folly::to<std::string>("Quic read error: ", toString(error)));
|
||||||
@@ -513,8 +512,7 @@ void QuicStreamAsyncTransport::onStreamWriteReady(
|
|||||||
|
|
||||||
void QuicStreamAsyncTransport::onStreamWriteError(
|
void QuicStreamAsyncTransport::onStreamWriteError(
|
||||||
StreamId /*id*/,
|
StreamId /*id*/,
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
QuicError error) noexcept {
|
||||||
error) noexcept {
|
|
||||||
closeNowImpl(folly::AsyncSocketException(
|
closeNowImpl(folly::AsyncSocketException(
|
||||||
folly::AsyncSocketException::UNKNOWN,
|
folly::AsyncSocketException::UNKNOWN,
|
||||||
folly::to<std::string>("Quic write error: ", toString(error))));
|
folly::to<std::string>("Quic write error: ", toString(error))));
|
||||||
|
@@ -127,20 +127,15 @@ class QuicStreamAsyncTransport : public folly::AsyncTransport,
|
|||||||
// QucSocket::ReadCallback overrides
|
// QucSocket::ReadCallback overrides
|
||||||
//
|
//
|
||||||
void readAvailable(quic::StreamId /*streamId*/) noexcept override;
|
void readAvailable(quic::StreamId /*streamId*/) noexcept override;
|
||||||
void readError(
|
void readError(quic::StreamId /*streamId*/, QuicError error) noexcept
|
||||||
quic::StreamId /*streamId*/,
|
override;
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// QucSocket::WriteCallback overrides
|
// QucSocket::WriteCallback overrides
|
||||||
//
|
//
|
||||||
void onStreamWriteReady(quic::StreamId /*id*/, uint64_t maxToSend) noexcept
|
void onStreamWriteReady(quic::StreamId /*id*/, uint64_t maxToSend) noexcept
|
||||||
override;
|
override;
|
||||||
void onStreamWriteError(
|
void onStreamWriteError(StreamId /*id*/, QuicError error) noexcept override;
|
||||||
StreamId /*id*/,
|
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// folly::EventBase::LoopCallback overrides
|
// folly::EventBase::LoopCallback overrides
|
||||||
|
@@ -143,7 +143,7 @@ QuicTransportBase::~QuicTransportBase() {
|
|||||||
resetConnectionCallbacks();
|
resetConnectionCallbacks();
|
||||||
|
|
||||||
closeImpl(
|
closeImpl(
|
||||||
std::make_pair(
|
QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
||||||
std::string("Closing from base destructor")),
|
std::string("Closing from base destructor")),
|
||||||
false);
|
false);
|
||||||
@@ -173,8 +173,7 @@ bool QuicTransportBase::error() const {
|
|||||||
return conn_->localConnectionError.has_value();
|
return conn_->localConnectionError.has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicTransportBase::close(
|
void QuicTransportBase::close(folly::Optional<QuicError> errorCode) {
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> errorCode) {
|
|
||||||
FOLLY_MAYBE_UNUSED auto self = sharedGuard();
|
FOLLY_MAYBE_UNUSED auto self = sharedGuard();
|
||||||
// The caller probably doesn't need a conn callback any more because they
|
// The caller probably doesn't need a conn callback any more because they
|
||||||
// explicitly called close.
|
// explicitly called close.
|
||||||
@@ -183,7 +182,7 @@ void QuicTransportBase::close(
|
|||||||
// If we were called with no error code, ensure that we are going to write
|
// If we were called with no error code, ensure that we are going to write
|
||||||
// an application close, so the peer knows it didn't come from the transport.
|
// an application close, so the peer knows it didn't come from the transport.
|
||||||
if (!errorCode) {
|
if (!errorCode) {
|
||||||
errorCode = std::make_pair(
|
errorCode = QuicError(
|
||||||
GenericApplicationErrorCode::NO_ERROR,
|
GenericApplicationErrorCode::NO_ERROR,
|
||||||
toString(GenericApplicationErrorCode::NO_ERROR));
|
toString(GenericApplicationErrorCode::NO_ERROR));
|
||||||
}
|
}
|
||||||
@@ -191,13 +190,12 @@ void QuicTransportBase::close(
|
|||||||
conn_->logger.reset();
|
conn_->logger.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicTransportBase::closeNow(
|
void QuicTransportBase::closeNow(folly::Optional<QuicError> errorCode) {
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> errorCode) {
|
|
||||||
DCHECK(getEventBase() && getEventBase()->isInEventBaseThread());
|
DCHECK(getEventBase() && getEventBase()->isInEventBaseThread());
|
||||||
FOLLY_MAYBE_UNUSED auto self = sharedGuard();
|
FOLLY_MAYBE_UNUSED auto self = sharedGuard();
|
||||||
VLOG(4) << __func__ << " " << *this;
|
VLOG(4) << __func__ << " " << *this;
|
||||||
if (!errorCode) {
|
if (!errorCode) {
|
||||||
errorCode = std::make_pair(
|
errorCode = QuicError(
|
||||||
GenericApplicationErrorCode::NO_ERROR,
|
GenericApplicationErrorCode::NO_ERROR,
|
||||||
toString(GenericApplicationErrorCode::NO_ERROR));
|
toString(GenericApplicationErrorCode::NO_ERROR));
|
||||||
}
|
}
|
||||||
@@ -230,8 +228,8 @@ void QuicTransportBase::closeGracefully() {
|
|||||||
VLOG(10) << "Stopping read and peek loopers due to graceful close " << *this;
|
VLOG(10) << "Stopping read and peek loopers due to graceful close " << *this;
|
||||||
readLooper_->stop();
|
readLooper_->stop();
|
||||||
peekLooper_->stop();
|
peekLooper_->stop();
|
||||||
cancelAllAppCallbacks(std::make_pair(
|
cancelAllAppCallbacks(
|
||||||
QuicErrorCode(LocalErrorCode::NO_ERROR), "Graceful Close"));
|
QuicError(QuicErrorCode(LocalErrorCode::NO_ERROR), "Graceful Close"));
|
||||||
// All streams are closed, close the transport for realz.
|
// All streams are closed, close the transport for realz.
|
||||||
if (conn_->streamManager->streamCount() == 0) {
|
if (conn_->streamManager->streamCount() == 0) {
|
||||||
closeImpl(folly::none);
|
closeImpl(folly::none);
|
||||||
@@ -241,7 +239,7 @@ void QuicTransportBase::closeGracefully() {
|
|||||||
// TODO: t64691045 change the closeImpl API to include both the sanitized and
|
// TODO: t64691045 change the closeImpl API to include both the sanitized and
|
||||||
// unsanited error message, remove exceptionCloseWhat_.
|
// unsanited error message, remove exceptionCloseWhat_.
|
||||||
void QuicTransportBase::closeImpl(
|
void QuicTransportBase::closeImpl(
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> errorCode,
|
folly::Optional<QuicError> errorCode,
|
||||||
bool drainConnection,
|
bool drainConnection,
|
||||||
bool sendCloseImmediately) {
|
bool sendCloseImmediately) {
|
||||||
if (closeState_ == CloseState::CLOSED) {
|
if (closeState_ == CloseState::CLOSED) {
|
||||||
@@ -298,9 +296,9 @@ void QuicTransportBase::closeImpl(
|
|||||||
// TODO: truncate the error code string to be 1MSS only.
|
// TODO: truncate the error code string to be 1MSS only.
|
||||||
closeState_ = CloseState::CLOSED;
|
closeState_ = CloseState::CLOSED;
|
||||||
updatePacingOnClose(*conn_);
|
updatePacingOnClose(*conn_);
|
||||||
auto cancelCode = std::make_pair(
|
auto cancelCode = QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::NO_ERROR),
|
QuicErrorCode(LocalErrorCode::NO_ERROR),
|
||||||
toString(LocalErrorCode::NO_ERROR));
|
toString(LocalErrorCode::NO_ERROR).str());
|
||||||
if (conn_->peerConnectionError) {
|
if (conn_->peerConnectionError) {
|
||||||
cancelCode = *conn_->peerConnectionError;
|
cancelCode = *conn_->peerConnectionError;
|
||||||
} else if (errorCode) {
|
} else if (errorCode) {
|
||||||
@@ -310,14 +308,14 @@ void QuicTransportBase::closeImpl(
|
|||||||
// errorCode will be used for localConnectionError, and sent in close frames.
|
// errorCode will be used for localConnectionError, and sent in close frames.
|
||||||
// It's safe to include the unsanitized error message in cancelCode
|
// It's safe to include the unsanitized error message in cancelCode
|
||||||
if (exceptionCloseWhat_) {
|
if (exceptionCloseWhat_) {
|
||||||
cancelCode.second = exceptionCloseWhat_.value();
|
cancelCode.message = exceptionCloseWhat_.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isReset = false;
|
bool isReset = false;
|
||||||
bool isAbandon = false;
|
bool isAbandon = false;
|
||||||
bool isInvalidMigration = false;
|
bool isInvalidMigration = false;
|
||||||
LocalErrorCode* localError = cancelCode.first.asLocalErrorCode();
|
LocalErrorCode* localError = cancelCode.code.asLocalErrorCode();
|
||||||
TransportErrorCode* transportError = cancelCode.first.asTransportErrorCode();
|
TransportErrorCode* transportError = cancelCode.code.asTransportErrorCode();
|
||||||
if (localError) {
|
if (localError) {
|
||||||
isReset = *localError == LocalErrorCode::CONNECTION_RESET;
|
isReset = *localError == LocalErrorCode::CONNECTION_RESET;
|
||||||
isAbandon = *localError == LocalErrorCode::CONNECTION_ABANDONED;
|
isAbandon = *localError == LocalErrorCode::CONNECTION_ABANDONED;
|
||||||
@@ -329,8 +327,8 @@ void QuicTransportBase::closeImpl(
|
|||||||
<< *this;
|
<< *this;
|
||||||
if (errorCode) {
|
if (errorCode) {
|
||||||
conn_->localConnectionError = errorCode;
|
conn_->localConnectionError = errorCode;
|
||||||
std::string errorStr = conn_->localConnectionError->second;
|
std::string errorStr = conn_->localConnectionError->message;
|
||||||
std::string errorCodeStr = errorCode->second;
|
std::string errorCodeStr = errorCode->message;
|
||||||
if (conn_->qLogger) {
|
if (conn_->qLogger) {
|
||||||
conn_->qLogger->addConnectionClose(
|
conn_->qLogger->addConnectionClose(
|
||||||
errorStr, errorCodeStr, drainConnection, sendCloseImmediately);
|
errorStr, errorCodeStr, drainConnection, sendCloseImmediately);
|
||||||
@@ -435,12 +433,11 @@ void QuicTransportBase::closeImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QuicTransportBase::processCancelCode(
|
bool QuicTransportBase::processCancelCode(const QuicError& cancelCode) {
|
||||||
const std::pair<QuicErrorCode, folly::StringPiece>& cancelCode) {
|
|
||||||
bool noError = false;
|
bool noError = false;
|
||||||
switch (cancelCode.first.type()) {
|
switch (cancelCode.code.type()) {
|
||||||
case QuicErrorCode::Type::LocalErrorCode: {
|
case QuicErrorCode::Type::LocalErrorCode: {
|
||||||
LocalErrorCode localErrorCode = *cancelCode.first.asLocalErrorCode();
|
LocalErrorCode localErrorCode = *cancelCode.code.asLocalErrorCode();
|
||||||
noError = localErrorCode == LocalErrorCode::NO_ERROR ||
|
noError = localErrorCode == LocalErrorCode::NO_ERROR ||
|
||||||
localErrorCode == LocalErrorCode::IDLE_TIMEOUT ||
|
localErrorCode == LocalErrorCode::IDLE_TIMEOUT ||
|
||||||
localErrorCode == LocalErrorCode::SHUTTING_DOWN;
|
localErrorCode == LocalErrorCode::SHUTTING_DOWN;
|
||||||
@@ -448,45 +445,44 @@ bool QuicTransportBase::processCancelCode(
|
|||||||
}
|
}
|
||||||
case QuicErrorCode::Type::TransportErrorCode: {
|
case QuicErrorCode::Type::TransportErrorCode: {
|
||||||
TransportErrorCode transportErrorCode =
|
TransportErrorCode transportErrorCode =
|
||||||
*cancelCode.first.asTransportErrorCode();
|
*cancelCode.code.asTransportErrorCode();
|
||||||
noError = transportErrorCode == TransportErrorCode::NO_ERROR;
|
noError = transportErrorCode == TransportErrorCode::NO_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QuicErrorCode::Type::ApplicationErrorCode:
|
case QuicErrorCode::Type::ApplicationErrorCode:
|
||||||
auto appErrorCode = *cancelCode.first.asApplicationErrorCode();
|
auto appErrorCode = *cancelCode.code.asApplicationErrorCode();
|
||||||
noError = appErrorCode == GenericApplicationErrorCode::NO_ERROR;
|
noError = appErrorCode == GenericApplicationErrorCode::NO_ERROR;
|
||||||
}
|
}
|
||||||
return noError;
|
return noError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicTransportBase::processConnectionEndError(
|
void QuicTransportBase::processConnectionEndError(const QuicError& cancelCode) {
|
||||||
const std::pair<QuicErrorCode, folly::StringPiece>& cancelCode) {
|
|
||||||
bool noError = processCancelCode(cancelCode);
|
bool noError = processCancelCode(cancelCode);
|
||||||
if (noError) {
|
if (noError) {
|
||||||
connCallback_->onConnectionEnd();
|
connCallback_->onConnectionEnd();
|
||||||
} else {
|
} else {
|
||||||
connCallback_->onConnectionError(
|
connCallback_->onConnectionError(
|
||||||
std::make_pair(cancelCode.first, cancelCode.second.str()));
|
QuicError(cancelCode.code, cancelCode.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicTransportBase::processConnectionEndErrorSplitCallbacks(
|
void QuicTransportBase::processConnectionEndErrorSplitCallbacks(
|
||||||
const std::pair<QuicErrorCode, folly::StringPiece>& cancelCode) {
|
const QuicError& cancelCode) {
|
||||||
bool noError = processCancelCode(cancelCode);
|
bool noError = processCancelCode(cancelCode);
|
||||||
if (noError) {
|
if (noError) {
|
||||||
if (transportReadyNotified_) {
|
if (transportReadyNotified_) {
|
||||||
connCallback_->onConnectionEnd();
|
connCallback_->onConnectionEnd();
|
||||||
} else {
|
} else {
|
||||||
connCallback_->onConnectionSetupError(
|
connCallback_->onConnectionSetupError(
|
||||||
std::make_pair(cancelCode.first, cancelCode.second.str()));
|
QuicError(cancelCode.code, cancelCode.message));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (transportReadyNotified_) {
|
if (transportReadyNotified_) {
|
||||||
connCallback_->onConnectionError(
|
connCallback_->onConnectionError(
|
||||||
std::make_pair(cancelCode.first, cancelCode.second.str()));
|
QuicError(cancelCode.code, cancelCode.message));
|
||||||
} else {
|
} else {
|
||||||
connCallback_->onConnectionSetupError(
|
connCallback_->onConnectionSetupError(
|
||||||
std::make_pair(cancelCode.first, cancelCode.second.str()));
|
QuicError(cancelCode.code, cancelCode.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -849,8 +845,7 @@ void QuicTransportBase::invokeReadDataAndCallbacks() {
|
|||||||
peekCallbacks_.erase(streamId);
|
peekCallbacks_.erase(streamId);
|
||||||
VLOG(10) << "invoking read error callbacks on stream=" << streamId << " "
|
VLOG(10) << "invoking read error callbacks on stream=" << streamId << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
readCb->readError(
|
readCb->readError(streamId, QuicError(*stream->streamReadError));
|
||||||
streamId, std::make_pair(*stream->streamReadError, folly::none));
|
|
||||||
} else if (
|
} else if (
|
||||||
readCb && callback->second.resumed && stream->hasReadableData()) {
|
readCb && callback->second.resumed && stream->hasReadableData()) {
|
||||||
VLOG(10) << "invoking read callbacks on stream=" << streamId << " "
|
VLOG(10) << "invoking read callbacks on stream=" << streamId << " "
|
||||||
@@ -996,8 +991,7 @@ void QuicTransportBase::invokePeekDataAndCallbacks() {
|
|||||||
if (peekCb && stream->streamReadError) {
|
if (peekCb && stream->streamReadError) {
|
||||||
VLOG(10) << "invoking peek error callbacks on stream=" << streamId << " "
|
VLOG(10) << "invoking peek error callbacks on stream=" << streamId << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
peekCb->peekError(
|
peekCb->peekError(streamId, QuicError(*stream->streamReadError));
|
||||||
streamId, std::make_pair(*stream->streamReadError, folly::none));
|
|
||||||
} else if (
|
} else if (
|
||||||
peekCb && !stream->streamReadError && stream->hasPeekableData()) {
|
peekCb && !stream->streamReadError && stream->hasPeekableData()) {
|
||||||
VLOG(10) << "invoking peek callbacks on stream=" << streamId << " "
|
VLOG(10) << "invoking peek callbacks on stream=" << streamId << " "
|
||||||
@@ -1263,19 +1257,19 @@ folly::Expected<std::pair<Buf, bool>, LocalErrorCode> QuicTransportBase::read(
|
|||||||
} catch (const QuicTransportException& ex) {
|
} catch (const QuicTransportException& ex) {
|
||||||
VLOG(4) << "read() error " << ex.what() << " " << *this;
|
VLOG(4) << "read() error " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("read() error")));
|
QuicError(QuicErrorCode(ex.errorCode()), std::string("read() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("read() error")));
|
QuicError(QuicErrorCode(ex.errorCode()), std::string("read() error")));
|
||||||
return folly::makeUnexpected(ex.errorCode());
|
return folly::makeUnexpected(ex.errorCode());
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << "read() error " << ex.what() << " " << *this;
|
VLOG(4) << "read() error " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("read() error")));
|
std::string("read() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
||||||
@@ -1374,20 +1368,20 @@ folly::
|
|||||||
} catch (const QuicTransportException& ex) {
|
} catch (const QuicTransportException& ex) {
|
||||||
VLOG(4) << "consume() error " << ex.what() << " " << *this;
|
VLOG(4) << "consume() error " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("consume() error")));
|
QuicErrorCode(ex.errorCode()), std::string("consume() error")));
|
||||||
return folly::makeUnexpected(
|
return folly::makeUnexpected(
|
||||||
ConsumeError{LocalErrorCode::TRANSPORT_ERROR, readOffset});
|
ConsumeError{LocalErrorCode::TRANSPORT_ERROR, readOffset});
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("consume() error")));
|
QuicErrorCode(ex.errorCode()), std::string("consume() error")));
|
||||||
return folly::makeUnexpected(ConsumeError{ex.errorCode(), readOffset});
|
return folly::makeUnexpected(ConsumeError{ex.errorCode(), readOffset});
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << "consume() error " << ex.what() << " " << *this;
|
VLOG(4) << "consume() error " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("consume() error")));
|
std::string("consume() error")));
|
||||||
return folly::makeUnexpected(
|
return folly::makeUnexpected(
|
||||||
@@ -1809,21 +1803,21 @@ void QuicTransportBase::onNetworkData(
|
|||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
return closeImpl(
|
return closeImpl(
|
||||||
std::make_pair(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
QuicError(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
return closeImpl(
|
return closeImpl(
|
||||||
std::make_pair(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
QuicError(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
||||||
} catch (const QuicApplicationException& ex) {
|
} catch (const QuicApplicationException& ex) {
|
||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
return closeImpl(
|
return closeImpl(
|
||||||
std::make_pair(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
QuicError(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
return closeImpl(std::make_pair(
|
return closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("error onNetworkData()")));
|
std::string("error onNetworkData()")));
|
||||||
}
|
}
|
||||||
@@ -1997,14 +1991,14 @@ QuicTransportBase::notifyPendingWriteOnStream(StreamId id, WriteCallback* wcb) {
|
|||||||
if (!self->conn_->streamManager->streamExists(id)) {
|
if (!self->conn_->streamManager->streamExists(id)) {
|
||||||
self->pendingWriteCallbacks_.erase(wcbIt);
|
self->pendingWriteCallbacks_.erase(wcbIt);
|
||||||
writeCallback->onStreamWriteError(
|
writeCallback->onStreamWriteError(
|
||||||
id, std::make_pair(LocalErrorCode::STREAM_NOT_EXISTS, folly::none));
|
id, QuicError(LocalErrorCode::STREAM_NOT_EXISTS));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto stream = self->conn_->streamManager->getStream(id);
|
auto stream = self->conn_->streamManager->getStream(id);
|
||||||
if (!stream->writable()) {
|
if (!stream->writable()) {
|
||||||
self->pendingWriteCallbacks_.erase(wcbIt);
|
self->pendingWriteCallbacks_.erase(wcbIt);
|
||||||
writeCallback->onStreamWriteError(
|
writeCallback->onStreamWriteError(
|
||||||
id, std::make_pair(LocalErrorCode::STREAM_NOT_EXISTS, folly::none));
|
id, QuicError(LocalErrorCode::STREAM_NOT_EXISTS));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto maxCanWrite = self->maxWritableOnStream(*stream);
|
auto maxCanWrite = self->maxWritableOnStream(*stream);
|
||||||
@@ -2077,21 +2071,21 @@ QuicSocket::WriteResult QuicTransportBase::writeChain(
|
|||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(ex.errorCode());
|
return folly::makeUnexpected(ex.errorCode());
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("writeChain() error")));
|
std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
||||||
@@ -2153,21 +2147,21 @@ QuicSocket::WriteResult QuicTransportBase::writeBufMeta(
|
|||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(ex.errorCode());
|
return folly::makeUnexpected(ex.errorCode());
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("writeChain() error")));
|
std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
||||||
@@ -2347,21 +2341,21 @@ folly::Expected<folly::Unit, LocalErrorCode> QuicTransportBase::resetStream(
|
|||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("resetStream() error")));
|
QuicErrorCode(ex.errorCode()), std::string("resetStream() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("resetStream() error")));
|
QuicErrorCode(ex.errorCode()), std::string("resetStream() error")));
|
||||||
return folly::makeUnexpected(ex.errorCode());
|
return folly::makeUnexpected(ex.errorCode());
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("resetStream() error")));
|
std::string("resetStream() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
||||||
@@ -2480,19 +2474,19 @@ void QuicTransportBase::lossTimeoutExpired() noexcept {
|
|||||||
} catch (const QuicTransportException& ex) {
|
} catch (const QuicTransportException& ex) {
|
||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()),
|
QuicErrorCode(ex.errorCode()),
|
||||||
std::string("lossTimeoutExpired() error")));
|
std::string("lossTimeoutExpired() error")));
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()),
|
QuicErrorCode(ex.errorCode()),
|
||||||
std::string("lossTimeoutExpired() error")));
|
std::string("lossTimeoutExpired() error")));
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " " << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("lossTimeoutExpired() error")));
|
std::string("lossTimeoutExpired() error")));
|
||||||
}
|
}
|
||||||
@@ -2525,7 +2519,7 @@ void QuicTransportBase::pathValidationTimeoutExpired() noexcept {
|
|||||||
// TODO junqiw probing is not supported, so pathValidation==connMigration
|
// TODO junqiw probing is not supported, so pathValidation==connMigration
|
||||||
// We decide to close conn when pathValidation to migrated path fails.
|
// We decide to close conn when pathValidation to migrated path fails.
|
||||||
FOLLY_MAYBE_UNUSED auto self = sharedGuard();
|
FOLLY_MAYBE_UNUSED auto self = sharedGuard();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INVALID_MIGRATION),
|
QuicErrorCode(TransportErrorCode::INVALID_MIGRATION),
|
||||||
std::string("Path validation timed out")));
|
std::string("Path validation timed out")));
|
||||||
}
|
}
|
||||||
@@ -2540,7 +2534,7 @@ void QuicTransportBase::idleTimeoutExpired(bool drain) noexcept {
|
|||||||
auto localError =
|
auto localError =
|
||||||
drain ? LocalErrorCode::IDLE_TIMEOUT : LocalErrorCode::SHUTTING_DOWN;
|
drain ? LocalErrorCode::IDLE_TIMEOUT : LocalErrorCode::SHUTTING_DOWN;
|
||||||
closeImpl(
|
closeImpl(
|
||||||
std::make_pair(
|
quic::QuicError(
|
||||||
QuicErrorCode(localError),
|
QuicErrorCode(localError),
|
||||||
folly::to<std::string>(
|
folly::to<std::string>(
|
||||||
toString(localError),
|
toString(localError),
|
||||||
@@ -2727,8 +2721,7 @@ void QuicTransportBase::setEarlyDataAppParamsFunctions(
|
|||||||
conn_->earlyDataAppParamsGetter = std::move(getter);
|
conn_->earlyDataAppParamsGetter = std::move(getter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicTransportBase::cancelAllAppCallbacks(
|
void QuicTransportBase::cancelAllAppCallbacks(const QuicError& err) noexcept {
|
||||||
const std::pair<QuicErrorCode, folly::StringPiece>& err) noexcept {
|
|
||||||
SCOPE_EXIT {
|
SCOPE_EXIT {
|
||||||
checkForClosedStream();
|
checkForClosedStream();
|
||||||
updateReadLooper();
|
updateReadLooper();
|
||||||
@@ -2795,7 +2788,8 @@ void QuicTransportBase::resetNonControlStreams(
|
|||||||
if (isSendingStream(conn_->nodeType, id) || isBidirectionalStream(id)) {
|
if (isSendingStream(conn_->nodeType, id) || isBidirectionalStream(id)) {
|
||||||
auto writeCallbackIt = pendingWriteCallbacks_.find(id);
|
auto writeCallbackIt = pendingWriteCallbacks_.find(id);
|
||||||
if (writeCallbackIt != pendingWriteCallbacks_.end()) {
|
if (writeCallbackIt != pendingWriteCallbacks_.end()) {
|
||||||
writeCallbackIt->second->onStreamWriteError(id, {error, errorMsg});
|
writeCallbackIt->second->onStreamWriteError(
|
||||||
|
id, QuicError(error, errorMsg.str()));
|
||||||
}
|
}
|
||||||
resetStream(id, error);
|
resetStream(id, error);
|
||||||
}
|
}
|
||||||
@@ -2803,7 +2797,8 @@ void QuicTransportBase::resetNonControlStreams(
|
|||||||
auto readCallbackIt = readCallbacks_.find(id);
|
auto readCallbackIt = readCallbacks_.find(id);
|
||||||
if (readCallbackIt != readCallbacks_.end() &&
|
if (readCallbackIt != readCallbacks_.end() &&
|
||||||
readCallbackIt->second.readCb) {
|
readCallbackIt->second.readCb) {
|
||||||
readCallbackIt->second.readCb->readError(id, {error, errorMsg});
|
readCallbackIt->second.readCb->readError(
|
||||||
|
id, QuicError(error, errorMsg.str()));
|
||||||
}
|
}
|
||||||
peekCallbacks_.erase(id);
|
peekCallbacks_.erase(id);
|
||||||
stopSending(id, error);
|
stopSending(id, error);
|
||||||
@@ -3083,19 +3078,19 @@ void QuicTransportBase::writeSocketDataAndCatch() {
|
|||||||
} catch (const QuicTransportException& ex) {
|
} catch (const QuicTransportException& ex) {
|
||||||
VLOG(4) << __func__ << ex.what() << " " << *this;
|
VLOG(4) << __func__ << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()),
|
QuicErrorCode(ex.errorCode()),
|
||||||
std::string("writeSocketDataAndCatch() error")));
|
std::string("writeSocketDataAndCatch() error")));
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << ex.what() << " " << *this;
|
VLOG(4) << __func__ << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()),
|
QuicErrorCode(ex.errorCode()),
|
||||||
std::string("writeSocketDataAndCatch() error")));
|
std::string("writeSocketDataAndCatch() error")));
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << __func__ << " error=" << ex.what() << " " << *this;
|
VLOG(4) << __func__ << " error=" << ex.what() << " " << *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("writeSocketDataAndCatch() error")));
|
std::string("writeSocketDataAndCatch() error")));
|
||||||
}
|
}
|
||||||
@@ -3497,21 +3492,21 @@ QuicSocket::WriteResult QuicTransportBase::setDSRPacketizationRequestSender(
|
|||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::TRANSPORT_ERROR);
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
QuicErrorCode(ex.errorCode()), std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(ex.errorCode());
|
return folly::makeUnexpected(ex.errorCode());
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
VLOG(4) << __func__ << " streamId=" << id << " " << ex.what() << " "
|
||||||
<< *this;
|
<< *this;
|
||||||
exceptionCloseWhat_ = ex.what();
|
exceptionCloseWhat_ = ex.what();
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("writeChain() error")));
|
std::string("writeChain() error")));
|
||||||
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
return folly::makeUnexpected(LocalErrorCode::INTERNAL_ERROR);
|
||||||
|
@@ -68,13 +68,11 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
|
|||||||
|
|
||||||
bool error() const override;
|
bool error() const override;
|
||||||
|
|
||||||
void close(
|
void close(folly::Optional<QuicError> error) override;
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> error) override;
|
|
||||||
|
|
||||||
void closeGracefully() override;
|
void closeGracefully() override;
|
||||||
|
|
||||||
void closeNow(
|
void closeNow(folly::Optional<QuicError> error) override;
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> error) override;
|
|
||||||
|
|
||||||
folly::Expected<size_t, LocalErrorCode> getStreamReadOffset(
|
folly::Expected<size_t, LocalErrorCode> getStreamReadOffset(
|
||||||
StreamId id) const override;
|
StreamId id) const override;
|
||||||
@@ -622,8 +620,7 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
|
|||||||
conn_->loopDetectorCallback = std::move(callback);
|
conn_->loopDetectorCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void cancelAllAppCallbacks(
|
virtual void cancelAllAppCallbacks(const QuicError& error) noexcept;
|
||||||
const std::pair<QuicErrorCode, folly::StringPiece>& error) noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an observer.
|
* Adds an observer.
|
||||||
@@ -732,7 +729,7 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
|
|||||||
folly::Function<void(std::shared_ptr<QuicTransportBase>)> func);
|
folly::Function<void(std::shared_ptr<QuicTransportBase>)> func);
|
||||||
|
|
||||||
void closeImpl(
|
void closeImpl(
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> error,
|
folly::Optional<QuicError> error,
|
||||||
bool drainConnection = true,
|
bool drainConnection = true,
|
||||||
bool sendCloseImmediately = true);
|
bool sendCloseImmediately = true);
|
||||||
folly::Expected<folly::Unit, LocalErrorCode> pauseOrResumeRead(
|
folly::Expected<folly::Unit, LocalErrorCode> pauseOrResumeRead(
|
||||||
@@ -858,12 +855,9 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
|
|||||||
connCallback_ = nullptr;
|
connCallback_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool processCancelCode(
|
bool processCancelCode(const QuicError& cancelCode);
|
||||||
const std::pair<QuicErrorCode, folly::StringPiece>& cancelCode);
|
void processConnectionEndError(const QuicError& cancelCode);
|
||||||
void processConnectionEndError(
|
void processConnectionEndErrorSplitCallbacks(const QuicError& cancelCode);
|
||||||
const std::pair<QuicErrorCode, folly::StringPiece>& cancelCode);
|
|
||||||
void processConnectionEndErrorSplitCallbacks(
|
|
||||||
const std::pair<QuicErrorCode, folly::StringPiece>& cancelCode);
|
|
||||||
|
|
||||||
class CallbackDispatcher : public folly::DelayedDestruction,
|
class CallbackDispatcher : public folly::DelayedDestruction,
|
||||||
public ConnectionSetupCallback,
|
public ConnectionSetupCallback,
|
||||||
@@ -888,8 +882,7 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
|
|||||||
folly::DelayedDestruction::DestructorGuard dg(this);
|
folly::DelayedDestruction::DestructorGuard dg(this);
|
||||||
CHECK_NOTNULL(connSetupCallback_)->onFirstPeerPacketProcessed();
|
CHECK_NOTNULL(connSetupCallback_)->onFirstPeerPacketProcessed();
|
||||||
}
|
}
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError code) noexcept override {
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept override {
|
|
||||||
folly::DelayedDestruction::DestructorGuard dg(this);
|
folly::DelayedDestruction::DestructorGuard dg(this);
|
||||||
CHECK_NOTNULL(connSetupCallback_)
|
CHECK_NOTNULL(connSetupCallback_)
|
||||||
->onConnectionSetupError(std::move(code));
|
->onConnectionSetupError(std::move(code));
|
||||||
@@ -917,8 +910,7 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
|
|||||||
folly::DelayedDestruction::DestructorGuard dg(this);
|
folly::DelayedDestruction::DestructorGuard dg(this);
|
||||||
CHECK_NOTNULL(connStreamsCallback_)->onConnectionEnd();
|
CHECK_NOTNULL(connStreamsCallback_)->onConnectionEnd();
|
||||||
}
|
}
|
||||||
void onConnectionError(
|
void onConnectionError(QuicError code) noexcept override {
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept override {
|
|
||||||
folly::DelayedDestruction::DestructorGuard dg(this);
|
folly::DelayedDestruction::DestructorGuard dg(this);
|
||||||
CHECK_NOTNULL(connStreamsCallback_)->onConnectionError(std::move(code));
|
CHECK_NOTNULL(connStreamsCallback_)->onConnectionError(std::move(code));
|
||||||
}
|
}
|
||||||
|
@@ -1138,7 +1138,7 @@ void writeCloseCommon(
|
|||||||
folly::AsyncUDPSocket& sock,
|
folly::AsyncUDPSocket& sock,
|
||||||
QuicConnectionStateBase& connection,
|
QuicConnectionStateBase& connection,
|
||||||
PacketHeader&& header,
|
PacketHeader&& header,
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
|
folly::Optional<QuicError> closeDetails,
|
||||||
const Aead& aead,
|
const Aead& aead,
|
||||||
const PacketNumberCipher& headerCipher) {
|
const PacketNumberCipher& headerCipher) {
|
||||||
// close is special, we're going to bypass all the packet sent logic for all
|
// close is special, we're going to bypass all the packet sent logic for all
|
||||||
@@ -1161,20 +1161,20 @@ void writeCloseCommon(
|
|||||||
std::string("No error")),
|
std::string("No error")),
|
||||||
packetBuilder);
|
packetBuilder);
|
||||||
} else {
|
} else {
|
||||||
switch (closeDetails->first.type()) {
|
switch (closeDetails->code.type()) {
|
||||||
case QuicErrorCode::Type::ApplicationErrorCode:
|
case QuicErrorCode::Type::ApplicationErrorCode:
|
||||||
written = writeFrame(
|
written = writeFrame(
|
||||||
ConnectionCloseFrame(
|
ConnectionCloseFrame(
|
||||||
QuicErrorCode(*closeDetails->first.asApplicationErrorCode()),
|
QuicErrorCode(*closeDetails->code.asApplicationErrorCode()),
|
||||||
closeDetails->second,
|
closeDetails->message,
|
||||||
quic::FrameType::CONNECTION_CLOSE_APP_ERR),
|
quic::FrameType::CONNECTION_CLOSE_APP_ERR),
|
||||||
packetBuilder);
|
packetBuilder);
|
||||||
break;
|
break;
|
||||||
case QuicErrorCode::Type::TransportErrorCode:
|
case QuicErrorCode::Type::TransportErrorCode:
|
||||||
written = writeFrame(
|
written = writeFrame(
|
||||||
ConnectionCloseFrame(
|
ConnectionCloseFrame(
|
||||||
QuicErrorCode(*closeDetails->first.asTransportErrorCode()),
|
QuicErrorCode(*closeDetails->code.asTransportErrorCode()),
|
||||||
closeDetails->second,
|
closeDetails->message,
|
||||||
quic::FrameType::CONNECTION_CLOSE),
|
quic::FrameType::CONNECTION_CLOSE),
|
||||||
packetBuilder);
|
packetBuilder);
|
||||||
break;
|
break;
|
||||||
@@ -1240,7 +1240,7 @@ void writeLongClose(
|
|||||||
const ConnectionId& srcConnId,
|
const ConnectionId& srcConnId,
|
||||||
const ConnectionId& dstConnId,
|
const ConnectionId& dstConnId,
|
||||||
LongHeader::Types headerType,
|
LongHeader::Types headerType,
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
|
folly::Optional<QuicError> closeDetails,
|
||||||
const Aead& aead,
|
const Aead& aead,
|
||||||
const PacketNumberCipher& headerCipher,
|
const PacketNumberCipher& headerCipher,
|
||||||
QuicVersion version) {
|
QuicVersion version) {
|
||||||
@@ -1269,7 +1269,7 @@ void writeShortClose(
|
|||||||
folly::AsyncUDPSocket& sock,
|
folly::AsyncUDPSocket& sock,
|
||||||
QuicConnectionStateBase& connection,
|
QuicConnectionStateBase& connection,
|
||||||
const ConnectionId& connId,
|
const ConnectionId& connId,
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
|
folly::Optional<QuicError> closeDetails,
|
||||||
const Aead& aead,
|
const Aead& aead,
|
||||||
const PacketNumberCipher& headerCipher) {
|
const PacketNumberCipher& headerCipher) {
|
||||||
auto header = ShortHeader(
|
auto header = ShortHeader(
|
||||||
|
@@ -219,7 +219,7 @@ void writeCloseCommon(
|
|||||||
folly::AsyncUDPSocket& sock,
|
folly::AsyncUDPSocket& sock,
|
||||||
QuicConnectionStateBase& connection,
|
QuicConnectionStateBase& connection,
|
||||||
PacketHeader&& header,
|
PacketHeader&& header,
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
|
folly::Optional<QuicError> closeDetails,
|
||||||
const Aead& aead,
|
const Aead& aead,
|
||||||
const PacketNumberCipher& headerCipher);
|
const PacketNumberCipher& headerCipher);
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ void writeLongClose(
|
|||||||
const ConnectionId& srcConnId,
|
const ConnectionId& srcConnId,
|
||||||
const ConnectionId& dstConnId,
|
const ConnectionId& dstConnId,
|
||||||
LongHeader::Types headerType,
|
LongHeader::Types headerType,
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
|
folly::Optional<QuicError> closeDetails,
|
||||||
const Aead& aead,
|
const Aead& aead,
|
||||||
const PacketNumberCipher& headerCipher,
|
const PacketNumberCipher& headerCipher,
|
||||||
QuicVersion);
|
QuicVersion);
|
||||||
@@ -246,7 +246,7 @@ void writeShortClose(
|
|||||||
folly::AsyncUDPSocket& sock,
|
folly::AsyncUDPSocket& sock,
|
||||||
QuicConnectionStateBase& connection,
|
QuicConnectionStateBase& connection,
|
||||||
const ConnectionId& connId,
|
const ConnectionId& connId,
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> closeDetails,
|
folly::Optional<QuicError> closeDetails,
|
||||||
const Aead& aead,
|
const Aead& aead,
|
||||||
const PacketNumberCipher& headerCipher);
|
const PacketNumberCipher& headerCipher);
|
||||||
|
|
||||||
|
@@ -26,13 +26,9 @@ class MockQuicSocket : public QuicSocket {
|
|||||||
MOCK_CONST_METHOD0(good, bool());
|
MOCK_CONST_METHOD0(good, bool());
|
||||||
MOCK_CONST_METHOD0(replaySafe, bool());
|
MOCK_CONST_METHOD0(replaySafe, bool());
|
||||||
MOCK_CONST_METHOD0(error, bool());
|
MOCK_CONST_METHOD0(error, bool());
|
||||||
MOCK_METHOD1(
|
MOCK_METHOD1(close, void(folly::Optional<QuicError>));
|
||||||
close,
|
|
||||||
void(folly::Optional<std::pair<QuicErrorCode, std::string>>));
|
|
||||||
MOCK_METHOD0(closeGracefully, void());
|
MOCK_METHOD0(closeGracefully, void());
|
||||||
MOCK_METHOD1(
|
MOCK_METHOD1(closeNow, void(folly::Optional<QuicError>));
|
||||||
closeNow,
|
|
||||||
void(folly::Optional<std::pair<QuicErrorCode, std::string>>));
|
|
||||||
MOCK_CONST_METHOD0(
|
MOCK_CONST_METHOD0(
|
||||||
getClientConnectionId,
|
getClientConnectionId,
|
||||||
folly::Optional<quic::ConnectionId>());
|
folly::Optional<quic::ConnectionId>());
|
||||||
|
@@ -44,14 +44,7 @@ class MockReadCallback : public QuicSocket::ReadCallback {
|
|||||||
public:
|
public:
|
||||||
~MockReadCallback() override = default;
|
~MockReadCallback() override = default;
|
||||||
GMOCK_METHOD1_(, noexcept, , readAvailable, void(StreamId));
|
GMOCK_METHOD1_(, noexcept, , readAvailable, void(StreamId));
|
||||||
GMOCK_METHOD2_(
|
GMOCK_METHOD2_(, noexcept, , readError, void(StreamId, QuicError));
|
||||||
,
|
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
readError,
|
|
||||||
void(
|
|
||||||
StreamId,
|
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockPeekCallback : public QuicSocket::PeekCallback {
|
class MockPeekCallback : public QuicSocket::PeekCallback {
|
||||||
@@ -63,14 +56,7 @@ class MockPeekCallback : public QuicSocket::PeekCallback {
|
|||||||
,
|
,
|
||||||
onDataAvailable,
|
onDataAvailable,
|
||||||
void(StreamId, const folly::Range<PeekIterator>&));
|
void(StreamId, const folly::Range<PeekIterator>&));
|
||||||
GMOCK_METHOD2_(
|
GMOCK_METHOD2_(, noexcept, , peekError, void(StreamId, QuicError));
|
||||||
,
|
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
peekError,
|
|
||||||
void(
|
|
||||||
StreamId,
|
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockDatagramCallback : public QuicSocket::DatagramCallback {
|
class MockDatagramCallback : public QuicSocket::DatagramCallback {
|
||||||
@@ -85,31 +71,14 @@ class MockWriteCallback : public QuicSocket::WriteCallback {
|
|||||||
|
|
||||||
GMOCK_METHOD2_(, noexcept, , onStreamWriteReady, void(StreamId, uint64_t));
|
GMOCK_METHOD2_(, noexcept, , onStreamWriteReady, void(StreamId, uint64_t));
|
||||||
GMOCK_METHOD1_(, noexcept, , onConnectionWriteReady, void(uint64_t));
|
GMOCK_METHOD1_(, noexcept, , onConnectionWriteReady, void(uint64_t));
|
||||||
GMOCK_METHOD2_(
|
GMOCK_METHOD2_(, noexcept, , onStreamWriteError, void(StreamId, QuicError));
|
||||||
,
|
GMOCK_METHOD1_(, noexcept, , onConnectionWriteError, void(QuicError));
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
onStreamWriteError,
|
|
||||||
void(
|
|
||||||
StreamId,
|
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>));
|
|
||||||
GMOCK_METHOD1_(
|
|
||||||
,
|
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
onConnectionWriteError,
|
|
||||||
void(std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockConnectionSetupCallback : public QuicSocket::ConnectionSetupCallback {
|
class MockConnectionSetupCallback : public QuicSocket::ConnectionSetupCallback {
|
||||||
public:
|
public:
|
||||||
~MockConnectionSetupCallback() override = default;
|
~MockConnectionSetupCallback() override = default;
|
||||||
GMOCK_METHOD1_(
|
GMOCK_METHOD1_(, noexcept, , onConnectionSetupError, void(QuicError));
|
||||||
,
|
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
onConnectionSetupError,
|
|
||||||
void(std::pair<QuicErrorCode, std::string>));
|
|
||||||
GMOCK_METHOD0_(, noexcept, , onReplaySafe, void());
|
GMOCK_METHOD0_(, noexcept, , onReplaySafe, void());
|
||||||
GMOCK_METHOD0_(, noexcept, , onTransportReady, void());
|
GMOCK_METHOD0_(, noexcept, , onTransportReady, void());
|
||||||
GMOCK_METHOD0_(, noexcept, , onFirstPeerPacketProcessed, void());
|
GMOCK_METHOD0_(, noexcept, , onFirstPeerPacketProcessed, void());
|
||||||
@@ -129,12 +98,7 @@ class MockConnectionCallbackNew : public QuicSocket::ConnectionCallbackNew {
|
|||||||
onStopSending,
|
onStopSending,
|
||||||
void(StreamId, ApplicationErrorCode));
|
void(StreamId, ApplicationErrorCode));
|
||||||
GMOCK_METHOD0_(, noexcept, , onConnectionEnd, void());
|
GMOCK_METHOD0_(, noexcept, , onConnectionEnd, void());
|
||||||
GMOCK_METHOD1_(
|
GMOCK_METHOD1_(, noexcept, , onConnectionError, void(QuicError));
|
||||||
,
|
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
onConnectionError,
|
|
||||||
void(std::pair<QuicErrorCode, std::string>));
|
|
||||||
GMOCK_METHOD1_(, noexcept, , onBidirectionalStreamsAvailable, void(uint64_t));
|
GMOCK_METHOD1_(, noexcept, , onBidirectionalStreamsAvailable, void(uint64_t));
|
||||||
GMOCK_METHOD1_(
|
GMOCK_METHOD1_(
|
||||||
,
|
,
|
||||||
@@ -289,19 +253,9 @@ class MockQuicTransport : public QuicServerTransport {
|
|||||||
setServerConnectionIdParams,
|
setServerConnectionIdParams,
|
||||||
void(ServerConnectionIdParams));
|
void(ServerConnectionIdParams));
|
||||||
|
|
||||||
GMOCK_METHOD1_(
|
GMOCK_METHOD1_(, noexcept, , close, void(folly::Optional<QuicError>));
|
||||||
,
|
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
close,
|
|
||||||
void(folly::Optional<std::pair<QuicErrorCode, std::string>>));
|
|
||||||
|
|
||||||
GMOCK_METHOD1_(
|
GMOCK_METHOD1_(, noexcept, , closeNow, void(folly::Optional<QuicError>));
|
||||||
,
|
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
closeNow,
|
|
||||||
void(folly::Optional<std::pair<QuicErrorCode, std::string>>));
|
|
||||||
|
|
||||||
GMOCK_METHOD0_(, const, , hasShutdown, bool());
|
GMOCK_METHOD0_(, const, , hasShutdown, bool());
|
||||||
|
|
||||||
@@ -354,9 +308,7 @@ class MockObserver : public Observer {
|
|||||||
noexcept,
|
noexcept,
|
||||||
,
|
,
|
||||||
close,
|
close,
|
||||||
void(
|
void(QuicSocket*, const folly::Optional<QuicError>&));
|
||||||
QuicSocket*,
|
|
||||||
const folly::Optional<std::pair<QuicErrorCode, std::string>>&));
|
|
||||||
GMOCK_METHOD2_(
|
GMOCK_METHOD2_(
|
||||||
,
|
,
|
||||||
noexcept,
|
noexcept,
|
||||||
|
@@ -218,7 +218,7 @@ class TestQuicTransport
|
|||||||
resetConnectionCallbacks();
|
resetConnectionCallbacks();
|
||||||
// we need to call close in the derived class.
|
// we need to call close in the derived class.
|
||||||
closeImpl(
|
closeImpl(
|
||||||
std::make_pair(
|
QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
||||||
std::string("shutdown")),
|
std::string("shutdown")),
|
||||||
false);
|
false);
|
||||||
@@ -439,7 +439,7 @@ class TestQuicTransport
|
|||||||
}
|
}
|
||||||
|
|
||||||
QuicErrorCode getConnectionError() {
|
QuicErrorCode getConnectionError() {
|
||||||
return conn_->localConnectionError->first;
|
return conn_->localConnectionError->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isClosed() const noexcept {
|
bool isClosed() const noexcept {
|
||||||
@@ -578,8 +578,7 @@ TEST_F(QuicTransportImplTest, IdleTimeoutStreamMaessage) {
|
|||||||
EXPECT_CALL(readCb1, readError(stream1, _))
|
EXPECT_CALL(readCb1, readError(stream1, _))
|
||||||
.Times(1)
|
.Times(1)
|
||||||
.WillOnce(Invoke([](auto, auto error) {
|
.WillOnce(Invoke([](auto, auto error) {
|
||||||
EXPECT_EQ(
|
EXPECT_EQ("Idle timeout, num non control streams: 2", error.message);
|
||||||
"Idle timeout, num non control streams: 2", error.second->str());
|
|
||||||
}));
|
}));
|
||||||
transport->invokeIdleTimeout();
|
transport->invokeIdleTimeout();
|
||||||
}
|
}
|
||||||
@@ -1386,12 +1385,9 @@ TEST_F(QuicTransportImplTest, ReadErrorUnsanitizedErrorMsg) {
|
|||||||
transport->setReadCallback(stream, &rcb);
|
transport->setReadCallback(stream, &rcb);
|
||||||
EXPECT_CALL(rcb, readError(stream, _))
|
EXPECT_CALL(rcb, readError(stream, _))
|
||||||
.Times(1)
|
.Times(1)
|
||||||
.WillOnce(Invoke(
|
.WillOnce(Invoke([](StreamId, QuicError error) {
|
||||||
[](StreamId,
|
EXPECT_EQ("You need to calm down.", error.message);
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>
|
}));
|
||||||
error) {
|
|
||||||
EXPECT_EQ("You need to calm down.", *error.second);
|
|
||||||
}));
|
|
||||||
|
|
||||||
EXPECT_CALL(*socketPtr, write(_, _)).WillOnce(Invoke([](auto&, auto&) {
|
EXPECT_CALL(*socketPtr, write(_, _)).WillOnce(Invoke([](auto&, auto&) {
|
||||||
throw std::runtime_error("You need to calm down.");
|
throw std::runtime_error("You need to calm down.");
|
||||||
@@ -1412,7 +1408,7 @@ TEST_F(QuicTransportImplTest, ConnectionErrorUnhandledException) {
|
|||||||
auto stream = transport->createBidirectionalStream().value();
|
auto stream = transport->createBidirectionalStream().value();
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
connSetupCallback,
|
connSetupCallback,
|
||||||
onConnectionSetupError(std::make_pair(
|
onConnectionSetupError(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("Well there's your problem"))));
|
std::string("Well there's your problem"))));
|
||||||
EXPECT_CALL(*socketPtr, write(_, _)).WillOnce(Invoke([](auto&, auto&) {
|
EXPECT_CALL(*socketPtr, write(_, _)).WillOnce(Invoke([](auto&, auto&) {
|
||||||
@@ -2505,7 +2501,7 @@ TEST_P(QuicTransportImplTestClose, TestNotifyPendingConnWriteOnCloseWithError) {
|
|||||||
wcb,
|
wcb,
|
||||||
onConnectionWriteError(
|
onConnectionWriteError(
|
||||||
IsAppError(GenericApplicationErrorCode::UNKNOWN)));
|
IsAppError(GenericApplicationErrorCode::UNKNOWN)));
|
||||||
transport->close(std::make_pair(
|
transport->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("Bye")));
|
std::string("Bye")));
|
||||||
} else {
|
} else {
|
||||||
@@ -2546,7 +2542,7 @@ TEST_P(QuicTransportImplTestClose, TestNotifyPendingWriteOnCloseWithError) {
|
|||||||
wcb,
|
wcb,
|
||||||
onStreamWriteError(
|
onStreamWriteError(
|
||||||
stream, IsAppError(GenericApplicationErrorCode::UNKNOWN)));
|
stream, IsAppError(GenericApplicationErrorCode::UNKNOWN)));
|
||||||
transport->close(std::make_pair(
|
transport->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("Bye")));
|
std::string("Bye")));
|
||||||
} else {
|
} else {
|
||||||
@@ -2709,7 +2705,7 @@ TEST_F(QuicTransportImplTest, TestImmediateClose) {
|
|||||||
EXPECT_CALL(txCb, onByteEventRegistered(getTxMatcher(stream, 4)));
|
EXPECT_CALL(txCb, onByteEventRegistered(getTxMatcher(stream, 4)));
|
||||||
EXPECT_FALSE(transport->registerTxCallback(stream, 0, &txCb).hasError());
|
EXPECT_FALSE(transport->registerTxCallback(stream, 0, &txCb).hasError());
|
||||||
EXPECT_FALSE(transport->registerTxCallback(stream, 4, &txCb).hasError());
|
EXPECT_FALSE(transport->registerTxCallback(stream, 4, &txCb).hasError());
|
||||||
transport->close(std::make_pair(
|
transport->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("Error")));
|
std::string("Error")));
|
||||||
|
|
||||||
@@ -3635,15 +3631,11 @@ TEST_F(QuicTransportImplTest, ObserverCloseNoErrorThenDestroyTransport) {
|
|||||||
transport->addObserver(cb.get());
|
transport->addObserver(cb.get());
|
||||||
EXPECT_THAT(transport->getObservers(), UnorderedElementsAre(cb.get()));
|
EXPECT_THAT(transport->getObservers(), UnorderedElementsAre(cb.get()));
|
||||||
|
|
||||||
const std::pair<QuicErrorCode, std::string> defaultError = std::make_pair(
|
const QuicError defaultError = QuicError(
|
||||||
GenericApplicationErrorCode::NO_ERROR,
|
GenericApplicationErrorCode::NO_ERROR,
|
||||||
toString(GenericApplicationErrorCode::NO_ERROR));
|
toString(GenericApplicationErrorCode::NO_ERROR));
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*cb,
|
*cb, close(transport.get(), folly::Optional<QuicError>(defaultError)));
|
||||||
close(
|
|
||||||
transport.get(),
|
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>>(
|
|
||||||
defaultError)));
|
|
||||||
transport->close(folly::none);
|
transport->close(folly::none);
|
||||||
Mock::VerifyAndClearExpectations(cb.get());
|
Mock::VerifyAndClearExpectations(cb.get());
|
||||||
InSequence s;
|
InSequence s;
|
||||||
@@ -3658,14 +3650,11 @@ TEST_F(QuicTransportImplTest, ObserverCloseWithErrorThenDestroyTransport) {
|
|||||||
transport->addObserver(cb.get());
|
transport->addObserver(cb.get());
|
||||||
EXPECT_THAT(transport->getObservers(), UnorderedElementsAre(cb.get()));
|
EXPECT_THAT(transport->getObservers(), UnorderedElementsAre(cb.get()));
|
||||||
|
|
||||||
const auto testError = std::make_pair(
|
const auto testError = QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::CONNECTION_RESET),
|
QuicErrorCode(LocalErrorCode::CONNECTION_RESET),
|
||||||
std::string("testError"));
|
std::string("testError"));
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*cb,
|
*cb, close(transport.get(), folly::Optional<QuicError>(testError)));
|
||||||
close(
|
|
||||||
transport.get(),
|
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>>(testError)));
|
|
||||||
transport->close(testError);
|
transport->close(testError);
|
||||||
Mock::VerifyAndClearExpectations(cb.get());
|
Mock::VerifyAndClearExpectations(cb.get());
|
||||||
InSequence s;
|
InSequence s;
|
||||||
|
@@ -1675,9 +1675,9 @@ TEST_F(QuicTransportTest, PathValidationTimeoutExpired) {
|
|||||||
EXPECT_EQ(transport_->closeState(), CloseState::CLOSED);
|
EXPECT_EQ(transport_->closeState(), CloseState::CLOSED);
|
||||||
EXPECT_TRUE(conn.localConnectionError);
|
EXPECT_TRUE(conn.localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
conn.localConnectionError->first,
|
conn.localConnectionError->code,
|
||||||
QuicErrorCode(TransportErrorCode::INVALID_MIGRATION));
|
QuicErrorCode(TransportErrorCode::INVALID_MIGRATION));
|
||||||
EXPECT_EQ(conn.localConnectionError->second, "Path validation timed out");
|
EXPECT_EQ(conn.localConnectionError->message, "Path validation timed out");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicTransportTest, SendPathValidationWhileThereIsOutstandingOne) {
|
TEST_F(QuicTransportTest, SendPathValidationWhileThereIsOutstandingOne) {
|
||||||
|
@@ -490,15 +490,11 @@ TYPED_TEST(
|
|||||||
transport->addObserver(observer.get());
|
transport->addObserver(observer.get());
|
||||||
EXPECT_THAT(transport->getObservers(), UnorderedElementsAre(observer.get()));
|
EXPECT_THAT(transport->getObservers(), UnorderedElementsAre(observer.get()));
|
||||||
|
|
||||||
const std::pair<QuicErrorCode, std::string> defaultError = std::make_pair(
|
const QuicError defaultError = QuicError(
|
||||||
GenericApplicationErrorCode::NO_ERROR,
|
GenericApplicationErrorCode::NO_ERROR,
|
||||||
toString(GenericApplicationErrorCode::NO_ERROR));
|
toString(GenericApplicationErrorCode::NO_ERROR));
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*observer,
|
*observer, close(transport, folly::Optional<QuicError>(defaultError)));
|
||||||
close(
|
|
||||||
transport,
|
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>>(
|
|
||||||
defaultError)));
|
|
||||||
transport->close(folly::none);
|
transport->close(folly::none);
|
||||||
Mock::VerifyAndClearExpectations(observer.get());
|
Mock::VerifyAndClearExpectations(observer.get());
|
||||||
InSequence s;
|
InSequence s;
|
||||||
@@ -517,14 +513,11 @@ TYPED_TEST(
|
|||||||
transport->addObserver(observer.get());
|
transport->addObserver(observer.get());
|
||||||
EXPECT_THAT(transport->getObservers(), UnorderedElementsAre(observer.get()));
|
EXPECT_THAT(transport->getObservers(), UnorderedElementsAre(observer.get()));
|
||||||
|
|
||||||
const auto testError = std::make_pair(
|
const auto testError = QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::CONNECTION_RESET),
|
QuicErrorCode(LocalErrorCode::CONNECTION_RESET),
|
||||||
std::string("testError"));
|
std::string("testError"));
|
||||||
EXPECT_CALL(
|
EXPECT_CALL(
|
||||||
*observer,
|
*observer, close(transport, folly::Optional<QuicError>(testError)));
|
||||||
close(
|
|
||||||
transport,
|
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>>(testError)));
|
|
||||||
transport->close(testError);
|
transport->close(testError);
|
||||||
Mock::VerifyAndClearExpectations(observer.get());
|
Mock::VerifyAndClearExpectations(observer.get());
|
||||||
InSequence s;
|
InSequence s;
|
||||||
|
@@ -39,7 +39,7 @@ class TestQuicTransport
|
|||||||
// we need to call close in the derived class.
|
// we need to call close in the derived class.
|
||||||
resetConnectionCallbacks();
|
resetConnectionCallbacks();
|
||||||
closeImpl(
|
closeImpl(
|
||||||
std::make_pair(
|
QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
||||||
std::string("shutdown")),
|
std::string("shutdown")),
|
||||||
false);
|
false);
|
||||||
|
@@ -38,11 +38,10 @@ void QuicClientAsyncTransport::onConnectionEnd() noexcept {
|
|||||||
closeNowImpl(std::move(ex));
|
closeNowImpl(std::move(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicClientAsyncTransport::onConnectionError(
|
void QuicClientAsyncTransport::onConnectionError(QuicError error) noexcept {
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept {
|
|
||||||
folly::AsyncSocketException ex(
|
folly::AsyncSocketException ex(
|
||||||
folly::AsyncSocketException::UNKNOWN,
|
folly::AsyncSocketException::UNKNOWN,
|
||||||
folly::to<std::string>("Quic connection error", code.second));
|
folly::to<std::string>("Quic connection error", error.message));
|
||||||
// TODO: closeNow inside this callback may actually trigger gracefull close
|
// TODO: closeNow inside this callback may actually trigger gracefull close
|
||||||
closeNowImpl(std::move(ex));
|
closeNowImpl(std::move(ex));
|
||||||
}
|
}
|
||||||
|
@@ -36,12 +36,10 @@ class QuicClientAsyncTransport : public QuicStreamAsyncTransport,
|
|||||||
void onNewUnidirectionalStream(StreamId id) noexcept override;
|
void onNewUnidirectionalStream(StreamId id) noexcept override;
|
||||||
void onStopSending(StreamId id, ApplicationErrorCode error) noexcept override;
|
void onStopSending(StreamId id, ApplicationErrorCode error) noexcept override;
|
||||||
void onConnectionEnd() noexcept override;
|
void onConnectionEnd() noexcept override;
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError code) noexcept override {
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept override {
|
|
||||||
onConnectionError(std::move(code));
|
onConnectionError(std::move(code));
|
||||||
}
|
}
|
||||||
void onConnectionError(
|
void onConnectionError(QuicError code) noexcept override;
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept override;
|
|
||||||
void onTransportReady() noexcept override;
|
void onTransportReady() noexcept override;
|
||||||
};
|
};
|
||||||
} // namespace quic
|
} // namespace quic
|
||||||
|
@@ -93,7 +93,7 @@ QuicClientTransport::~QuicClientTransport() {
|
|||||||
resetConnectionCallbacks();
|
resetConnectionCallbacks();
|
||||||
// Close without draining.
|
// Close without draining.
|
||||||
closeImpl(
|
closeImpl(
|
||||||
std::make_pair(
|
QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
||||||
std::string("Closing from client destructor")),
|
std::string("Closing from client destructor")),
|
||||||
false);
|
false);
|
||||||
@@ -181,7 +181,7 @@ void QuicClientTransport::processPacketData(
|
|||||||
const auto& token = clientConn_->statelessResetToken;
|
const auto& token = clientConn_->statelessResetToken;
|
||||||
if (statelessReset->token == token) {
|
if (statelessReset->token == token) {
|
||||||
VLOG(4) << "Received Stateless Reset " << *this;
|
VLOG(4) << "Received Stateless Reset " << *this;
|
||||||
conn_->peerConnectionError = std::make_pair(
|
conn_->peerConnectionError = QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::CONNECTION_RESET),
|
QuicErrorCode(LocalErrorCode::CONNECTION_RESET),
|
||||||
toString(LocalErrorCode::CONNECTION_RESET).str());
|
toString(LocalErrorCode::CONNECTION_RESET).str());
|
||||||
throw QuicInternalException("Peer reset", LocalErrorCode::NO_ERROR);
|
throw QuicInternalException("Peer reset", LocalErrorCode::NO_ERROR);
|
||||||
@@ -564,8 +564,8 @@ void QuicClientTransport::processPacketData(
|
|||||||
if (conn_->qLogger) {
|
if (conn_->qLogger) {
|
||||||
conn_->qLogger->addTransportStateUpdate(getPeerClose(errMsg));
|
conn_->qLogger->addTransportStateUpdate(getPeerClose(errMsg));
|
||||||
}
|
}
|
||||||
conn_->peerConnectionError = std::make_pair(
|
conn_->peerConnectionError =
|
||||||
QuicErrorCode(connFrame.errorCode), std::move(errMsg));
|
QuicError(QuicErrorCode(connFrame.errorCode), std::move(errMsg));
|
||||||
throw QuicTransportException(
|
throw QuicTransportException(
|
||||||
"Peer closed", TransportErrorCode::NO_ERROR);
|
"Peer closed", TransportErrorCode::NO_ERROR);
|
||||||
break;
|
break;
|
||||||
@@ -1051,8 +1051,8 @@ void QuicClientTransport::errMessage(
|
|||||||
if (!happyEyeballsState.shouldWriteToFirstSocket &&
|
if (!happyEyeballsState.shouldWriteToFirstSocket &&
|
||||||
!happyEyeballsState.shouldWriteToSecondSocket) {
|
!happyEyeballsState.shouldWriteToSecondSocket) {
|
||||||
runOnEvbAsync([errString = std::move(errStr)](auto self) {
|
runOnEvbAsync([errString = std::move(errStr)](auto self) {
|
||||||
auto quicError = std::make_pair(
|
auto quicError =
|
||||||
QuicErrorCode(LocalErrorCode::CONNECT_FAILED), errString);
|
QuicError(QuicErrorCode(LocalErrorCode::CONNECT_FAILED), errString);
|
||||||
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
||||||
clientPtr->closeImpl(std::move(quicError), false, false);
|
clientPtr->closeImpl(std::move(quicError), false, false);
|
||||||
});
|
});
|
||||||
@@ -1069,7 +1069,7 @@ void QuicClientTransport::onReadError(
|
|||||||
// draining the socket.
|
// draining the socket.
|
||||||
runOnEvbAsync([ex](auto self) {
|
runOnEvbAsync([ex](auto self) {
|
||||||
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
||||||
clientPtr->closeNow(std::make_pair(
|
clientPtr->closeNow(QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::CONNECTION_ABANDONED),
|
QuicErrorCode(LocalErrorCode::CONNECTION_ABANDONED),
|
||||||
std::string(ex.what())));
|
std::string(ex.what())));
|
||||||
});
|
});
|
||||||
@@ -1546,20 +1546,20 @@ void QuicClientTransport::start(
|
|||||||
} catch (const QuicTransportException& ex) {
|
} catch (const QuicTransportException& ex) {
|
||||||
runOnEvbAsync([ex](auto self) {
|
runOnEvbAsync([ex](auto self) {
|
||||||
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
||||||
clientPtr->closeImpl(std::make_pair(
|
clientPtr->closeImpl(
|
||||||
QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
QuicError(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
||||||
});
|
});
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
runOnEvbAsync([ex](auto self) {
|
runOnEvbAsync([ex](auto self) {
|
||||||
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
||||||
clientPtr->closeImpl(std::make_pair(
|
clientPtr->closeImpl(
|
||||||
QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
QuicError(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
||||||
});
|
});
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
LOG(ERROR) << "Connect failed " << ex.what();
|
LOG(ERROR) << "Connect failed " << ex.what();
|
||||||
runOnEvbAsync([ex](auto self) {
|
runOnEvbAsync([ex](auto self) {
|
||||||
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
auto clientPtr = static_cast<QuicClientTransport*>(self.get());
|
||||||
clientPtr->closeImpl(std::make_pair(
|
clientPtr->closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string(ex.what())));
|
std::string(ex.what())));
|
||||||
});
|
});
|
||||||
|
@@ -19,8 +19,7 @@ namespace quic {
|
|||||||
|
|
||||||
QuicConnector::QuicConnector(Callback* cb) : cb_(CHECK_NOTNULL(cb)) {}
|
QuicConnector::QuicConnector(Callback* cb) : cb_(CHECK_NOTNULL(cb)) {}
|
||||||
|
|
||||||
void QuicConnector::onConnectionSetupError(
|
void QuicConnector::onConnectionSetupError(QuicError code) noexcept {
|
||||||
std::pair<quic::QuicErrorCode, std::string> code) noexcept {
|
|
||||||
if (cb_) {
|
if (cb_) {
|
||||||
cb_->onConnectError(std::move(code));
|
cb_->onConnectError(std::move(code));
|
||||||
}
|
}
|
||||||
@@ -108,7 +107,7 @@ void QuicConnector::cleanUp() {
|
|||||||
|
|
||||||
void QuicConnector::cleanUpAndCloseSocket() {
|
void QuicConnector::cleanUpAndCloseSocket() {
|
||||||
if (quicClient_) {
|
if (quicClient_) {
|
||||||
auto error = std::make_pair(
|
auto error = QuicError(
|
||||||
quic::QuicErrorCode(quic::LocalErrorCode::SHUTTING_DOWN),
|
quic::QuicErrorCode(quic::LocalErrorCode::SHUTTING_DOWN),
|
||||||
std::string("shutting down"));
|
std::string("shutting down"));
|
||||||
quicClient_->close(std::move(error));
|
quicClient_->close(std::move(error));
|
||||||
@@ -122,7 +121,7 @@ std::chrono::milliseconds QuicConnector::timeElapsed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuicConnector::timeoutExpired() noexcept {
|
void QuicConnector::timeoutExpired() noexcept {
|
||||||
auto error = std::make_pair(
|
auto error = QuicError(
|
||||||
quic::QuicErrorCode(quic::LocalErrorCode::CONNECT_FAILED),
|
quic::QuicErrorCode(quic::LocalErrorCode::CONNECT_FAILED),
|
||||||
std::string("connect operation timed out"));
|
std::string("connect operation timed out"));
|
||||||
if (quicClient_) {
|
if (quicClient_) {
|
||||||
|
@@ -31,8 +31,7 @@ class QuicConnector : private quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
class Callback {
|
class Callback {
|
||||||
public:
|
public:
|
||||||
virtual ~Callback() = default;
|
virtual ~Callback() = default;
|
||||||
virtual void onConnectError(
|
virtual void onConnectError(QuicError errorCode) = 0;
|
||||||
std::pair<quic::QuicErrorCode, std::string> errorCode) = 0;
|
|
||||||
virtual void onConnectSuccess() = 0;
|
virtual void onConnectSuccess() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -78,8 +77,7 @@ class QuicConnector : private quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
|
|
||||||
// QuicSocket::ConnectionSetupCallback overrides.
|
// QuicSocket::ConnectionSetupCallback overrides.
|
||||||
void onFirstPeerPacketProcessed() noexcept override {}
|
void onFirstPeerPacketProcessed() noexcept override {}
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError code) noexcept override;
|
||||||
std::pair<quic::QuicErrorCode, std::string> code) noexcept override;
|
|
||||||
void onTransportReady() noexcept override {}
|
void onTransportReady() noexcept override {}
|
||||||
void onReplaySafe() noexcept override;
|
void onReplaySafe() noexcept override;
|
||||||
|
|
||||||
|
@@ -76,9 +76,7 @@ class MockClientHandshake : public ClientHandshake {
|
|||||||
|
|
||||||
class MockQuicConnectorCallback : public quic::QuicConnector::Callback {
|
class MockQuicConnectorCallback : public quic::QuicConnector::Callback {
|
||||||
public:
|
public:
|
||||||
MOCK_METHOD1(
|
MOCK_METHOD1(onConnectError, void(QuicError));
|
||||||
onConnectError,
|
|
||||||
void(std::pair<quic::QuicErrorCode, std::string>));
|
|
||||||
MOCK_METHOD0(onConnectSuccess, void());
|
MOCK_METHOD0(onConnectSuccess, void());
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -99,7 +97,7 @@ class MockQuicClientTransport : public quic::QuicClientTransport {
|
|||||||
|
|
||||||
void start(ConnectionSetupCallback* connSetupCb, ConnectionCallbackNew*)
|
void start(ConnectionSetupCallback* connSetupCb, ConnectionCallbackNew*)
|
||||||
override {
|
override {
|
||||||
auto cancelCode = std::make_pair(
|
auto cancelCode = QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::NO_ERROR),
|
QuicErrorCode(LocalErrorCode::NO_ERROR),
|
||||||
toString(LocalErrorCode::NO_ERROR).str());
|
toString(LocalErrorCode::NO_ERROR).str());
|
||||||
|
|
||||||
|
@@ -63,9 +63,7 @@ TEST_F(QuicConnectorTest, TestConnectSuccess) {
|
|||||||
TEST_F(QuicConnectorTest, TestConnectFailure) {
|
TEST_F(QuicConnectorTest, TestConnectFailure) {
|
||||||
EXPECT_CALL(cb_, onConnectError(_))
|
EXPECT_CALL(cb_, onConnectError(_))
|
||||||
.Times(1)
|
.Times(1)
|
||||||
.WillOnce(Invoke([this](std::pair<quic::QuicErrorCode, std::string>) {
|
.WillOnce(Invoke([this](QuicError) { eventBase_.terminateLoopSoon(); }));
|
||||||
eventBase_.terminateLoopSoon();
|
|
||||||
}));
|
|
||||||
executeMockConnect(
|
executeMockConnect(
|
||||||
MockQuicClientTransport::TestType::Failure,
|
MockQuicClientTransport::TestType::Failure,
|
||||||
std::chrono::milliseconds(200));
|
std::chrono::milliseconds(200));
|
||||||
@@ -75,9 +73,7 @@ TEST_F(QuicConnectorTest, TestConnectFailure) {
|
|||||||
TEST_F(QuicConnectorTest, TestConnectTimeout) {
|
TEST_F(QuicConnectorTest, TestConnectTimeout) {
|
||||||
EXPECT_CALL(cb_, onConnectError(_))
|
EXPECT_CALL(cb_, onConnectError(_))
|
||||||
.Times(1)
|
.Times(1)
|
||||||
.WillOnce(Invoke([this](std::pair<quic::QuicErrorCode, std::string>) {
|
.WillOnce(Invoke([this](QuicError) { eventBase_.terminateLoopSoon(); }));
|
||||||
eventBase_.terminateLoopSoon();
|
|
||||||
}));
|
|
||||||
executeMockConnect(
|
executeMockConnect(
|
||||||
MockQuicClientTransport::TestType::Timeout, std::chrono::milliseconds(1));
|
MockQuicClientTransport::TestType::Timeout, std::chrono::milliseconds(1));
|
||||||
eventBase_.loopForever();
|
eventBase_.loopForever();
|
||||||
|
@@ -706,39 +706,19 @@ std::vector<int> getQLogEventIndices(
|
|||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matchError(
|
bool matchError(QuicError errorCode, LocalErrorCode error) {
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>> errorCode,
|
return errorCode.code.type() == QuicErrorCode::Type::LocalErrorCode &&
|
||||||
LocalErrorCode error) {
|
*errorCode.code.asLocalErrorCode() == error;
|
||||||
return errorCode.first.type() == QuicErrorCode::Type::LocalErrorCode &&
|
|
||||||
*errorCode.first.asLocalErrorCode() == error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matchError(
|
bool matchError(QuicError errorCode, TransportErrorCode error) {
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>> errorCode,
|
return errorCode.code.type() == QuicErrorCode::Type::TransportErrorCode &&
|
||||||
TransportErrorCode error) {
|
*errorCode.code.asTransportErrorCode() == error;
|
||||||
return errorCode.first.type() == QuicErrorCode::Type::TransportErrorCode &&
|
|
||||||
*errorCode.first.asTransportErrorCode() == error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matchError(
|
bool matchError(QuicError errorCode, ApplicationErrorCode error) {
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>> errorCode,
|
return errorCode.code.type() == QuicErrorCode::Type::ApplicationErrorCode &&
|
||||||
ApplicationErrorCode error) {
|
*errorCode.code.asApplicationErrorCode() == error;
|
||||||
return errorCode.first.type() == QuicErrorCode::Type::ApplicationErrorCode &&
|
|
||||||
*errorCode.first.asApplicationErrorCode() == error;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool matchError(
|
|
||||||
std::pair<QuicErrorCode, std::string> errorCode,
|
|
||||||
ApplicationErrorCode error) {
|
|
||||||
return errorCode.first.type() == QuicErrorCode::Type::ApplicationErrorCode &&
|
|
||||||
*errorCode.first.asApplicationErrorCode() == error;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool matchError(
|
|
||||||
std::pair<QuicErrorCode, std::string> errorCode,
|
|
||||||
TransportErrorCode error) {
|
|
||||||
return errorCode.first.type() == QuicErrorCode::Type::TransportErrorCode &&
|
|
||||||
*errorCode.first.asTransportErrorCode() == error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CongestionController::AckEvent::AckPacket makeAckPacketFromOutstandingPacket(
|
CongestionController::AckEvent::AckPacket makeAckPacketFromOutstandingPacket(
|
||||||
|
@@ -174,25 +174,9 @@ uint64_t computeExpectedDelay(
|
|||||||
uint8_t ackDelayExponent);
|
uint8_t ackDelayExponent);
|
||||||
|
|
||||||
// match error functions
|
// match error functions
|
||||||
bool matchError(
|
bool matchError(QuicError errorCode, LocalErrorCode error);
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>> errorCode,
|
bool matchError(QuicError errorCode, TransportErrorCode error);
|
||||||
LocalErrorCode error);
|
bool matchError(QuicError errorCode, ApplicationErrorCode error);
|
||||||
|
|
||||||
bool matchError(
|
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>> errorCode,
|
|
||||||
TransportErrorCode error);
|
|
||||||
|
|
||||||
bool matchError(
|
|
||||||
std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>> errorCode,
|
|
||||||
ApplicationErrorCode error);
|
|
||||||
|
|
||||||
bool matchError(
|
|
||||||
std::pair<QuicErrorCode, std::string> errorCode,
|
|
||||||
ApplicationErrorCode error);
|
|
||||||
|
|
||||||
bool matchError(
|
|
||||||
std::pair<QuicErrorCode, std::string> errorCode,
|
|
||||||
TransportErrorCode error);
|
|
||||||
|
|
||||||
ConnectionId getTestConnectionId(
|
ConnectionId getTestConnectionId(
|
||||||
uint32_t hostId = 0,
|
uint32_t hostId = 0,
|
||||||
|
@@ -266,9 +266,7 @@ class StreamData {
|
|||||||
|
|
||||||
explicit StreamData(StreamId id) : id(id) {}
|
explicit StreamData(StreamId id) : id(id) {}
|
||||||
|
|
||||||
void setException(
|
void setException(const QuicError& err) {
|
||||||
const std::pair<QuicErrorCode, folly::Optional<folly::StringPiece>>&
|
|
||||||
err) {
|
|
||||||
promise.setException(std::runtime_error(toString(err)));
|
promise.setException(std::runtime_error(toString(err)));
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
@@ -387,9 +385,9 @@ TEST_P(QuicClientTransportIntegrationTest, TLSAlert) {
|
|||||||
client->getNonConstConn().qLogger = qLogger;
|
client->getNonConstConn().qLogger = qLogger;
|
||||||
EXPECT_CALL(clientConnSetupCallback, onConnectionSetupError(_))
|
EXPECT_CALL(clientConnSetupCallback, onConnectionSetupError(_))
|
||||||
.WillOnce(Invoke([&](const auto& errorCode) {
|
.WillOnce(Invoke([&](const auto& errorCode) {
|
||||||
LOG(ERROR) << "error: " << errorCode.second;
|
LOG(ERROR) << "error: " << errorCode.message;
|
||||||
const TransportErrorCode* transportError =
|
const TransportErrorCode* transportError =
|
||||||
errorCode.first.asTransportErrorCode();
|
errorCode.code.asTransportErrorCode();
|
||||||
EXPECT_NE(transportError, nullptr);
|
EXPECT_NE(transportError, nullptr);
|
||||||
client->close(folly::none);
|
client->close(folly::none);
|
||||||
this->checkTransportSummaryEvent(qLogger);
|
this->checkTransportSummaryEvent(qLogger);
|
||||||
@@ -413,8 +411,8 @@ TEST_P(QuicClientTransportIntegrationTest, BadServerTest) {
|
|||||||
client->setTransportSettings(tp);
|
client->setTransportSettings(tp);
|
||||||
EXPECT_CALL(clientConnSetupCallback, onConnectionSetupError(_))
|
EXPECT_CALL(clientConnSetupCallback, onConnectionSetupError(_))
|
||||||
.WillOnce(Invoke([&](const auto& errorCode) {
|
.WillOnce(Invoke([&](const auto& errorCode) {
|
||||||
LOG(ERROR) << "error: " << errorCode.second;
|
LOG(ERROR) << "error: " << errorCode.message;
|
||||||
const LocalErrorCode* localError = errorCode.first.asLocalErrorCode();
|
const LocalErrorCode* localError = errorCode.code.asLocalErrorCode();
|
||||||
EXPECT_NE(localError, nullptr);
|
EXPECT_NE(localError, nullptr);
|
||||||
this->checkTransportSummaryEvent(qLogger);
|
this->checkTransportSummaryEvent(qLogger);
|
||||||
}));
|
}));
|
||||||
@@ -1078,16 +1076,10 @@ TEST_F(QuicClientTransportTest, SocketClosedDuringOnTransportReady) {
|
|||||||
GMOCK_METHOD0_(, noexcept, , onTransportReadyMock, void());
|
GMOCK_METHOD0_(, noexcept, , onTransportReadyMock, void());
|
||||||
GMOCK_METHOD0_(, noexcept, , onReplaySafe, void());
|
GMOCK_METHOD0_(, noexcept, , onReplaySafe, void());
|
||||||
GMOCK_METHOD0_(, noexcept, , onConnectionEnd, void());
|
GMOCK_METHOD0_(, noexcept, , onConnectionEnd, void());
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
|
||||||
onConnectionError(std::move(error));
|
onConnectionError(std::move(error));
|
||||||
}
|
}
|
||||||
GMOCK_METHOD1_(
|
GMOCK_METHOD1_(, noexcept, , onConnectionError, void(QuicError));
|
||||||
,
|
|
||||||
noexcept,
|
|
||||||
,
|
|
||||||
onConnectionError,
|
|
||||||
void(std::pair<QuicErrorCode, std::string>));
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QuicSocket> socket_;
|
std::shared_ptr<QuicSocket> socket_;
|
||||||
@@ -3036,7 +3028,7 @@ TEST_P(
|
|||||||
socketWrites.clear();
|
socketWrites.clear();
|
||||||
EXPECT_CALL(readCb, readError(streamId, _));
|
EXPECT_CALL(readCb, readError(streamId, _));
|
||||||
if (GetParam()) {
|
if (GetParam()) {
|
||||||
client->close(std::make_pair(
|
client->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("stopping")));
|
std::string("stopping")));
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
@@ -3203,7 +3195,7 @@ TEST_P(QuicClientTransportAfterStartTestClose, CloseConnectionWithError) {
|
|||||||
deliverData(packet->coalesce());
|
deliverData(packet->coalesce());
|
||||||
socketWrites.clear();
|
socketWrites.clear();
|
||||||
if (GetParam()) {
|
if (GetParam()) {
|
||||||
client->close(std::make_pair(
|
client->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("stopping")));
|
std::string("stopping")));
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
@@ -3336,7 +3328,7 @@ TEST_P(QuicClientTransportAfterStartTestClose, TimeoutsNotSetAfterClose) {
|
|||||||
0 /* largestAcked */));
|
0 /* largestAcked */));
|
||||||
|
|
||||||
if (GetParam()) {
|
if (GetParam()) {
|
||||||
client->close(std::make_pair(
|
client->close(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("how about no")));
|
std::string("how about no")));
|
||||||
} else {
|
} else {
|
||||||
@@ -4359,7 +4351,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReceiveConnectionClose) {
|
|||||||
// Now the transport should be closed
|
// Now the transport should be closed
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
||||||
client->getConn().localConnectionError->first);
|
client->getConn().localConnectionError->code);
|
||||||
EXPECT_TRUE(client->isClosed());
|
EXPECT_TRUE(client->isClosed());
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
socketWrites,
|
socketWrites,
|
||||||
@@ -4391,7 +4383,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReceiveApplicationClose) {
|
|||||||
// Now the transport should be closed
|
// Now the transport should be closed
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
||||||
client->getConn().localConnectionError->first);
|
client->getConn().localConnectionError->code);
|
||||||
EXPECT_TRUE(client->isClosed());
|
EXPECT_TRUE(client->isClosed());
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
socketWrites,
|
socketWrites,
|
||||||
@@ -4428,7 +4420,7 @@ TEST_F(QuicClientTransportAfterStartTest, ReceiveApplicationCloseNoError) {
|
|||||||
// Now the transport should be closed
|
// Now the transport should be closed
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
||||||
client->getConn().localConnectionError->first);
|
client->getConn().localConnectionError->code);
|
||||||
EXPECT_TRUE(client->isClosed());
|
EXPECT_TRUE(client->isClosed());
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
socketWrites,
|
socketWrites,
|
||||||
@@ -4472,7 +4464,7 @@ TEST_F(QuicClientTransportAfterStartTest, DestroyWhileDraining) {
|
|||||||
|
|
||||||
TEST_F(QuicClientTransportAfterStartTest, CloseNowWhileDraining) {
|
TEST_F(QuicClientTransportAfterStartTest, CloseNowWhileDraining) {
|
||||||
// Drain first with no active streams
|
// Drain first with no active streams
|
||||||
auto err = std::make_pair<QuicErrorCode, std::string>(
|
auto err = QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(LocalErrorCode::INTERNAL_ERROR),
|
||||||
toString(LocalErrorCode::INTERNAL_ERROR).str());
|
toString(LocalErrorCode::INTERNAL_ERROR).str());
|
||||||
client->close(err);
|
client->close(err);
|
||||||
@@ -4484,7 +4476,7 @@ TEST_F(QuicClientTransportAfterStartTest, CloseNowWhileDraining) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicClientTransportAfterStartTest, ExpiredDrainTimeout) {
|
TEST_F(QuicClientTransportAfterStartTest, ExpiredDrainTimeout) {
|
||||||
auto err = std::make_pair<QuicErrorCode, std::string>(
|
auto err = QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(LocalErrorCode::INTERNAL_ERROR),
|
||||||
toString(LocalErrorCode::INTERNAL_ERROR).str());
|
toString(LocalErrorCode::INTERNAL_ERROR).str());
|
||||||
client->close(err);
|
client->close(err);
|
||||||
@@ -4497,7 +4489,7 @@ TEST_F(QuicClientTransportAfterStartTest, ExpiredDrainTimeout) {
|
|||||||
|
|
||||||
TEST_F(QuicClientTransportAfterStartTest, WriteThrowsExceptionWhileDraining) {
|
TEST_F(QuicClientTransportAfterStartTest, WriteThrowsExceptionWhileDraining) {
|
||||||
// Drain first with no active streams
|
// Drain first with no active streams
|
||||||
auto err = std::make_pair<QuicErrorCode, std::string>(
|
auto err = QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(LocalErrorCode::INTERNAL_ERROR),
|
||||||
toString(LocalErrorCode::INTERNAL_ERROR).str());
|
toString(LocalErrorCode::INTERNAL_ERROR).str());
|
||||||
EXPECT_CALL(*sock, write(_, _)).WillRepeatedly(SetErrnoAndReturn(EBADF, -1));
|
EXPECT_CALL(*sock, write(_, _)).WillRepeatedly(SetErrnoAndReturn(EBADF, -1));
|
||||||
@@ -4729,7 +4721,7 @@ TEST_F(QuicClientTransportAfterStartTest, OneCloseFramePerRtt) {
|
|||||||
// Close the client transport. There could be multiple writes given how many
|
// Close the client transport. There could be multiple writes given how many
|
||||||
// ciphers we have.
|
// ciphers we have.
|
||||||
EXPECT_CALL(*sock, write(_, _)).Times(AtLeast(1)).WillRepeatedly(Return(10));
|
EXPECT_CALL(*sock, write(_, _)).Times(AtLeast(1)).WillRepeatedly(Return(10));
|
||||||
client->close(std::make_pair<QuicErrorCode, std::string>(
|
client->close(QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(LocalErrorCode::INTERNAL_ERROR),
|
||||||
toString(LocalErrorCode::INTERNAL_ERROR).str()));
|
toString(LocalErrorCode::INTERNAL_ERROR).str()));
|
||||||
EXPECT_TRUE(conn.lastCloseSentTime.hasValue());
|
EXPECT_TRUE(conn.lastCloseSentTime.hasValue());
|
||||||
|
@@ -716,13 +716,13 @@ class QuicClientTransportTestBase : public virtual testing::Test {
|
|||||||
if (client->getConn().localConnectionError) {
|
if (client->getConn().localConnectionError) {
|
||||||
bool idleTimeout = false;
|
bool idleTimeout = false;
|
||||||
const LocalErrorCode* localError =
|
const LocalErrorCode* localError =
|
||||||
client->getConn().localConnectionError->first.asLocalErrorCode();
|
client->getConn().localConnectionError->code.asLocalErrorCode();
|
||||||
if (localError) {
|
if (localError) {
|
||||||
idleTimeout = (*localError == LocalErrorCode::IDLE_TIMEOUT);
|
idleTimeout = (*localError == LocalErrorCode::IDLE_TIMEOUT);
|
||||||
}
|
}
|
||||||
if (!idleTimeout) {
|
if (!idleTimeout) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
toString(client->getConn().localConnectionError->first));
|
toString(client->getConn().localConnectionError->code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,10 +50,7 @@ class EchoClient : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
<< " on stream=" << streamId;
|
<< " on stream=" << streamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void readError(
|
void readError(quic::StreamId streamId, QuicError error) noexcept override {
|
||||||
quic::StreamId streamId,
|
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override {
|
|
||||||
LOG(ERROR) << "EchoClient failed read from stream=" << streamId
|
LOG(ERROR) << "EchoClient failed read from stream=" << streamId
|
||||||
<< ", error=" << toString(error);
|
<< ", error=" << toString(error);
|
||||||
// A read error only terminates the ingress portion of the stream state.
|
// A read error only terminates the ingress portion of the stream state.
|
||||||
@@ -81,15 +78,13 @@ class EchoClient : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
LOG(INFO) << "EchoClient connection end";
|
LOG(INFO) << "EchoClient connection end";
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
|
||||||
onConnectionError(std::move(error));
|
onConnectionError(std::move(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionError(
|
void onConnectionError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
LOG(ERROR) << "EchoClient error: " << toString(error.code)
|
||||||
LOG(ERROR) << "EchoClient error: " << toString(error.first)
|
<< "; errStr=" << error.message;
|
||||||
<< "; errStr=" << error.second;
|
|
||||||
startDone_.post();
|
startDone_.post();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,10 +99,8 @@ class EchoClient : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
sendMessage(id, pendingOutput_[id]);
|
sendMessage(id, pendingOutput_[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onStreamWriteError(
|
void onStreamWriteError(quic::StreamId id, QuicError error) noexcept
|
||||||
quic::StreamId id,
|
override {
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override {
|
|
||||||
LOG(ERROR) << "EchoClient write error with stream=" << id
|
LOG(ERROR) << "EchoClient write error with stream=" << id
|
||||||
<< " error=" << toString(error);
|
<< " error=" << toString(error);
|
||||||
}
|
}
|
||||||
|
@@ -47,15 +47,13 @@ class EchoHandler : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
LOG(INFO) << "Socket closed";
|
LOG(INFO) << "Socket closed";
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
|
||||||
onConnectionError(std::move(error));
|
onConnectionError(std::move(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionError(
|
void onConnectionError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
LOG(ERROR) << "Socket error=" << toString(error.code) << " "
|
||||||
LOG(ERROR) << "Socket error=" << toString(error.first) << " "
|
<< error.message;
|
||||||
<< error.second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void readAvailable(quic::StreamId id) noexcept override {
|
void readAvailable(quic::StreamId id) noexcept override {
|
||||||
@@ -84,10 +82,7 @@ class EchoHandler : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void readError(
|
void readError(quic::StreamId id, QuicError error) noexcept override {
|
||||||
quic::StreamId id,
|
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override {
|
|
||||||
LOG(ERROR) << "Got read error on stream=" << id
|
LOG(ERROR) << "Got read error on stream=" << id
|
||||||
<< " error=" << toString(error);
|
<< " error=" << toString(error);
|
||||||
// A read error only terminates the ingress portion of the stream state.
|
// A read error only terminates the ingress portion of the stream state.
|
||||||
@@ -117,10 +112,8 @@ class EchoHandler : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
echo(id, input_[id]);
|
echo(id, input_[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onStreamWriteError(
|
void onStreamWriteError(quic::StreamId id, QuicError error) noexcept
|
||||||
quic::StreamId id,
|
override {
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override {
|
|
||||||
LOG(ERROR) << "write error with stream=" << id
|
LOG(ERROR) << "write error with stream=" << id
|
||||||
<< " error=" << toString(error);
|
<< " error=" << toString(error);
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,7 @@ QuicServerTransport::~QuicServerTransport() {
|
|||||||
// transport.
|
// transport.
|
||||||
resetConnectionCallbacks();
|
resetConnectionCallbacks();
|
||||||
closeImpl(
|
closeImpl(
|
||||||
std::make_pair(
|
QuicError(
|
||||||
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
QuicErrorCode(LocalErrorCode::SHUTTING_DOWN),
|
||||||
std::string("Closing from server destructor")),
|
std::string("Closing from server destructor")),
|
||||||
false);
|
false);
|
||||||
@@ -416,15 +416,13 @@ void QuicServerTransport::onCryptoEventAvailable() noexcept {
|
|||||||
maybeNotifyTransportReady();
|
maybeNotifyTransportReady();
|
||||||
} catch (const QuicTransportException& ex) {
|
} catch (const QuicTransportException& ex) {
|
||||||
VLOG(4) << "onCryptoEventAvailable() error " << ex.what() << " " << *this;
|
VLOG(4) << "onCryptoEventAvailable() error " << ex.what() << " " << *this;
|
||||||
closeImpl(
|
closeImpl(QuicError(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
||||||
std::make_pair(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
|
||||||
} catch (const QuicInternalException& ex) {
|
} catch (const QuicInternalException& ex) {
|
||||||
VLOG(4) << "onCryptoEventAvailable() error " << ex.what() << " " << *this;
|
VLOG(4) << "onCryptoEventAvailable() error " << ex.what() << " " << *this;
|
||||||
closeImpl(
|
closeImpl(QuicError(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
||||||
std::make_pair(QuicErrorCode(ex.errorCode()), std::string(ex.what())));
|
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
VLOG(4) << "read() error " << ex.what() << " " << *this;
|
VLOG(4) << "read() error " << ex.what() << " " << *this;
|
||||||
closeImpl(std::make_pair(
|
closeImpl(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string(ex.what())));
|
std::string(ex.what())));
|
||||||
}
|
}
|
||||||
|
@@ -1296,7 +1296,7 @@ void QuicServerWorker::shutdownAllConnections(LocalErrorCode error) {
|
|||||||
transport->setTransportStatsCallback(nullptr);
|
transport->setTransportStatsCallback(nullptr);
|
||||||
transport->setHandshakeFinishedCallback(nullptr);
|
transport->setHandshakeFinishedCallback(nullptr);
|
||||||
transport->closeNow(
|
transport->closeNow(
|
||||||
std::make_pair(QuicErrorCode(error), std::string("shutting down")));
|
QuicError(QuicErrorCode(error), std::string("shutting down")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shut down all transports with bound connection ids.
|
// Shut down all transports with bound connection ids.
|
||||||
@@ -1306,7 +1306,7 @@ void QuicServerWorker::shutdownAllConnections(LocalErrorCode error) {
|
|||||||
t->setTransportStatsCallback(nullptr);
|
t->setTransportStatsCallback(nullptr);
|
||||||
t->setHandshakeFinishedCallback(nullptr);
|
t->setHandshakeFinishedCallback(nullptr);
|
||||||
t->closeNow(
|
t->closeNow(
|
||||||
std::make_pair(QuicErrorCode(error), std::string("shutting down")));
|
QuicError(QuicErrorCode(error), std::string("shutting down")));
|
||||||
QUIC_STATS(statsCallback_, onConnectionClose, QuicErrorCode(error));
|
QUIC_STATS(statsCallback_, onConnectionClose, QuicErrorCode(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,11 +37,10 @@ void QuicServerAsyncTransport::onConnectionEnd() noexcept {
|
|||||||
closeNowImpl(std::move(ex));
|
closeNowImpl(std::move(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicServerAsyncTransport::onConnectionError(
|
void QuicServerAsyncTransport::onConnectionError(QuicError code) noexcept {
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept {
|
|
||||||
folly::AsyncSocketException ex(
|
folly::AsyncSocketException ex(
|
||||||
folly::AsyncSocketException::UNKNOWN,
|
folly::AsyncSocketException::UNKNOWN,
|
||||||
folly::to<std::string>("Quic connection error", code.second));
|
folly::to<std::string>("Quic connection error", code.message));
|
||||||
closeNowImpl(std::move(ex));
|
closeNowImpl(std::move(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,12 +31,10 @@ class QuicServerAsyncTransport : public QuicStreamAsyncTransport,
|
|||||||
void onNewUnidirectionalStream(StreamId id) noexcept override;
|
void onNewUnidirectionalStream(StreamId id) noexcept override;
|
||||||
void onStopSending(StreamId id, ApplicationErrorCode error) noexcept override;
|
void onStopSending(StreamId id, ApplicationErrorCode error) noexcept override;
|
||||||
void onConnectionEnd() noexcept override;
|
void onConnectionEnd() noexcept override;
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError code) noexcept override {
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept override {
|
|
||||||
onConnectionError(std::move(code));
|
onConnectionError(std::move(code));
|
||||||
}
|
}
|
||||||
void onConnectionError(
|
void onConnectionError(QuicError code) noexcept override;
|
||||||
std::pair<QuicErrorCode, std::string> code) noexcept override;
|
|
||||||
void onTransportReady() noexcept override;
|
void onTransportReady() noexcept override;
|
||||||
};
|
};
|
||||||
} // namespace quic
|
} // namespace quic
|
||||||
|
@@ -1134,8 +1134,8 @@ void onServerReadDataFromOpen(
|
|||||||
if (conn.qLogger) {
|
if (conn.qLogger) {
|
||||||
conn.qLogger->addTransportStateUpdate(getPeerClose(errMsg));
|
conn.qLogger->addTransportStateUpdate(getPeerClose(errMsg));
|
||||||
}
|
}
|
||||||
conn.peerConnectionError = std::make_pair(
|
conn.peerConnectionError =
|
||||||
QuicErrorCode(connFrame.errorCode), std::move(errMsg));
|
QuicError(QuicErrorCode(connFrame.errorCode), std::move(errMsg));
|
||||||
if (getSendConnFlowControlBytesWire(conn) == 0 &&
|
if (getSendConnFlowControlBytesWire(conn) == 0 &&
|
||||||
conn.flowControlState.sumCurStreamBufferLen) {
|
conn.flowControlState.sumCurStreamBufferLen) {
|
||||||
VLOG(2) << "Client gives up a flow control blocked connection";
|
VLOG(2) << "Client gives up a flow control blocked connection";
|
||||||
@@ -1384,8 +1384,8 @@ void onServerReadDataFromClosed(
|
|||||||
}
|
}
|
||||||
// we want to deliver app callbacks with the peer supplied error,
|
// we want to deliver app callbacks with the peer supplied error,
|
||||||
// but send a NO_ERROR to the peer.
|
// but send a NO_ERROR to the peer.
|
||||||
conn.peerConnectionError = std::make_pair(
|
conn.peerConnectionError =
|
||||||
QuicErrorCode(connFrame.errorCode), std::move(errMsg));
|
QuicError(QuicErrorCode(connFrame.errorCode), std::move(errMsg));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@@ -245,7 +245,7 @@ TEST_F(QuicServerTransportTest, TimeoutsNotSetAfterClose) {
|
|||||||
*expected,
|
*expected,
|
||||||
0 /* cipherOverhead */,
|
0 /* cipherOverhead */,
|
||||||
0 /* largestAcked */));
|
0 /* largestAcked */));
|
||||||
server->close(std::make_pair(
|
server->close(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("how about no")));
|
std::string("how about no")));
|
||||||
server->idleTimeout().cancelTimeout();
|
server->idleTimeout().cancelTimeout();
|
||||||
@@ -270,7 +270,7 @@ TEST_F(QuicServerTransportTest, InvalidMigrationNoDrain) {
|
|||||||
*expected,
|
*expected,
|
||||||
0 /* cipherOverhead */,
|
0 /* cipherOverhead */,
|
||||||
0 /* largestAcked */));
|
0 /* largestAcked */));
|
||||||
server->close(std::make_pair(
|
server->close(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INVALID_MIGRATION),
|
QuicErrorCode(TransportErrorCode::INVALID_MIGRATION),
|
||||||
std::string("migration disabled")));
|
std::string("migration disabled")));
|
||||||
server->idleTimeout().cancelTimeout();
|
server->idleTimeout().cancelTimeout();
|
||||||
@@ -314,7 +314,7 @@ TEST_F(QuicServerTransportTest, RecvDataAfterIdleTimeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicServerTransportTest, TestCloseConnectionWithError) {
|
TEST_F(QuicServerTransportTest, TestCloseConnectionWithError) {
|
||||||
server->close(std::make_pair(
|
server->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("stopping")));
|
std::string("stopping")));
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
@@ -324,7 +324,7 @@ TEST_F(QuicServerTransportTest, TestCloseConnectionWithError) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(QuicServerTransportTest, TestCloseConnectionWithNoError) {
|
TEST_F(QuicServerTransportTest, TestCloseConnectionWithNoError) {
|
||||||
server->close(std::make_pair(
|
server->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("stopping")));
|
std::string("stopping")));
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
@@ -377,7 +377,7 @@ TEST_F(QuicServerTransportTest, TestCloseConnectionWithNoErrorPendingStreams) {
|
|||||||
++clientNextAppDataPacketNum,
|
++clientNextAppDataPacketNum,
|
||||||
acks,
|
acks,
|
||||||
PacketNumberSpace::AppData)));
|
PacketNumberSpace::AppData)));
|
||||||
server->close(std::make_pair(
|
server->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("stopping")));
|
std::string("stopping")));
|
||||||
|
|
||||||
@@ -534,7 +534,7 @@ TEST_F(QuicServerTransportTest, NoDataExceptCloseProcessedAfterClosing) {
|
|||||||
|
|
||||||
auto packet = std::move(builder).buildPacket();
|
auto packet = std::move(builder).buildPacket();
|
||||||
|
|
||||||
server->close(std::make_pair(
|
server->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("hello")));
|
std::string("hello")));
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
@@ -1288,14 +1288,14 @@ TEST_F(QuicServerTransportTest, ReceiveConnectionClose) {
|
|||||||
deliverDataWithoutErrorCheck(packetToBuf(packet));
|
deliverDataWithoutErrorCheck(packetToBuf(packet));
|
||||||
// Now the transport should be closed
|
// Now the transport should be closed
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->first,
|
server->getConn().localConnectionError->code,
|
||||||
QuicErrorCode(TransportErrorCode::NO_ERROR));
|
QuicErrorCode(TransportErrorCode::NO_ERROR));
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().peerConnectionError->first,
|
server->getConn().peerConnectionError->code,
|
||||||
QuicErrorCode(TransportErrorCode::NO_ERROR));
|
QuicErrorCode(TransportErrorCode::NO_ERROR));
|
||||||
auto closedMsg =
|
auto closedMsg =
|
||||||
folly::to<std::string>("Server closed by peer reason=", errMsg);
|
folly::to<std::string>("Server closed by peer reason=", errMsg);
|
||||||
EXPECT_EQ(server->getConn().peerConnectionError->second, closedMsg);
|
EXPECT_EQ(server->getConn().peerConnectionError->message, closedMsg);
|
||||||
EXPECT_TRUE(server->isClosed());
|
EXPECT_TRUE(server->isClosed());
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
serverWrites,
|
serverWrites,
|
||||||
@@ -1331,13 +1331,13 @@ TEST_F(QuicServerTransportTest, ReceiveApplicationClose) {
|
|||||||
// Now the transport should be closed
|
// Now the transport should be closed
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
||||||
server->getConn().localConnectionError->first);
|
server->getConn().localConnectionError->code);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().peerConnectionError->first,
|
server->getConn().peerConnectionError->code,
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN));
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN));
|
||||||
auto closedMsg =
|
auto closedMsg =
|
||||||
folly::to<std::string>("Server closed by peer reason=", errMsg);
|
folly::to<std::string>("Server closed by peer reason=", errMsg);
|
||||||
EXPECT_EQ(server->getConn().peerConnectionError->second, closedMsg);
|
EXPECT_EQ(server->getConn().peerConnectionError->message, closedMsg);
|
||||||
EXPECT_TRUE(server->isClosed());
|
EXPECT_TRUE(server->isClosed());
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
serverWrites,
|
serverWrites,
|
||||||
@@ -1368,13 +1368,13 @@ TEST_F(QuicServerTransportTest, ReceiveConnectionCloseTwice) {
|
|||||||
// Now the transport should be closed
|
// Now the transport should be closed
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
QuicErrorCode(TransportErrorCode::NO_ERROR),
|
||||||
server->getConn().localConnectionError->first);
|
server->getConn().localConnectionError->code);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().peerConnectionError->first,
|
server->getConn().peerConnectionError->code,
|
||||||
QuicErrorCode(TransportErrorCode::NO_ERROR));
|
QuicErrorCode(TransportErrorCode::NO_ERROR));
|
||||||
auto closedMsg =
|
auto closedMsg =
|
||||||
folly::to<std::string>("Server closed by peer reason=", errMsg);
|
folly::to<std::string>("Server closed by peer reason=", errMsg);
|
||||||
EXPECT_EQ(server->getConn().peerConnectionError->second, closedMsg);
|
EXPECT_EQ(server->getConn().peerConnectionError->message, closedMsg);
|
||||||
EXPECT_TRUE(server->isClosed());
|
EXPECT_TRUE(server->isClosed());
|
||||||
EXPECT_TRUE(verifyFramePresent(
|
EXPECT_TRUE(verifyFramePresent(
|
||||||
serverWrites,
|
serverWrites,
|
||||||
@@ -1533,7 +1533,7 @@ TEST_F(
|
|||||||
}
|
}
|
||||||
EXPECT_TRUE(server->getConn().localConnectionError);
|
EXPECT_TRUE(server->getConn().localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->second, "Migration disabled");
|
server->getConn().localConnectionError->message, "Migration disabled");
|
||||||
EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);
|
EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1650,7 +1650,7 @@ TEST_F(QuicServerTransportTest, ShortHeaderPacketWithNoFramesAfterClose) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Close the connection
|
// Close the connection
|
||||||
server->close(std::make_pair(
|
server->close(QuicError(
|
||||||
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
QuicErrorCode(TransportErrorCode::INTERNAL_ERROR),
|
||||||
std::string("test close")));
|
std::string("test close")));
|
||||||
server->idleTimeout().cancelTimeout();
|
server->idleTimeout().cancelTimeout();
|
||||||
@@ -1746,7 +1746,7 @@ TEST_P(
|
|||||||
}
|
}
|
||||||
EXPECT_TRUE(server->getConn().localConnectionError);
|
EXPECT_TRUE(server->getConn().localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->second,
|
server->getConn().localConnectionError->message,
|
||||||
"Probing not supported yet");
|
"Probing not supported yet");
|
||||||
|
|
||||||
std::vector<int> indices =
|
std::vector<int> indices =
|
||||||
@@ -2068,7 +2068,7 @@ TEST_P(
|
|||||||
|
|
||||||
EXPECT_TRUE(server->getConn().localConnectionError);
|
EXPECT_TRUE(server->getConn().localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->second,
|
server->getConn().localConnectionError->message,
|
||||||
"Probing not supported yet");
|
"Probing not supported yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2100,7 +2100,7 @@ TEST_F(QuicServerTransportTest, TooManyMigrations) {
|
|||||||
}
|
}
|
||||||
EXPECT_TRUE(server->getConn().localConnectionError);
|
EXPECT_TRUE(server->getConn().localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->second, "Too many migrations");
|
server->getConn().localConnectionError->message, "Too many migrations");
|
||||||
EXPECT_TRUE(server->isClosed());
|
EXPECT_TRUE(server->isClosed());
|
||||||
std::vector<int> indices =
|
std::vector<int> indices =
|
||||||
getQLogEventIndices(QLogEventType::PacketDrop, qLogger);
|
getQLogEventIndices(QLogEventType::PacketDrop, qLogger);
|
||||||
@@ -3079,7 +3079,7 @@ TEST_F(
|
|||||||
}
|
}
|
||||||
EXPECT_TRUE(server->getConn().localConnectionError);
|
EXPECT_TRUE(server->getConn().localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->second,
|
server->getConn().localConnectionError->message,
|
||||||
"Migration not allowed during handshake");
|
"Migration not allowed during handshake");
|
||||||
EXPECT_TRUE(server->isClosed());
|
EXPECT_TRUE(server->isClosed());
|
||||||
|
|
||||||
@@ -3113,7 +3113,7 @@ TEST_F(
|
|||||||
}
|
}
|
||||||
EXPECT_TRUE(server->getConn().localConnectionError);
|
EXPECT_TRUE(server->getConn().localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->second,
|
server->getConn().localConnectionError->message,
|
||||||
"Migration not allowed during handshake");
|
"Migration not allowed during handshake");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3146,7 +3146,7 @@ TEST_F(
|
|||||||
}
|
}
|
||||||
EXPECT_TRUE(server->getConn().localConnectionError);
|
EXPECT_TRUE(server->getConn().localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->second,
|
server->getConn().localConnectionError->message,
|
||||||
"Migration not allowed during handshake");
|
"Migration not allowed during handshake");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3177,7 +3177,7 @@ TEST_F(
|
|||||||
}
|
}
|
||||||
EXPECT_TRUE(server->getConn().localConnectionError);
|
EXPECT_TRUE(server->getConn().localConnectionError);
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
server->getConn().localConnectionError->second, "Migration disabled");
|
server->getConn().localConnectionError->message, "Migration disabled");
|
||||||
EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);
|
EXPECT_EQ(server->getConn().streamManager->streamCount(), 0);
|
||||||
EXPECT_EQ(server->getConn().pendingZeroRttData, nullptr);
|
EXPECT_EQ(server->getConn().pendingZeroRttData, nullptr);
|
||||||
EXPECT_EQ(server->getConn().pendingOneRttData, nullptr);
|
EXPECT_EQ(server->getConn().pendingOneRttData, nullptr);
|
||||||
@@ -3569,7 +3569,7 @@ TEST_F(QuicUnencryptedServerTransportTest, TestCloseWhileAsyncPending) {
|
|||||||
EXPECT_CALL(handshakeFinishedCallback, onHandshakeUnfinished());
|
EXPECT_CALL(handshakeFinishedCallback, onHandshakeUnfinished());
|
||||||
recvClientFinished();
|
recvClientFinished();
|
||||||
|
|
||||||
server->close(std::make_pair(
|
server->close(QuicError(
|
||||||
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
QuicErrorCode(GenericApplicationErrorCode::UNKNOWN),
|
||||||
std::string("hello")));
|
std::string("hello")));
|
||||||
EXPECT_TRUE(server->isClosed());
|
EXPECT_TRUE(server->isClosed());
|
||||||
|
@@ -477,13 +477,13 @@ class QuicServerTransportTestBase : public virtual testing::Test {
|
|||||||
if (server->getConn().localConnectionError) {
|
if (server->getConn().localConnectionError) {
|
||||||
bool idleTimeout = false;
|
bool idleTimeout = false;
|
||||||
const LocalErrorCode* localError =
|
const LocalErrorCode* localError =
|
||||||
server->getConn().localConnectionError->first.asLocalErrorCode();
|
server->getConn().localConnectionError->code.asLocalErrorCode();
|
||||||
if (localError) {
|
if (localError) {
|
||||||
idleTimeout = (*localError == LocalErrorCode::IDLE_TIMEOUT);
|
idleTimeout = (*localError == LocalErrorCode::IDLE_TIMEOUT);
|
||||||
}
|
}
|
||||||
if (!idleTimeout) {
|
if (!idleTimeout) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
toString(server->getConn().localConnectionError->first));
|
toString(server->getConn().localConnectionError->code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -519,10 +519,10 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction {
|
|||||||
folly::Optional<folly::SocketAddress> localAddress;
|
folly::Optional<folly::SocketAddress> localAddress;
|
||||||
|
|
||||||
// Local error on the connection.
|
// Local error on the connection.
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> localConnectionError;
|
folly::Optional<QuicError> localConnectionError;
|
||||||
|
|
||||||
// Error sent on the connection by the peer.
|
// Error sent on the connection by the peer.
|
||||||
folly::Optional<std::pair<QuicErrorCode, std::string>> peerConnectionError;
|
folly::Optional<QuicError> peerConnectionError;
|
||||||
|
|
||||||
// Supported versions in order of preference. Only meaningful to clients.
|
// Supported versions in order of preference. Only meaningful to clients.
|
||||||
// TODO: move to client only conn state.
|
// TODO: move to client only conn state.
|
||||||
|
@@ -275,15 +275,13 @@ class ServerStreamHandler : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
sock_.reset();
|
sock_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
|
||||||
onConnectionError(std::move(error));
|
onConnectionError(std::move(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionError(
|
void onConnectionError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
LOG(ERROR) << "Conn errorCoded=" << toString(error.code)
|
||||||
LOG(ERROR) << "Conn errorCoded=" << toString(error.first)
|
<< ", errorMsg=" << error.message;
|
||||||
<< ", errorMsg=" << error.second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onTransportReady() noexcept override {
|
void onTransportReady() noexcept override {
|
||||||
@@ -325,10 +323,7 @@ class ServerStreamHandler : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
LOG(INFO) << "read available for stream id=" << id;
|
LOG(INFO) << "read available for stream id=" << id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void readError(
|
void readError(quic::StreamId id, QuicError error) noexcept override {
|
||||||
quic::StreamId id,
|
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override {
|
|
||||||
LOG(ERROR) << "Got read error on stream=" << id
|
LOG(ERROR) << "Got read error on stream=" << id
|
||||||
<< " error=" << toString(error);
|
<< " error=" << toString(error);
|
||||||
// A read error only terminates the ingress portion of the stream state.
|
// A read error only terminates the ingress portion of the stream state.
|
||||||
@@ -361,10 +356,8 @@ class ServerStreamHandler : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onStreamWriteError(
|
void onStreamWriteError(quic::StreamId id, QuicError error) noexcept
|
||||||
quic::StreamId id,
|
override {
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override {
|
|
||||||
LOG(ERROR) << "write error with stream=" << id
|
LOG(ERROR) << "write error with stream=" << id
|
||||||
<< " error=" << toString(error);
|
<< " error=" << toString(error);
|
||||||
}
|
}
|
||||||
@@ -648,7 +641,7 @@ class TPerfClient : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
|
|
||||||
void readError(
|
void readError(
|
||||||
quic::StreamId /*streamId*/,
|
quic::StreamId /*streamId*/,
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
QuicError
|
||||||
/*error*/) noexcept override {
|
/*error*/) noexcept override {
|
||||||
// A read error only terminates the ingress portion of the stream state.
|
// A read error only terminates the ingress portion of the stream state.
|
||||||
// Your application should probably terminate the egress portion via
|
// Your application should probably terminate the egress portion via
|
||||||
@@ -686,14 +679,12 @@ class TPerfClient : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
eventBase_.terminateLoopSoon();
|
eventBase_.terminateLoopSoon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionSetupError(
|
void onConnectionSetupError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
|
||||||
onConnectionError(std::move(error));
|
onConnectionError(std::move(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionError(
|
void onConnectionError(QuicError error) noexcept override {
|
||||||
std::pair<quic::QuicErrorCode, std::string> error) noexcept override {
|
LOG(ERROR) << "TPerfClient error: " << toString(error.code);
|
||||||
LOG(ERROR) << "TPerfClient error: " << toString(error.first);
|
|
||||||
eventBase_.terminateLoopSoon();
|
eventBase_.terminateLoopSoon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,10 +694,8 @@ class TPerfClient : public quic::QuicSocket::ConnectionSetupCallback,
|
|||||||
<< " is write ready with maxToSend=" << maxToSend;
|
<< " is write ready with maxToSend=" << maxToSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onStreamWriteError(
|
void onStreamWriteError(quic::StreamId id, QuicError error) noexcept
|
||||||
quic::StreamId id,
|
override {
|
||||||
std::pair<quic::QuicErrorCode, folly::Optional<folly::StringPiece>>
|
|
||||||
error) noexcept override {
|
|
||||||
LOG(ERROR) << "TPerfClient write error with stream=" << id
|
LOG(ERROR) << "TPerfClient write error with stream=" << id
|
||||||
<< " error=" << toString(error);
|
<< " error=" << toString(error);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user