diff options
author | Matthew Holt <[email protected]> | 2023-07-08 13:42:51 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2023-07-08 13:42:51 -0600 |
commit | 5dec11f2a0e920d5466ff224a0749a667193e3ce (patch) | |
tree | b088d80cfdaa5ac17eef75922b1aecf608a5be9d | |
parent | 66114cb155f2a975ecdc9f3d2d89a9df1142791a (diff) | |
download | caddy-5dec11f2a0e920d5466ff224a0749a667193e3ce.tar.gz caddy-5dec11f2a0e920d5466ff224a0749a667193e3ce.zip |
reverseproxy: Pointer receiver
This avoids copying the Upstream, which has an atomically-accessed value
in it.
-rw-r--r-- | modules/caddyhttp/reverseproxy/hosts.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/caddyhttp/reverseproxy/hosts.go b/modules/caddyhttp/reverseproxy/hosts.go index 298d4f321..83a39d807 100644 --- a/modules/caddyhttp/reverseproxy/hosts.go +++ b/modules/caddyhttp/reverseproxy/hosts.go @@ -63,9 +63,10 @@ type Upstream struct { unhealthy int32 // accessed atomically; status from active health checker } -func (u Upstream) String() string { - return u.Dial -} +// (pointer receiver necessary to avoid a race condition, since +// copying the Upstream reads the 'unhealthy' field which is +// accessed atomically) +func (u *Upstream) String() string { return u.Dial } // Available returns true if the remote host // is available to receive requests. This is |