slaskit
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 28s
Build and Publish / BuildAndDeploy (push) Successful in 2m23s

This commit is contained in:
matst80
2024-11-13 08:58:40 +01:00
parent c9a7113e12
commit 3615d2d7d1
4 changed files with 19 additions and 4 deletions

View File

@@ -244,6 +244,7 @@ func (p *SyncedPool) IsKnown(host string) bool {
return true
}
}
return host == p.Hostname
}
@@ -321,6 +322,7 @@ func (p *SyncedPool) Negotiate() {
func (p *SyncedPool) RequestOwnership(id CartId) error {
ok := 0
all := 0
p.mu.RLock()
for _, r := range p.remotes {
log.Printf("Asking for confirmation change of %s to %s (me) with %s\n", id, p.Hostname, r.Host)
err := r.ConfirmChange(id, p.Hostname)
@@ -336,6 +338,7 @@ func (p *SyncedPool) RequestOwnership(id CartId) error {
}
ok++
}
p.mu.RUnlock()
if ok == 0 && all > 0 {
p.removeLocalGrain(id)
return fmt.Errorf("no remotes confirmed change")
@@ -354,6 +357,8 @@ func (p *SyncedPool) removeLocalGrain(id CartId) {
}
func (p *SyncedPool) AddRemote(host string) error {
p.mu.Lock()
defer p.mu.Unlock()
_, hasHost := p.remotes[host]
if host == "" || p.IsKnown(host) || hasHost {
return nil