aboutsummaryrefslogtreecommitdiff
path: root/plugin/pprof/pprof.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/pprof/pprof.go')
-rw-r--r--plugin/pprof/pprof.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/plugin/pprof/pprof.go b/plugin/pprof/pprof.go
index c53010089..ddf5ab2df 100644
--- a/plugin/pprof/pprof.go
+++ b/plugin/pprof/pprof.go
@@ -7,6 +7,8 @@ import (
"net/http"
pp "net/http/pprof"
"runtime"
+
+ "github.com/coredns/coredns/plugin/pkg/reuseport"
)
type handler struct {
@@ -17,7 +19,10 @@ type handler struct {
}
func (h *handler) Startup() error {
- ln, err := net.Listen("tcp", h.addr)
+ // Reloading the plugin without changing the listening address results
+ // in an error unless we reuse the port because Startup is called for
+ // new handlers before Shutdown is called for the old ones.
+ ln, err := reuseport.Listen("tcp", h.addr)
if err != nil {
log.Errorf("Failed to start pprof handler: %s", err)
return err