Skip to content

Commit

Permalink
agent: check listener instead of portfile in Listen
Browse files Browse the repository at this point in the history
After #213 the portfile might no longer be written, thus check the
listener to determine whether the agent is already listening.
  • Loading branch information
tklauser committed Oct 5, 2023
1 parent dae615b commit 710ef44
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down Expand Up @@ -192,6 +192,7 @@ func Close() {
}
if listener != nil {
listener.Close()
listener = nil
}
}

Expand Down

0 comments on commit 710ef44

Please sign in to comment.