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 } }