Browse Source

Eliminate some TODOs

master
Matthew Holt 5 years ago
parent
commit
f15f0d5839
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 2
      caddy.go
  2. 2
      modules/caddyhttp/encode/encode.go
  3. 2
      modules/caddyhttp/matchers.go
  4. 6
      modules/caddyhttp/reverseproxy/reverseproxy.go
  5. 4
      modules/caddyhttp/routes.go
  6. 4
      modules/caddytls/acmemanager.go
  7. 4
      modules/caddytls/connpolicy.go
  8. 2
      modules/caddytls/sessiontickets.go
  9. 4
      modules/caddytls/tls.go

2
caddy.go

@ -93,7 +93,7 @@ func Run(newCfg *Config) error {
return fmt.Errorf("creating storage value: %v", err) return fmt.Errorf("creating storage value: %v", err)
} }
newCfg.storage = stor newCfg.storage = stor
newCfg.StorageRaw = nil // allow GC to deallocate - TODO: Does this help? newCfg.StorageRaw = nil // allow GC to deallocate
} }
if newCfg.storage == nil { if newCfg.storage == nil {
newCfg.storage = &certmagic.FileStorage{Path: dataDir()} newCfg.storage = &certmagic.FileStorage{Path: dataDir()}

2
modules/caddyhttp/encode/encode.go

@ -68,7 +68,7 @@ func (enc *Encode) Provision(ctx caddy.Context) error {
return err return err
} }
} }
enc.EncodingsRaw = nil // allow GC to deallocate - TODO: Does this help? enc.EncodingsRaw = nil // allow GC to deallocate
if enc.MinLength == 0 { if enc.MinLength == 0 {
enc.MinLength = defaultMinLength enc.MinLength = defaultMinLength

2
modules/caddyhttp/matchers.go

@ -418,7 +418,7 @@ func (m *MatchNegate) Provision(ctx caddy.Context) error {
} }
m.matchers = append(m.matchers, val.(RequestMatcher)) m.matchers = append(m.matchers, val.(RequestMatcher))
} }
m.matchersRaw = nil // allow GC to deallocate - TODO: Does this help? m.matchersRaw = nil // allow GC to deallocate
return nil return nil
} }

6
modules/caddyhttp/reverseproxy/reverseproxy.go

@ -66,7 +66,7 @@ func (h *Handler) Provision(ctx caddy.Context) error {
return fmt.Errorf("loading transport module: %s", err) return fmt.Errorf("loading transport module: %s", err)
} }
h.Transport = val.(http.RoundTripper) h.Transport = val.(http.RoundTripper)
h.TransportRaw = nil // allow GC to deallocate - TODO: Does this help? h.TransportRaw = nil // allow GC to deallocate
} }
if h.LoadBalancing != nil && h.LoadBalancing.SelectionPolicyRaw != nil { if h.LoadBalancing != nil && h.LoadBalancing.SelectionPolicyRaw != nil {
val, err := ctx.LoadModuleInline("policy", val, err := ctx.LoadModuleInline("policy",
@ -76,7 +76,7 @@ func (h *Handler) Provision(ctx caddy.Context) error {
return fmt.Errorf("loading load balancing selection module: %s", err) return fmt.Errorf("loading load balancing selection module: %s", err)
} }
h.LoadBalancing.SelectionPolicy = val.(Selector) h.LoadBalancing.SelectionPolicy = val.(Selector)
h.LoadBalancing.SelectionPolicyRaw = nil // allow GC to deallocate - TODO: Does this help? h.LoadBalancing.SelectionPolicyRaw = nil // allow GC to deallocate
} }
if h.CBRaw != nil { if h.CBRaw != nil {
val, err := ctx.LoadModuleInline("type", "http.handlers.reverse_proxy.circuit_breakers", h.CBRaw) val, err := ctx.LoadModuleInline("type", "http.handlers.reverse_proxy.circuit_breakers", h.CBRaw)
@ -84,7 +84,7 @@ func (h *Handler) Provision(ctx caddy.Context) error {
return fmt.Errorf("loading circuit breaker module: %s", err) return fmt.Errorf("loading circuit breaker module: %s", err)
} }
h.CB = val.(CircuitBreaker) h.CB = val.(CircuitBreaker)
h.CBRaw = nil // allow GC to deallocate - TODO: Does this help? h.CBRaw = nil // allow GC to deallocate
} }
if h.Transport == nil { if h.Transport == nil {

4
modules/caddyhttp/routes.go

@ -91,7 +91,7 @@ func (routes RouteList) Provision(ctx caddy.Context) error {
} }
routes[i].MatcherSets = append(routes[i].MatcherSets, matchers) routes[i].MatcherSets = append(routes[i].MatcherSets, matchers)
} }
routes[i].MatcherSetsRaw = nil // allow GC to deallocate - TODO: Does this help? routes[i].MatcherSetsRaw = nil // allow GC to deallocate
// handlers // handlers
for j, rawMsg := range route.HandlersRaw { for j, rawMsg := range route.HandlersRaw {
@ -101,7 +101,7 @@ func (routes RouteList) Provision(ctx caddy.Context) error {
} }
routes[i].Handlers = append(routes[i].Handlers, mh.(MiddlewareHandler)) routes[i].Handlers = append(routes[i].Handlers, mh.(MiddlewareHandler))
} }
routes[i].HandlersRaw = nil // allow GC to deallocate - TODO: Does this help? routes[i].HandlersRaw = nil // allow GC to deallocate
} }
return nil return nil
} }

