-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[controller] Use short lived CommandSender when no command sender is provided #7041
[controller] Use short lived CommandSender when no command sender is provided #7041
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This feels like some unit testing is required here. What unit tests can be put in place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this goes back to my question about lifetime of mpCommandSender
on Slack. Why do we have it at all if it's single-use but the objects that are using it might be long-lived and get used more than once?
Why can't we just remove the mpCommandSender bit? Where is the restriction on lifetimes if a command sender is caller-provided documented?
What I'd like to see here is:
- A better commit message. The PR description is closer, but doesn't really answer my questions above.
- Better documentation at the places that provide a command sender, since that sender will still auto-destroy itself and then we will have dangling refs...
As far as testing on iOS, I don't have a setup for that right now, and I will see what I can do. But this definitely feels like something we should be able to have automated tests for. |
62fe85d
to
49f069e
Compare
The code in this change is already covered in various tests, like tests in Darwin platform. However, the bug it intend to solve is something happened on application side, so it is hard to be covered by UT. Anyway, added a test in Darwin, although it is not UT, but some kind of end-to-end test. |
49f069e
to
486726c
Compare
486726c
to
3a1f89f
Compare
In this case,
Removing Also added a comment in CommandSender. |
0526fd4
to
184aa66
Compare
The controller::Command has a mpCommandSender object, which is used by python device controller. However, the controller::Command is not designed for single use. This commit: - Remove command sender from CHIPClusters - Add comment in SendCommandRequest that caller SHOULD drop the reference of CommandSender after SendCommandRequest.
184aa66
to
aac5d48
Compare
|
||
expectation = [self expectationWithDescription:@"ReuseCHIPClusterObjectSecondCall"]; | ||
|
||
// Reuse the CHIPCluster Object for multiple times. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a good idea to reuse a number of times larger than CHIP_MAX_NUM_COMMAND_SENDER
so that we catch cases when we're leaking senders. Followup is OK for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#7074 Filed.
@andy31415 @Damian-Nordic PTAL, thanks. |
…provided (project-chip#7041) * [controller] Use short lived command sender in CHIPClusters The controller::Command has a mpCommandSender object, which is used by python device controller. However, the controller::Command is not designed for single use. This commit: - Remove command sender from CHIPClusters - Add comment in SendCommandRequest that caller SHOULD drop the reference of CommandSender after SendCommandRequest. * Run codegen
Problem
Change overview
Testing
@bzbarsky-apple Can you test this on iOS apps? Thanks.