mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-08 09:42:06 +03:00
Use ByteEvent as a key in maps and sets
Summary: This commit demonstrates the use of ByteEvents in maps. Intentionally didn't define the custom comparator and hash function inside the quic library because we want consumers of ByteEvents to define equality of 2 ByteEvents in their own way. This will help recipients of ByteEventCallback keep track of pending, received and cancelled ByteEvents easily. In addition, the behavior of registerByteEventCallback was modified to NOT allow duplicate registrations. A pair of registrations is considered duplicate if they both have the same stream ID, stream offset, ByteEvent type and recipient callback pointer. In such cases, registerByteEventCallback returns an INVALID_OPERATION error. This is critical to make sure that ByteEvents work well in maps, which may be used by recipients. Reviewed By: bschlinker Differential Revision: D27100623 fbshipit-source-id: 084a4765fa6c98fdc1b98414fbd30582cf1e5139
This commit is contained in:
committed by
Facebook GitHub Bot
parent
dfc9475107
commit
ac468ad891
@@ -2240,17 +2240,20 @@ TEST_F(QuicTransportTest, InvokeTxCallbacksSingleByte) {
|
||||
Mock::VerifyAndClearExpectations(&firstByteTxCb);
|
||||
Mock::VerifyAndClearExpectations(&lastByteTxCb);
|
||||
|
||||
// even if we register pastlastByte again, it shouldn't be triggered
|
||||
// Even if we register pastlastByte again, it shouldn't trigger
|
||||
// onByteEventRegistered because this is a duplicate registration.
|
||||
EXPECT_CALL(pastlastByteTxCb, onByteEventRegistered(getTxMatcher(stream, 1)))
|
||||
.Times(1);
|
||||
transport_->registerTxCallback(stream, 1, &pastlastByteTxCb);
|
||||
.Times(0);
|
||||
auto ret = transport_->registerTxCallback(stream, 1, &pastlastByteTxCb);
|
||||
EXPECT_EQ(LocalErrorCode::INVALID_OPERATION, ret.error());
|
||||
Mock::VerifyAndClearExpectations(&pastlastByteTxCb);
|
||||
|
||||
// pastlastByteTxCb::onByteEvent will never get called
|
||||
// cancel gets called instead
|
||||
// onByteEventCanceled called twice, since added twice
|
||||
// Even though we attempted to register the ByteEvent twice, it resulted in
|
||||
// an error. So, onByteEventCanceled should be called only once.
|
||||
EXPECT_CALL(pastlastByteTxCb, onByteEventCanceled(getTxMatcher(stream, 1)))
|
||||
.Times(2);
|
||||
.Times(1);
|
||||
transport_->close(folly::none);
|
||||
Mock::VerifyAndClearExpectations(&pastlastByteTxCb);
|
||||
}
|
||||
|
Reference in New Issue
Block a user