mirror of
https://github.com/getcompanion-ai/computer-host.git
synced 2026-04-17 19:03:52 +00:00
fix: reconcile race fix, disk regression for snapshot deletion
This commit is contained in:
parent
09d9e7c23b
commit
218cc3fecb
11 changed files with 193 additions and 123 deletions
|
|
@ -118,6 +118,20 @@ func (d *Daemon) Health(ctx context.Context) (*contracthost.HealthResponse, erro
|
|||
}
|
||||
|
||||
func (d *Daemon) lockMachine(machineID contracthost.MachineID) func() {
|
||||
lock := d.machineLock(machineID)
|
||||
lock.Lock()
|
||||
return lock.Unlock
|
||||
}
|
||||
|
||||
func (d *Daemon) tryLockMachine(machineID contracthost.MachineID) (func(), bool) {
|
||||
lock := d.machineLock(machineID)
|
||||
if !lock.TryLock() {
|
||||
return nil, false
|
||||
}
|
||||
return lock.Unlock, true
|
||||
}
|
||||
|
||||
func (d *Daemon) machineLock(machineID contracthost.MachineID) *sync.Mutex {
|
||||
d.locksMu.Lock()
|
||||
lock, ok := d.machineLocks[machineID]
|
||||
if !ok {
|
||||
|
|
@ -125,9 +139,7 @@ func (d *Daemon) lockMachine(machineID contracthost.MachineID) func() {
|
|||
d.machineLocks[machineID] = lock
|
||||
}
|
||||
d.locksMu.Unlock()
|
||||
|
||||
lock.Lock()
|
||||
return lock.Unlock
|
||||
return lock
|
||||
}
|
||||
|
||||
func (d *Daemon) lockArtifact(key string) func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue