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

Qubesdb with commit #52

Merged
merged 4 commits into from
May 13, 2020
Merged

Qubesdb with commit #52

merged 4 commits into from
May 13, 2020

Conversation

hannesm
Copy link
Member

@hannesm hannesm commented Apr 27, 2020

Hello,

we extended the Qubes.DB module to provide two new functions:

  • got_new_commit : t -> string -> map Lwt.t
  • values : t -> string -> map Lwt.t

The first resolves once the provided key is written to with an empty string (this is used in Qubes to signal a commit). It provides a partial map, where only keys with key as prefix are contained. The function values does the latter.

The reason for these functions is to properly react to QubesDB updates (in our case, firewall updates), and not using a QubesDB where firewall rules are only partially written. This cannot be implemented with just the provided after.

linse and others added 2 commits April 27, 2020 18:18
Co-Authored-By: hannes <hannes@mehnert.org>
@hannesm hannesm requested a review from talex5 April 27, 2020 17:02
Copy link
Collaborator

@talex5 talex5 left a comment

Choose a reason for hiding this comment

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

got_new_commit looks racy to me. If events are signalled for two keys in quick succession, we might only see one of them (and ignore it, if we're waiting for the other one).

I think it would also be safer to take the old value as an input, so we can return immediately if the caller is already out-of-date. Otherwise, the caller has to call values immediately after starting the got_new_commit operation, and it would be easy to get that wrong.

Co-Authored-By: linse <sschirme@gmail.com>
@hannesm
Copy link
Member Author

hannesm commented May 4, 2020

Hi @talex5, thanks for your review.

In 02da172 we addressed the race conditions (see comments at the end of dB.ml). Do you think this covers all cases of the racy behaviour.

@hannesm
Copy link
Member Author

hannesm commented May 7, 2020

@talex5 we pushed an updated, (hopefully) race-free version for got_new_commit (a bit complicated since multiple "transactions" may be in progress, thus a "commit" (empty write) only updates the key it commited). Its implementation was guided after the usages of the qubes-firewall and the firewall rules.

@hannesm hannesm merged commit 8b806bc into mirage:master May 13, 2020
hannesm added a commit that referenced this pull request May 13, 2020
* Add new function got_new_commit to QubesDB.

Co-Authored-By: hannes <hannes@mehnert.org>
hannesm added a commit to hannesm/opam-repository that referenced this pull request May 13, 2020
CHANGES:

- provide Qubes.DB.got_new_commit to wait for specific commit writes in QubesDB
  (mirage/mirage-qubes#52 @linse @hannesm)
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

3 participants