Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Added mutex to BluetoothManager #147

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

Conversation

pierantoniomerlino
Copy link
Contributor

This PR tries to fix the issue #113.
A mutex and guard_locks are added in BluetoothManager to synchronize the access to the event_list.

I'm not a C++ expert, so please check it before merging!
Signed-off-by: pierantoniomerlino [email protected]

Signed-off-by: pierantoniomerlino <[email protected]>
@@ -206,6 +206,7 @@ std::weak_ptr<BluetoothEvent> BluetoothManager::find(BluetoothType type,
void BluetoothManager::handle_event(BluetoothType type, std::string *name,
std::string *identifier, BluetoothObject *parent, BluetoothObject &object)
{
std::lock_guard<std::mutex> guard(lock);
Copy link

Choose a reason for hiding this comment

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

Hi.

Is it possible, that add_event/remove_event API will be called in scope of callback (line 232). If so, crash will occur because 'event_list' will be modified during the iteration. To avoid this copy on write semantics should be implemented.

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

Successfully merging this pull request may close these issues.

1 participant