@marcel91200 / caddy Mirror · read-only / commits / 5dec11f2
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 00:30 UTC

reverseproxy: Pointer receiver

This avoids copying the Upstream, which has an atomically-accessed value in it.

Matthew Holt committed Jul 8, 2023 at 13:42 UTC 5dec11f2a0e920d5466ff224a0749a667193e3ce
1 file changed +4 -3
modules/caddyhttp/reverseproxy/hosts.go
+4 -3
@@ -63,9 +63,10 @@ type Upstream struct {
63 unhealthy int32 // accessed atomically; status from active health checker
64 }
65
66 -func (u Upstream) String() string {
67 - return u.Dial
68 -}
66 +// (pointer receiver necessary to avoid a race condition, since
67 +// copying the Upstream reads the 'unhealthy' field which is
68 +// accessed atomically)
69 +func (u *Upstream) String() string { return u.Dial }
70
71 // Available returns true if the remote host
72 // is available to receive requests. This is