From bf4a7a6f4b88f9428ba167bdb16e03687fbb5846 Mon Sep 17 00:00:00 2001 From: "kade.lee" Date: Thu, 5 Dec 2024 20:14:14 +0900 Subject: [PATCH] Fix potential deadlock in hedging request Signed-off-by: kade.lee --- pkg/exthttp/hedging.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/exthttp/hedging.go b/pkg/exthttp/hedging.go index 09a1b3e8a2..af200bd92e 100644 --- a/pkg/exthttp/hedging.go +++ b/pkg/exthttp/hedging.go @@ -48,11 +48,11 @@ func (hrt *hedgingRoundTripper) RoundTrip(req *http.Request) (*http.Response, er } duration := float64(time.Since(start).Milliseconds()) hrt.mu.Lock() + defer hrt.mu.Unlock() err = hrt.TDigest.Add(duration) if err != nil { return nil, err } - hrt.mu.Unlock() return resp, err }