diff options
| author | 2026-03-23 03:25:44 +0000 | |
|---|---|---|
| committer | 2026-03-23 03:27:52 +0000 | |
| commit | 4a796e64ac576d6a3e3f2fe6174c4aa476ea0c5c (patch) | |
| tree | 44d72a20076ceab0981d0b553693d26ca36cc0be /refstore/files/transaction_lock_packed.go | |
| parent | receivepack: Lifecycle/ownership docs (diff) | |
| signature | No signature | |
refstore: Improve interfaces, errors, and make batch work v0.1.92
Diffstat (limited to 'refstore/files/transaction_lock_packed.go')
| -rw-r--r-- | refstore/files/transaction_lock_packed.go | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/refstore/files/transaction_lock_packed.go b/refstore/files/transaction_lock_packed.go deleted file mode 100644 index 4538e5e5..00000000 --- a/refstore/files/transaction_lock_packed.go +++ /dev/null @@ -1,44 +0,0 @@ -package files - -import ( - "errors" - "os" - "time" -) - -func (tx *Transaction) createPackedLock(timeout time.Duration) error { - const ( - initialBackoffMs = 1 - backoffMaxMultiplier = 1000 - ) - - deadline := time.Now().Add(timeout) - multiplier := 1 - n := 1 - - for { - file, err := tx.store.commonRoot.OpenFile("packed-refs.lock", os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644) - if err == nil { - return file.Close() - } - - if !errors.Is(err, os.ErrExist) { - return err - } - - if timeout == 0 || (timeout > 0 && time.Now().After(deadline)) { - return err - } - - backoffMs := multiplier * initialBackoffMs - waitMs := (750 + tx.store.lockRand.Intn(500)) * backoffMs / 1000 - time.Sleep(time.Duration(waitMs) * time.Millisecond) - - multiplier += 2*n + 1 - if multiplier > backoffMaxMultiplier { - multiplier = backoffMaxMultiplier - } else { - n++ - } - } -} |
