From d77efc7128af230e2609c0d6c9369e513ff07600 Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Mon, 18 Nov 2024 16:24:52 -0600 Subject: [PATCH] fix: unlock mutex on shutdown in blockfetch --- protocol/blockfetch/client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/protocol/blockfetch/client.go b/protocol/blockfetch/client.go index 27789e7b..4bedf0c7 100644 --- a/protocol/blockfetch/client.go +++ b/protocol/blockfetch/client.go @@ -127,6 +127,7 @@ func (c *Client) GetBlockRange(start common.Point, end common.Point) error { "role", "client", "connection_id", c.callbackContext.ConnectionId.String(), ) + // NOTE: this will be unlocked on BatchDone c.busyMutex.Lock() c.blockUseCallback = true msg := NewMsgRequestRange(start, end) @@ -136,6 +137,7 @@ func (c *Client) GetBlockRange(start common.Point, end common.Point) error { } err, ok := <-c.startBatchResultChan if !ok { + c.busyMutex.Unlock() return protocol.ProtocolShuttingDownError } if err != nil { @@ -155,6 +157,7 @@ func (c *Client) GetBlock(point common.Point) (ledger.Block, error) { "role", "client", "connection_id", c.callbackContext.ConnectionId.String(), ) + // NOTE: this will be unlocked on BatchDone c.busyMutex.Lock() c.blockUseCallback = false msg := NewMsgRequestRange(point, point)