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

Fixed issue where the SimpleService stop_announce method would crash #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlwinHughes
Copy link

I've noticed that calling the stop_announce method on the SimpleService class causes the program will crash.

The crash is caused by the stop_announce method re-constructing the instance so that when the announcer searches through it's list of services it is announcing it is unable to remove the service instance on this line:
https://github.com/afflux/pysomeip/blob/master/src/someip/sd.py#L1313

If you simple call the stop method of SimpleService this issue is not encountered by SD announcer won't stop announcing the service.
In in the toos/simpleservice.py file this is circumvented as the entire announcer is stopped before the SimpleService is stopped.

I've made an example of this here: https://github.com/AlwinHughes/pysomeip/blob/demo/tools/simpleservice.py. This demo will crash if it's run with the version of SimpleService that is on the current afflux/master but completes successfully with the changes in this PR.

My proposed solution is to store the service_instance when SimpleService start_announce is called. Then when stop_announce is called the correct instance can be passed to the announcer. This allows multiple SimpleServices to be announced by the same ServiceAnnouncer and each service to be offered/stopped independent of each other.

I'm new to contributing to open source projects so please let me know what you think or if I've missed anything.

@afflux
Copy link
Owner

afflux commented Jun 18, 2024

Hi! Thanks a lot for your contribution. The original code is even more wrong than what you describe - in stop_announce, I'm passing a config.Service instead of the sd.ServiceInstance. Good catch! The CI will probably error, but that is not on you, I'll fix that in a bit.

@afflux afflux mentioned this pull request Jun 18, 2024
@AlwinHughes
Copy link
Author

Ahh OK yeah I missed that. I guess my explanation was also wrong as I though the python remove method worked by reference rather than value. Glad to be able to help.

@AlwinHughes
Copy link
Author

Hey, just wondering if there's anything I can do to help get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants