Skip to content

Commit 61b3670

Browse files
committed
lntest: do not do IO under mutex in fee_service
If HTTP response is consumed slowly, this might block other HTTP requests to the fee service, because the mutex is held.
1 parent 45c1564 commit 61b3670

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lntest/fee_service.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,13 @@ func (f *FeeService) Start() error {
115115
// handleRequest handles a client request for fee estimates.
116116
func (f *FeeService) handleRequest(w http.ResponseWriter, _ *http.Request) {
117117
f.lock.Lock()
118-
defer f.lock.Unlock()
119-
120118
bytes, err := json.Marshal(
121119
chainfee.WebAPIResponse{
122120
FeeByBlockTarget: f.feeRateMap,
123121
MinRelayFeerate: f.minRelayFeerate,
124122
},
125123
)
124+
f.lock.Unlock()
126125
require.NoErrorf(f, err, "cannot serialize estimates")
127126

128127
_, err = io.WriteString(w, string(bytes))

0 commit comments

Comments
 (0)