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

fix(windows): fix race condition in WiFi connection details feature #568

Merged

Conversation

jfkm69
Copy link
Contributor

@jfkm69 jfkm69 commented Jan 26, 2022

Overview

The main objective of this PR was to add support for getting Wi-Fi properties on the Windows platform, however, thanks to this PR(#564) we now have access to an asynchronous method to accommodate the retrieval of Wi-Fi properties. However, the current implementation does not keep track of the Network Status requests and suffers from a race condition that will allow unordered delivery of Network Info Details because it simply returns the result of the current request without acknowledging that it's predecessor has been completed. Lastly, we added support for the requestedInterface property and removed access to details properties that were unavailable for the given connection type.

Test Plan

Getting Wi-Fi properties from requestedInterface:
image

Connection history:
Before:
image

After:
image

@mikehardy
Copy link
Contributor

Hi there @jfkm69 - with sincere apologies, and I'm not sure I've ever seen this in a module before! - but 2 people were working on a windows item at once and there has been a massive collision between this PR and the just merged #564

This is really unfortunate, but in order for this PR to be considered it will have to be based off the new/current master branch commits

…to ensure network events are handled in order
@jfkm69 jfkm69 changed the title Added support for WiFi connection details on Windows Fix race condition introduced by adding support for WiFi connection details on Windows Jan 31, 2022
@jfkm69 jfkm69 changed the title Fix race condition introduced by adding support for WiFi connection details on Windows fix (windows): Fix race condition introduced by adding support for WiFi connection details Jan 31, 2022
@jfkm69
Copy link
Contributor Author

jfkm69 commented Feb 1, 2022

Hi @mikehardy, I merged to the latest version of master and updated the PR to fix a few issues that came up as a result of #564. Thanks to @bbowman for the review.

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

I've checked this out and I can attest it builds and runs successfully in my environment with seemingly correct results but I did not reproduce the original fault and thus can't commit on the actual fix.

Curious what @bbowman thinks as their review was ace! Happy to merge + release with consensus

example/ConnectionInfoSubscription.tsx Outdated Show resolved Hide resolved
Co-authored-by: Mike Hardy <github@mikehardy.net>
Copy link

@bbowman bbowman left a comment

Choose a reason for hiding this comment

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

LGTM! Just a small nit on the std::function copy

windows/RNCNetInfoCPP/RNCNetInfo.cpp Show resolved Hide resolved
windows/RNCNetInfoCPP/RNCNetInfo.cpp Outdated Show resolved Hide resolved
@mikehardy
Copy link
Contributor

Just chiming in to say that I really appreciate the review + collaboration as it is way past my rusty college-courses-then-did-not-use-it C++ skills. I'm watching and still happy to hit the big green "merge" (and release) button as soon as there is consensus. Appears all comments are addressed, so just curious for a look from @aschultz then off we go I think. Cheers

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

I pulled it locally to check after the last commits/approvals here - noticed that the windows msbuild.binlog wasn't gitignore'd, so I added that but there are few things more minor than a .gitignore change, hopefully that's okay! Helps keep my local git tree clean vs dirty when testing at least, for the future. Going to merge and it should auto release. Thanks!

@mikehardy mikehardy changed the title fix (windows): Fix race condition introduced by adding support for WiFi connection details fix(windows): fix race condition in WiFi connection details feature Feb 8, 2022
@mikehardy mikehardy merged commit 0cd8132 into react-native-netinfo:master Feb 8, 2022
github-actions bot pushed a commit that referenced this pull request Feb 8, 2022
## [7.1.11](v7.1.10...v7.1.11) (2022-02-08)

### Bug Fixes

* **windows:** fix race condition in WiFi connection details feature ([#568](#568)) ([0cd8132](0cd8132))
@matt-oakes
Copy link
Collaborator

🎉 This PR is included in version 7.1.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

5 participants