Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init limits if nil #844

Merged
merged 8 commits into from
Jul 19, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,14 @@
}
Logger.Printf("Sending %s failed with the following error: %s", eventType, string(b))
}

t.mu.Lock()
if t.limits == nil {
t.limits = make(ratelimit.Map)

Check warning on line 556 in transport.go

View check run for this annotation

Codecov / codecov/patch

transport.go#L556

Added line #L556 was not covered by tests
}
t.limits.Merge(ratelimit.FromResponse(response))
t.mu.Unlock()

// Drain body up to a limit and close it, allowing the
// transport to reuse TCP connections.
_, _ = io.CopyN(io.Discard, response.Body, maxDrainResponseBytes)
Expand Down Expand Up @@ -690,6 +695,10 @@
}

t.mu.Lock()
if t.limits == nil {
t.limits = make(ratelimit.Map)

Check warning on line 699 in transport.go

View check run for this annotation

Codecov / codecov/patch

transport.go#L699

Added line #L699 was not covered by tests
}

t.limits.Merge(ratelimit.FromResponse(response))
t.mu.Unlock()

Expand Down
Loading