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

Pbstate locking #25

Merged
merged 3 commits into from
Sep 1, 2023
Merged

Pbstate locking #25

merged 3 commits into from
Sep 1, 2023

Conversation

jonasblixt
Copy link
Owner

No description provided.

@codecov
Copy link

codecov bot commented Sep 1, 2023

Codecov Report

Merging #25 (dcabe0d) into master (0fbb011) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master      #25   +/-   ##
=======================================
  Coverage   68.15%   68.15%           
=======================================
  Files          54       54           
  Lines        2795     2795           
=======================================
  Hits         1905     1905           
  Misses        890      890           

The library should return negative errno numbers as default.
This commit introduces flock'ing on the state file. This is needed when
the library is used by more than one process.

Before this change the library would load the state on the init call and
keep the state in memory, any modifications are done on the in memory
state and then written. This will not work when multiple processes are
using the library since it's more or less guaranteed to cause data loss.

Because of how flock must be implemented and because we cant keep an in
memory copy of the state most of the functions have changed and the API
has changed on a few places as well. Mostly because now API functions
must load and check the state on every invocation and that means that
they now must be able to return error codes.
This commits adds a clear/set function that takes a clear and set mask.
This may be useful in situations where only modification if specific
bits is desired.

It might be dangerous to first call the read_board_reg function, perform
modifciations and then call the set_board_reg function since another
process might have done modifications to the register. The
clear_set_board_reg function will acquire the lock read/modify/write and
then release the lock.
@jonasblixt jonasblixt merged commit 10bb36d into master Sep 1, 2023
5 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants