mirror of
https://github.com/git/git.git
synced 2026-01-10 01:56:42 +00:00
reftable/stack: allow locking of outdated stacks
In `reftable_stack_new_addition()` we first lock the stack and then check whether it is still up-to-date. If it is not we return an error to the caller indicating that the stack is outdated. This is overly restrictive in our ref transaction interface though: we lock the stack right before we start to verify the transaction, so we do not really care whether it is outdated or not. What we really want is that the stack is up-to-date after it has been locked so that we can verify queued updates against its current state while we know that it is locked for concurrent modification. Introduce a new flag `REFTABLE_STACK_NEW_ADDITION_RELOAD` that alters the behaviour of `reftable_stack_init_addition()` in this case: when we notice that it is out-of-date we reload it instead of returning an error to the caller. This logic will be wired up in the reftable backend in the next commit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
bc39b6a796
commit
80e7342ea8
@@ -37,12 +37,21 @@ uint64_t reftable_stack_next_update_index(struct reftable_stack *st);
|
||||
/* holds a transaction to add tables at the top of a stack. */
|
||||
struct reftable_addition;
|
||||
|
||||
enum {
|
||||
/*
|
||||
* Reload the stack when the stack is out-of-date after locking it.
|
||||
*/
|
||||
REFTABLE_STACK_NEW_ADDITION_RELOAD = (1 << 0),
|
||||
};
|
||||
|
||||
/*
|
||||
* returns a new transaction to add reftables to the given stack. As a side
|
||||
* effect, the ref database is locked.
|
||||
* effect, the ref database is locked. Accepts REFTABLE_STACK_NEW_ADDITION_*
|
||||
* flags.
|
||||
*/
|
||||
int reftable_stack_new_addition(struct reftable_addition **dest,
|
||||
struct reftable_stack *st);
|
||||
struct reftable_stack *st,
|
||||
unsigned int flags);
|
||||
|
||||
/* Adds a reftable to transaction. */
|
||||
int reftable_addition_add(struct reftable_addition *add,
|
||||
|
||||
Reference in New Issue
Block a user