From 67b9a739feca9e3d2b3a8d9b7a4262c6da8f54c5 Mon Sep 17 00:00:00 2001 From: matst80 Date: Mon, 13 Oct 2025 22:50:09 +0200 Subject: [PATCH] Update simple_grain_pool.go --- pkg/actor/simple_grain_pool.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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)