Skip to content

Commit

Permalink
Remove WriteHandler::Abort. (#24880)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Sep 2, 2023
1 parent e0545c6 commit 1298520
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
5 changes: 4 additions & 1 deletion src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ void InteractionModelEngine::Shutdown()

for (auto & writeHandler : mWriteHandlers)
{
writeHandler.Abort();
if (!writeHandler.IsFree())
{
writeHandler.Close();
}
}

mReportingEngine.Shutdown();
Expand Down
22 changes: 8 additions & 14 deletions src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ CHIP_ERROR WriteHandler::Init()

void WriteHandler::Close()
{
mSuppressResponse = false;
VerifyOrReturn(mState != State::Uninitialized);

ClearState();
}

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

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

void WriteHandler::ClearState()
{
DeliverFinalListWriteEnd(false /* wasSuccessful */);
mExchangeCtx.Release();
MoveToState(State::Uninitialized);
}

} // namespace app
} // namespace chip

Expand Down
7 changes: 0 additions & 7 deletions src/app/WriteHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ class WriteHandler : public Messaging::ExchangeDelegate
Protocols::InteractionModel::Status OnWriteRequest(Messaging::ExchangeContext * apExchangeContext,
System::PacketBufferHandle && aPayload, bool aIsTimedWrite);

/*
* This forcibly closes the exchange context if a valid one is pointed to and de-initializes the object. Such a situation does
* not arise during normal message processing flows that all normally call Close() below.
*/
void Abort();

/**
* Clean up state when we are done sending the write response.
*/
Expand Down Expand Up @@ -136,7 +130,6 @@ class WriteHandler : public Messaging::ExchangeDelegate
CHIP_ERROR SendWriteResponse(System::PacketBufferTLVWriter && aMessageWriter);

void MoveToState(const State aTargetState);
void ClearState();
const char * GetStateStr() const;

void DeliverListWriteBegin(const ConcreteAttributePath & aPath);
Expand Down

0 comments on commit 1298520

Please sign in to comment.