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

Shouldn't NimBLEScan::getDevice() be protected by semaphore? #43

Closed
Jeroen88 opened this issue May 14, 2020 · 2 comments
Closed

Shouldn't NimBLEScan::getDevice() be protected by semaphore? #43

Jeroen88 opened this issue May 14, 2020 · 2 comments

Comments

@Jeroen88
Copy link

In NimBLEScan::getDevice() here the device to return to the caller is assigned to a temporary variable. Is this unary? In other words, could the background scan update the device halfway copying the device? Or is this impossible? If possible, could / should it be protected by semaphore?

@h2zero
Copy link
Owner

h2zero commented May 14, 2020

Yes it seems possible that the data could be modified while copying, I don't think that method was meant to be used while scanning is active. The idea of those related methods seems to be that you would use the blocking scan call, then when complete, you would access the results via this.

In the scenario you describe, yes a semaphore would make sense to stay on the safe side.

@h2zero
Copy link
Owner

h2zero commented Feb 1, 2021

Going to close this, as the scenario that may cause this issue is extremely unlikely.
Also, now that I've said it, I'm sure an issue involving this situation will be posted shortly 😆

@h2zero h2zero closed this as completed Feb 1, 2021
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

No branches or pull requests

2 participants