Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

Code

395 commit(s) on main

update readme Keenan Nemetz · 55m ago 32290114
history blame raw 796 B
1//go:build !unix
2
3package git
4
5import (
6 "os"
7 "sync"
8)
9
10// flock is not part of the portable API, so a platform without it serializes
11// writers inside one process only. That still removes the retry storm between
12// requests handled by one server; a second process on the same repository falls
13// back to the compare-and-swap, which is correct and slower. Vole ships packages
14// for the platforms where the kernel lock is available; this keeps the rest
15// building and says what it does.
16var (
17 processLocksMu sync.Mutex
18 processLocks = map[string]*sync.Mutex{}
19)
20
21func lockFile(f *os.File) (func(), error) {
22 processLocksMu.Lock()
23 mu := processLocks[f.Name()]
24 if mu == nil {
25 mu = &sync.Mutex{}
26 processLocks[f.Name()] = mu
27 }
28 processLocksMu.Unlock()
29 mu.Lock()
30 return mu.Unlock, nil
31}
32