diff --git a/pkg/actor/simple_grain_pool.go b/pkg/actor/simple_grain_pool.go index 2722f86..9c8c2bc 100644 --- a/pkg/actor/simple_grain_pool.go +++ b/pkg/actor/simple_grain_pool.go @@ -144,8 +144,17 @@ func (p *SimpleGrainPool[V]) TakeOwnership(id uint64) { } func (p *SimpleGrainPool[V]) AddRemote(host string) (Host, error) { - if host == "" || host == p.hostname || p.IsKnown(host) { - return nil, fmt.Errorf("invalid host") + if host == "" { + return nil, fmt.Errorf("host is empty") + } + if host == p.hostname { + return nil, fmt.Errorf("same host, this should not happen") + } + p.remoteMu.RLock() + existing, found := p.remoteHosts[host] + p.remoteMu.RUnlock() + if found { + return existing, nil } remote, err := p.spawnHost(host)