-
Notifications
You must be signed in to change notification settings - Fork 3k
Add some logic related to initialization to various block devices #7773
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
Conversation
4fade51
to
c10d029
Compare
@@ -39,6 +39,10 @@ BufferedBlockDevice::~BufferedBlockDevice() | |||
|
|||
int BufferedBlockDevice::init() | |||
{ | |||
if (!_is_initialized) { | |||
_init_ref_count = 0; |
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.
I think there's a fault in this protection - Consider this Scenario:
- Threads1&2 are the first to call init simultaneously.
- Thread 1 calls init(), contact switch just before _init_ref_count = 0.
(_is_initialized is still false) - Thread 2 calls init(), also enters this 'if' and completes init() with _init_ref_count = 1.
- Thread 1 is now back and now it sets _init_ref_count = 0, it will also go through entire
init() function and mess up the ref count
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.
Offir - you are right. This is indeed a bug (however awkward). Issuing a fix now.
c10d029
to
5a87f3a
Compare
Pushed a fix following @offirko's comments. |
Looks great , thanks |
- Add an initialization flag on which BD actions depend (fail if uninitialized). - Fix behavior of init reference count if first initialization fails
5a87f3a
to
6f6ea14
Compare
/morph build |
I really don't understand what the travis-ci/littlefs error is about. Has nothing to do with this PR. |
Build : SUCCESSBuild number : 2854 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2486 |
/morph test |
Pausing Test CI until 5.9.6 PR is merged. |
/morph test |
/morph test |
/morph test |
2 similar comments
/morph test |
/morph test |
Description
Pull request type