4
modules/caddytls/acmemanager.go

@ -74,7 +74,7 @@ func (m *ACMEManagerMaker) Provision(ctx caddy.Context) error {
return fmt.Errorf("loading DNS provider module: %s", err) return fmt.Errorf("loading DNS provider module: %s", err)
} }
m.Challenges.DNS = val.(challenge.Provider) m.Challenges.DNS = val.(challenge.Provider)
m.Challenges.DNSRaw = nil // allow GC to deallocate - TODO: Does this help? m.Challenges.DNSRaw = nil // allow GC to deallocate
} }
// policy-specific storage implementation // policy-specific storage implementation
@ -88,7 +88,7 @@ func (m *ACMEManagerMaker) Provision(ctx caddy.Context) error {
return fmt.Errorf("creating TLS storage configuration: %v", err) return fmt.Errorf("creating TLS storage configuration: %v", err)
} }
m.storage = cmStorage m.storage = cmStorage
m.Storage = nil // allow GC to deallocate - TODO: Does this help? m.Storage = nil // allow GC to deallocate
} }
return nil return nil

4
modules/caddytls/connpolicy.go

@ -46,7 +46,7 @@ func (cp ConnectionPolicies) TLSConfig(ctx caddy.Context) (*tls.Config, error) {
} }
cp[i].matchers = append(cp[i].matchers, val.(ConnectionMatcher)) cp[i].matchers = append(cp[i].matchers, val.(ConnectionMatcher))
} }
cp[i].Matchers = nil // allow GC to deallocate - TODO: Does this help? cp[i].Matchers = nil // allow GC to deallocate
// certificate selector // certificate selector
if pol.CertSelection != nil { if pol.CertSelection != nil {
@ -55,7 +55,7 @@ func (cp ConnectionPolicies) TLSConfig(ctx caddy.Context) (*tls.Config, error) {
return nil, fmt.Errorf("loading certificate selection module: %s", err) return nil, fmt.Errorf("loading certificate selection module: %s", err)
} }
cp[i].certSelector = val.(certmagic.CertificateSelector) cp[i].certSelector = val.(certmagic.CertificateSelector)
cp[i].CertSelection = nil // allow GC to deallocate - TODO: Does this help? cp[i].CertSelection = nil // allow GC to deallocate
} }
} }

2
modules/caddytls/sessiontickets.go

@ -62,7 +62,7 @@ func (s *SessionTicketService) provision(ctx caddy.Context) error {
return fmt.Errorf("loading TLS session ticket ephemeral keys provider module: %s", err) return fmt.Errorf("loading TLS session ticket ephemeral keys provider module: %s", err)
} }
s.keySource = val.(STEKProvider) s.keySource = val.(STEKProvider)
s.KeySource = nil // allow GC to deallocate - TODO: Does this help? s.KeySource = nil // allow GC to deallocate
// if session tickets or just rotation are // if session tickets or just rotation are
// disabled, no need to start service // disabled, no need to start service

4
modules/caddytls/tls.go

@ -71,7 +71,7 @@ func (t *TLS) Provision(ctx caddy.Context) error {
return fmt.Errorf("loading TLS automation management module: %s", err) return fmt.Errorf("loading TLS automation management module: %s", err)
} }
t.Automation.Policies[i].Management = val.(ManagerMaker) t.Automation.Policies[i].Management = val.(ManagerMaker)
t.Automation.Policies[i].ManagementRaw = nil // allow GC to deallocate - TODO: Does this help? t.Automation.Policies[i].ManagementRaw = nil // allow GC to deallocate
} }
// certificate loaders // certificate loaders
@ -138,7 +138,7 @@ func (t *TLS) Start() error {
return fmt.Errorf("automate: managing %v: %v", names, err) return fmt.Errorf("automate: managing %v: %v", names, err)
} }
} }
t.Certificates = nil // allow GC to deallocate - TODO: Does this help? t.Certificates = nil // allow GC to deallocate
return nil return nil
} }

Loading…
Cancel
Save