Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PacketBufferHandle::Get private again. #17567

Merged
merged 1 commit into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/inet/UDPEndPointImplOpenThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,16 @@ void UDPEndPointImplOT::handleUdpReceive(void * aContext, otMessage * aMessage,
payload->SetDataLength(static_cast<uint16_t>(msgLen + sizeof(IPPacketInfo)));

ep->Retain();
CHIP_ERROR err = ep->GetSystemLayer().ScheduleLambda([ep, p = payload.Get()] {
ep->HandleDataReceived(System::PacketBufferHandle::Adopt(p));
auto * buf = std::move(payload).UnsafeRelease();
CHIP_ERROR err = ep->GetSystemLayer().ScheduleLambda([ep, buf] {
ep->HandleDataReceived(System::PacketBufferHandle::Adopt(buf));
ep->Release();
});
if (err == CHIP_NO_ERROR)
{
// If ScheduleLambda() succeeded, it has ownership of the buffer, so we need to release it (without freeing it).
static_cast<void>(std::move(payload).UnsafeRelease());
}
else
if (err != CHIP_NO_ERROR)
{
// Make sure we properly clean up buf and ep, since our lambda will not
// run.
payload = System::PacketBufferHandle::Adopt(buf);
ep->Release();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/SystemPacketBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,6 @@ class DLL_EXPORT PacketBufferHandle
#endif
}

PacketBuffer * Get() const { return mBuffer; }

protected:
#if CHIP_SYSTEM_CONFIG_USE_LWIP
// For use via LwIPPacketBufferView only.
Expand All @@ -679,6 +677,8 @@ class DLL_EXPORT PacketBufferHandle
return PacketBufferHandle(buffer);
}

PacketBuffer * Get() const { return mBuffer; }

bool operator==(const PacketBufferHandle & aOther) { return mBuffer == aOther.mBuffer; }

#if CHIP_SYSTEM_PACKETBUFFER_HAS_RIGHTSIZE
Expand Down