From 9b1587f837f8b80f9aab41dc9ba4becce9d08268 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 } }