Skip to content

Commit 42853ab

Browse files
bzbarsky-applepull[bot]
authored andcommitted
Remove WriteHandler::Abort. (#24880)
It's basically just Close, except missing some state updates, and not doing the "is this actually in use" check that Close does. We can guard on that check in the caller and call Close. Fixes #21740
1 parent a673b08 commit 42853ab

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

src/app/InteractionModelEngine.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ void InteractionModelEngine::Shutdown()
132132

133133
for (auto & writeHandler : mWriteHandlers)
134134
{
135-
writeHandler.Abort();
135+
if (!writeHandler.IsFree())
136+
{
137+
writeHandler.Close();
138+
}
136139
}
137140

138141
mReportingEngine.Shutdown();

src/app/WriteHandler.cpp

+8-14
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ CHIP_ERROR WriteHandler::Init()
4848

4949
void WriteHandler::Close()
5050
{
51-
mSuppressResponse = false;
5251
VerifyOrReturn(mState != State::Uninitialized);
5352

54-
ClearState();
55-
}
56-
57-
void WriteHandler::Abort()
58-
{
59-
ClearState();
53+
// DeliverFinalListWriteEnd will be a no-op if we have called
54+
// DeliverFinalListWriteEnd in success conditions, so passing false for
55+
// wasSuccessful here is safe: if it does anything, we were in fact not
56+
// successful.
57+
DeliverFinalListWriteEnd(false /* wasSuccessful */);
58+
mExchangeCtx.Release();
59+
mSuppressResponse = false;
60+
MoveToState(State::Uninitialized);
6061
}
6162

6263
Status WriteHandler::HandleWriteRequestMessage(Messaging::ExchangeContext * apExchangeContext,
@@ -691,13 +692,6 @@ void WriteHandler::MoveToState(const State aTargetState)
691692
ChipLogDetail(DataManagement, "IM WH moving to [%s]", GetStateStr());
692693
}
693694

694-
void WriteHandler::ClearState()
695-
{
696-
DeliverFinalListWriteEnd(false /* wasSuccessful */);
697-
mExchangeCtx.Release();
698-
MoveToState(State::Uninitialized);
699-
}
700-
701695
} // namespace app
702696
} // namespace chip
703697

src/app/WriteHandler.h

-7
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ class WriteHandler : public Messaging::ExchangeDelegate
7070
Protocols::InteractionModel::Status OnWriteRequest(Messaging::ExchangeContext * apExchangeContext,
7171
System::PacketBufferHandle && aPayload, bool aIsTimedWrite);
7272

73-
/*
74-
* This forcibly closes the exchange context if a valid one is pointed to and de-initializes the object. Such a situation does
75-
* not arise during normal message processing flows that all normally call Close() below.
76-
*/
77-
void Abort();
78-
7973
/**
8074
* Clean up state when we are done sending the write response.
8175
*/
@@ -136,7 +130,6 @@ class WriteHandler : public Messaging::ExchangeDelegate
136130
CHIP_ERROR SendWriteResponse(System::PacketBufferTLVWriter && aMessageWriter);
137131

138132
void MoveToState(const State aTargetState);
139-
void ClearState();
140133
const char * GetStateStr() const;
141134

142135
void DeliverListWriteBegin(const ConcreteAttributePath & aPath);

0 commit comments

Comments
 (0)