From 710ef44cc33af0749663e7edccea6db23a14e84b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 5 Oct 2023 16:07:22 +0200 Subject: [PATCH] agent: check listener instead of portfile in Listen After #213 the portfile might no longer be written, thus check the listener to determine whether the agent is already listening. --- agent/agent.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agent/agent.go b/agent/agent.go index c35702d5..39bcbd51 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -79,7 +79,7 @@ func Listen(opts Options) (err error) { mu.Lock() defer mu.Unlock() - if portfile != "" { + if listener != nil { return fmt.Errorf("gops: agent already listening at: %v", listener.Addr()) } @@ -192,6 +192,7 @@ func Close() { } if listener != nil { listener.Close() + listener = nil } }