1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

reverseproxy: Pointer receiver

This avoids copying the Upstream, which has an atomically-accessed value
in it.
This commit is contained in:
Matthew Holt 2023-07-08 13:42:51 -06:00
parent 66114cb155
commit 5dec11f2a0
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -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