forward: respect context (#6483)

Signed-off-by: Vladislav Yarmak <vladislav-ex-src@vm-0.com>
This commit is contained in:
Snawoot 2024-03-07 21:54:28 +02:00 committed by GitHub
parent fca7ce232e
commit 8e783897a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,7 +110,7 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
list := f.List()
deadline := time.Now().Add(defaultTimeout)
start := time.Now()
for time.Now().Before(deadline) {
for time.Now().Before(deadline) && ctx.Err() == nil {
if i >= len(list) {
// reached the end of list, reset to begin
i = 0