mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-08 09:42:06 +03:00
Generic ByteEvent infrastructure
Summary: Introduces framework for handling callbacks when a `ByteEvent` occurs. - Adds `ByteEventCallback`, a new class that can be used to notify a callback implementation about delivery (ACK) of a byte and is used in the subsequent diff for notifications about TX of a byte. - Adds `ByteEvent` and `ByteEventCancellation`, both of which are used to communicate ancillary information when a ByteEvent happens to the callback implementation. This makes it easier to add additional fields (such as kernel timestamps, information about ACK delays, etc) in the future, without requiring the function signatures of all callback implementations to be updated. - For the moment, `DeliveryCallback` inherits from `ByteEventCallback` so that existing implementations do not need to be adjusted; `DeliveryCallback` implements `ByteEventCallback`'s methods and transforms the received `ByteEvents` into the expected callback. I will deprecate `DeliveryCallback` in a subsequent diff. - Refactors existing logic for handling delivery callbacks to be generic and capable of handling different types of byte events. This allows the same logic for registering and cancelling byte events to be reused for ACK and TX timestamps; custom logic is only required to decide when to trigger the callback. Reviewed By: mjoras Differential Revision: D21877803 fbshipit-source-id: 74f344aa9f83ddee2a3d0056c97c62da4a581580
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eb1dd2c31b
commit
d332cc4e0c
@@ -353,7 +353,12 @@ class TestQuicTransport
|
||||
auto deliveryCb = deliveryCallbacks_.find(id);
|
||||
if (deliveryCb != deliveryCallbacks_.end()) {
|
||||
for (auto& cbs : deliveryCb->second) {
|
||||
cbs.second->onDeliveryAck(id, cbs.first, stream->conn.lossState.srtt);
|
||||
ByteEvent event = {};
|
||||
event.id = id;
|
||||
event.offset = cbs.first;
|
||||
event.type = ByteEvent::Type::ACK;
|
||||
event.srtt = stream->conn.lossState.srtt;
|
||||
cbs.second->onByteEvent(event);
|
||||
if (closeState_ != CloseState::OPEN) {
|
||||
break;
|
||||
}
|
||||
@@ -1314,32 +1319,6 @@ TEST_F(QuicTransportImplTest, CloseStreamAfterReadFin) {
|
||||
transport.reset();
|
||||
}
|
||||
|
||||
TEST_F(QuicTransportImplTest, CancelAllDeliveryCallbacksDeque) {
|
||||
NiceMock<MockDeliveryCallback> mockedDeliveryCallback1,
|
||||
mockedDeliveryCallback2;
|
||||
std::deque<std::pair<uint64_t, QuicSocket::DeliveryCallback*>> callbacks;
|
||||
callbacks.emplace_back(0, &mockedDeliveryCallback1);
|
||||
callbacks.emplace_back(100, &mockedDeliveryCallback2);
|
||||
StreamId id = 0x123;
|
||||
EXPECT_CALL(mockedDeliveryCallback1, onCanceled(id, 0)).Times(1);
|
||||
EXPECT_CALL(mockedDeliveryCallback2, onCanceled(id, 100)).Times(1);
|
||||
TestQuicTransport::cancelDeliveryCallbacks(id, callbacks);
|
||||
}
|
||||
|
||||
TEST_F(QuicTransportImplTest, CancelAllDeliveryCallbacksMap) {
|
||||
NiceMock<MockDeliveryCallback> mockedDeliveryCallback1,
|
||||
mockedDeliveryCallback2;
|
||||
folly::F14FastMap<
|
||||
StreamId,
|
||||
std::deque<std::pair<uint64_t, QuicSocket::DeliveryCallback*>>>
|
||||
callbacks;
|
||||
callbacks[0x123].emplace_back(0, &mockedDeliveryCallback1);
|
||||
callbacks[0x135].emplace_back(100, &mockedDeliveryCallback2);
|
||||
EXPECT_CALL(mockedDeliveryCallback1, onCanceled(0x123, 0)).Times(1);
|
||||
EXPECT_CALL(mockedDeliveryCallback2, onCanceled(0x135, 100)).Times(1);
|
||||
TestQuicTransport::cancelDeliveryCallbacks(callbacks);
|
||||
}
|
||||
|
||||
TEST_F(QuicTransportImplTest, CloseTransportCleansupOutstandingCounters) {
|
||||
transport->transportConn->outstandings.handshakePacketsCount = 200;
|
||||
transport->closeNow(folly::none);
|
||||
|
Reference in New Issue
Block a user