limit: clamp bandwidth limiter burst (#5471)

This commit is contained in:
fatedier
2026-08-09 17:30:39 +08:00
committed by GitHub
parent 5b68148f11
commit f666d97b64
6 changed files with 117 additions and 2 deletions
+7
View File
@@ -34,8 +34,15 @@ func NewWriter(w io.Writer, limiter *rate.Limiter) *Writer {
}
func (w *Writer) Write(p []byte) (n int, err error) {
if len(p) == 0 {
return 0, nil
}
var nn int
b := w.limiter.Burst()
if b <= 0 {
return 0, invalidBurstError(b)
}
for {
end := len(p)
if end == 0 {