From 27ff6aeccb99995880a86ee482dd90c1e5c85d85 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 27 Mar 2019 12:36:30 -0600 Subject: [PATCH] Fix goroutine leak in Run D'oh, the servers' Shutdown() would never be called because they were never added to the list of servers. Thanks Danny for finding this. --- .gitignore | 6 +++++- admin.go | 2 +- caddy.go | 4 ---- modules/caddyhttp/caddyhttp.go | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index e755a6fe..37d227b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -_gitignore/ \ No newline at end of file +_gitignore/ + +# artifacts from pprof tooling +*.prof +*.test diff --git a/admin.go b/admin.go index 9f92db8c..487569b1 100644 --- a/admin.go +++ b/admin.go @@ -33,7 +33,7 @@ func StartAdmin(addr string) error { mux := http.NewServeMux() mux.HandleFunc("/load", handleLoadConfig) - ///// BEGIN PPROF STUFF ////// + ///// BEGIN PPROF STUFF (TODO: Temporary) ///// mux.HandleFunc("/debug/pprof/", pprof.Index) mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) mux.HandleFunc("/debug/pprof/profile", pprof.Profile) diff --git a/caddy.go b/caddy.go index 40b73c5a..3b7aee21 100644 --- a/caddy.go +++ b/caddy.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "log" - "runtime/debug" "strings" "sync" "time" @@ -49,9 +48,6 @@ func Start(cfg Config) error { currentCfg = &cfg currentCfgMu.Unlock() - // TODO: debugging memory leak... - debug.FreeOSMemory() - return nil } diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go index ec2637a7..529c1f79 100644 --- a/modules/caddyhttp/caddyhttp.go +++ b/modules/caddyhttp/caddyhttp.go @@ -49,6 +49,7 @@ func (hc *httpModuleConfig) Run() error { return fmt.Errorf("%s: listening on %s: %v", proto, addr, err) } go s.Serve(ln) + hc.servers = append(hc.servers, s) } } }