mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-08 09:42:06 +03:00
Notify connection callback when app rate limited
Summary: Notify connection callback implementation when the transport becomes app rate limited - The callback implementation is not required to define a handler for this callback (not pure virtual). - D21923745 will add an instrumentation callback class that can be used to allow other components to receive this signal. I'm extending to the connection callback because the overhead seems low, and we already have the connection callback registered for `HQSession`. Reviewed By: mjoras, lnicco Differential Revision: D21923744 fbshipit-source-id: 153696aefeab82b7fd8a6bc299c011dcce479995
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9dd5d81d8e
commit
e43eb2e8b4
@@ -101,6 +101,11 @@ class QuicSocket {
|
||||
*/
|
||||
virtual void onUnidirectionalStreamsAvailable(
|
||||
uint64_t /*numStreamsAvailable*/) noexcept {}
|
||||
|
||||
/**
|
||||
* Invoked when transport is detected to be app rate limited.
|
||||
*/
|
||||
virtual void onAppRateLimited() noexcept {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -2433,6 +2433,7 @@ void QuicTransportBase::writeSocketData() {
|
||||
currentSendBufLen < conn_->udpSendPacketLen && lossBufferEmpty &&
|
||||
conn_->congestionController->getWritableBytes()) {
|
||||
conn_->congestionController->setAppLimited();
|
||||
connCallback_->onAppRateLimited();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -117,6 +117,7 @@ class MockConnectionCallback : public QuicSocket::ConnectionCallback {
|
||||
,
|
||||
onUnidirectionalStreamsAvailable,
|
||||
void(uint64_t));
|
||||
GMOCK_METHOD0_(, noexcept, , onAppRateLimited, void());
|
||||
};
|
||||
|
||||
class MockDeliveryCallback : public QuicSocket::DeliveryCallback {
|
||||
|
@@ -280,6 +280,7 @@ TEST_F(QuicTransportTest, NotAppLimitedWithLoss) {
|
||||
false,
|
||||
nullptr);
|
||||
EXPECT_CALL(*rawCongestionController, setAppLimited()).Times(0);
|
||||
EXPECT_CALL(connCallback_, onAppRateLimited()).Times(0);
|
||||
loopForWrites();
|
||||
transport_->close(folly::none);
|
||||
}
|
||||
@@ -307,6 +308,7 @@ TEST_F(QuicTransportTest, NotAppLimitedWithNoWritableBytes) {
|
||||
false,
|
||||
nullptr);
|
||||
EXPECT_CALL(*rawCongestionController, setAppLimited()).Times(0);
|
||||
EXPECT_CALL(connCallback_, onAppRateLimited()).Times(0);
|
||||
loopForWrites();
|
||||
transport_->close(folly::none);
|
||||
}
|
||||
@@ -325,6 +327,7 @@ TEST_F(QuicTransportTest, NotAppLimitedWithLargeBuffer) {
|
||||
auto buf = buildRandomInputData(100 * 2000);
|
||||
transport_->writeChain(stream, buf->clone(), false, false, nullptr);
|
||||
EXPECT_CALL(*rawCongestionController, setAppLimited()).Times(0);
|
||||
EXPECT_CALL(connCallback_, onAppRateLimited()).Times(0);
|
||||
loopForWrites();
|
||||
transport_->close(folly::none);
|
||||
}
|
||||
@@ -347,6 +350,7 @@ TEST_F(QuicTransportTest, AppLimited) {
|
||||
false,
|
||||
nullptr);
|
||||
EXPECT_CALL(*rawCongestionController, setAppLimited()).Times(1);
|
||||
EXPECT_CALL(connCallback_, onAppRateLimited()).Times(1);
|
||||
loopForWrites();
|
||||
transport_->close(folly::none);
|
||||
}
|
||||
|
Reference in New Issue
Block a user