Skip to content

Commit

Permalink
Fix data race: Do not modify the message after calling next()
Browse files Browse the repository at this point in the history
The message handler invoked by next, might do processing in a different
go routine, modifying the message options causes a data race. After
the message is handled, it is not reused, so the modification is not
necessary.
  • Loading branch information
Danielius1922 authored and Daniel Adam committed Jul 2, 2024
1 parent 2c59d93 commit de76143
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions net/blockwise/blockwise.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,6 @@ func (b *BlockWise[C]) handleReceivedMessage(w *responsewriter.ResponseWriter[C]
maxSZX = fitSZX(r, message.Block2, maxSZX)
block, errG := r.GetOptionUint32(message.Block2)
next(w, r)
if errG == nil {
r.Remove(message.Block2)
}
if w.Message().Code() == codes.Content && errG == nil {
startSendingMessageBlock = block
}
Expand Down

0 comments on commit de76143

Please sign in to comment.