-
-
Notifications
You must be signed in to change notification settings - Fork 151
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(serialport): data race on the isClosing
bool status of the serial port
#1009
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1009 +/- ##
==========================================
- Coverage 20.14% 20.14% -0.01%
==========================================
Files 42 42
Lines 3221 3222 +1
==========================================
Hits 649 649
- Misses 2487 2488 +1
Partials 85 85
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
isClosing
bool status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we only need to synchronize access to a single variable maybe an atomic.Bool
could be better?
isClosing
bool statusisClosing
bool status of the serial port
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retested on Linux, and now seems working OK! ✅
Please check if the PR fulfills these requirements
before creating one)
Fix a DATA RACE on the
isClosing
variable of the seiral port.There are two routines that read and write the
isClosing
variable concurrently.open
command reads theisClosing
variable to verify if it must stop reading from the serial portclose
command writes theisClosing
(setting to true) variable to inform that the serial port must be closed.Steps to reproduce
task run
http://127.0.0.1:8991/
open /dev/ttyACM0 115200
close /dev/ttyACM0
Add an atomic.Bool to control the access of the
isClosing
status of the serial port.