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

main_phase_timer should be stopped along with SD #740

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

Conversation

kheaactua
Copy link
Contributor

@kheaactua kheaactua commented Jul 12, 2024

If main_phase_timer isn't stopped, it might prevent routingmanagerd from quitting gracefully. Thread will be blocked on join().

This is a followup on #559. The issue is a sporative (through rare) SIGTERM on exit from routingmanagerd.

The key signature of the crash appears to be:

#34 vsomeip_v3::routing_manager_impl::expire_subscriptions (this=0x1962493058, _force=false) at implementation/routing/src/routing_manager_impl.cpp:3307 #35 0x0000004ec2948f2c in vsomeip_v3::sd::service_discovery_impl::expire_subscriptions (_error=..., this=0x19624985c8) at implementation/service_discovery/src/service_discovery_impl.cpp:2828

That PR inverted the ownership structure in SD (better explained by @vvcarvalho here.) This change however calls a stop on main_phase_timer during shutdown.

If not stopped, it might prevent routingmanagerd from quitting
gracefully. Thread will be blocked on join().
@kheaactua kheaactua marked this pull request as ready for review July 16, 2024 13:44
@lutzbichler lutzbichler self-requested a review August 6, 2024 08:04
@@ -3235,6 +3236,13 @@ service_discovery_impl::start_main_phase_timer() {
this, std::placeholders::_1));
}

void
service_discovery_impl::stop_main_phase_timer() {
std::lock_guard<std::mutex> its_lock(main_phase_timer_mutex_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested by sonarcube

Suggested change
std::lock_guard<std::mutex> its_lock(main_phase_timer_mutex_);
std::scoped_lock<std::mutex> its_lock(main_phase_timer_mutex_);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kheaactua what do you think of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it adds anything.... Reading up on this, when dealing with a single mutex lock_guard seems equivalent. There are arguments on SO where some people try to claim lock_guard is deprecated, but I see no evidence of that in the standard.

I suppose I don't have strong feelings either way. :)

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.

3 participants