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

platforms/common/uORB/uORBManager.cpp: Fix a race condition in uORB c… #643

Merged
merged 1 commit into from
Feb 21, 2024
Merged
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
9 changes: 5 additions & 4 deletions platforms/common/uORB/uORBManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ uORB::Manager::unregisterCallback(orb_advert_t &node_handle, SubscriptionCallbac
#ifndef CONFIG_BUILD_FLAT
lock_cb_list();

// Remove the callback from the list. This must be done before unregistering from the device node
// otherwise the callback thread might try to call an already unregistered cb

per_process_cb_list.remove(callback_sub);

// Unregister the callback from the device node and retrieve amount of unhandled callback triggers
// The unregister from the node needs to be done callback_thread locked; otherwise we don't know
// if there are unhandled triggers left or not (due to a race between the callback thread and
Expand All @@ -598,10 +603,6 @@ uORB::Manager::unregisterCallback(orb_advert_t &node_handle, SubscriptionCallbac

callback_count += DeviceNode::unregister_callback(node_handle, cb_handle);

// Remove the callback from the list

per_process_cb_list.remove(callback_sub);

unlock_cb_list();
#else
DeviceNode::unregister_callback(node_handle, cb_handle);
Expand Down
Loading