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

Eliminate race conditions #23

Open
lionelains opened this issue Jan 17, 2020 · 6 comments
Open

Eliminate race conditions #23

lionelains opened this issue Jan 17, 2020 · 6 comments

Comments

@lionelains
Copy link
Contributor

When using threads for timer or libserialcpp SPI (that is internally using threads also), there may be additional race conditions that are not usually hit if running a mainloop (eg: on Raritan framework).

Serial read/write coud can be run simultaneously and race conditions must be handled.
Timer elapsing are implemented using threads when not running on the Raritan mainloop and the actions for the code executed in timers should be protected using mutexes.

@lionelains
Copy link
Contributor Author

We should first add a mutex SPI to be able to run either with Raritan framework mutexes of C++11 mutexes.

@lionelains
Copy link
Contributor Author

One race condition here:
CLibEzspMain lib_main is instanciated and could start to invoke observer callbacks, but the callbacks themselves are registered a bit afterwards.

@lionelains
Copy link
Contributor Author

In ezsp-dongle.cpp:
Reset command is sent here but callbacks for received frames is only registered afterwards.

@lionelains
Copy link
Contributor Author

lionelains commented Mar 3, 2020

First race condition should be fixed by f7d20b7

Second race condition should be fixed by 31a2e16

@lionelains
Copy link
Contributor Author

Fixes done on branch https://github.com/Legrandgroup/libezsp/tree/thread-safety are part of solving this.

@lionelains
Copy link
Contributor Author

Implemented in PR #76

@lionelains lionelains self-assigned this Nov 9, 2020
@lionelains lionelains removed their assignment Mar 31, 2023
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

1 participant