1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-08 09:42:06 +03:00

error peek callbacks on connection closure

Summary: This was missed when peekError was added

Reviewed By: mjoras, lnicco

Differential Revision: D27973063

fbshipit-source-id: dbf1112a4ce6822401ba5125de853fe922acd85e
This commit is contained in:
Alan Frindell
2021-04-26 16:45:10 -07:00
committed by Facebook GitHub Bot
parent cf144da1d0
commit 5a0451760a
2 changed files with 13 additions and 1 deletions

View File

@@ -2603,7 +2603,13 @@ void QuicTransportBase::cancelAllAppCallbacks(
}
}
VLOG(4) << "Clearing " << peekCallbacks_.size() << " peek callbacks";
peekCallbacks_.clear();
auto peekCallbacksCopy = peekCallbacks_;
for (auto& cb : peekCallbacksCopy) {
peekCallbacks_.erase(cb.first);
if (cb.second.peekCb) {
cb.second.peekCb->peekError(cb.first, err);
}
}
if (connWriteCallback_) {
auto connWriteCallback = connWriteCallback_;

View File

@@ -2593,6 +2593,7 @@ TEST_F(QuicTransportImplTest, TestImmediateClose) {
NiceMock<MockWriteCallback> wcb;
NiceMock<MockWriteCallback> wcbConn;
NiceMock<MockReadCallback> rcb;
NiceMock<MockPeekCallback> pcb;
NiceMock<MockDeliveryCallback> deliveryCb;
NiceMock<MockByteEventCallback> txCb;
EXPECT_CALL(
@@ -2604,6 +2605,8 @@ TEST_F(QuicTransportImplTest, TestImmediateClose) {
onConnectionWriteError(IsAppError(GenericApplicationErrorCode::UNKNOWN)));
EXPECT_CALL(
rcb, readError(stream, IsAppError(GenericApplicationErrorCode::UNKNOWN)));
EXPECT_CALL(
pcb, peekError(stream, IsAppError(GenericApplicationErrorCode::UNKNOWN)));
EXPECT_CALL(deliveryCb, onCanceled(stream, _));
EXPECT_CALL(txCb, onByteEventCanceled(getTxMatcher(stream, 0)));
EXPECT_CALL(txCb, onByteEventCanceled(getTxMatcher(stream, 4)));
@@ -2613,6 +2616,7 @@ TEST_F(QuicTransportImplTest, TestImmediateClose) {
transport->notifyPendingWriteOnConnection(&wcbConn);
transport->notifyPendingWriteOnStream(stream, &wcb);
transport->setReadCallback(stream, &rcb);
transport->setPeekCallback(stream, &pcb);
EXPECT_CALL(*socketPtr, write(_, _))
.WillRepeatedly(SetErrnoAndReturn(EAGAIN, -1));
transport->writeChain(stream, IOBuf::copyBuffer("hello"), true, &deliveryCb);
@@ -2975,6 +2979,8 @@ TEST_F(QuicTransportImplTest, PeekError) {
transport->driveReadCallbacks();
EXPECT_CALL(peekCb1, peekError(stream1, _));
transport.reset();
}