Skip to content

Commit 0ab28c2

Browse files
authored
Fix potential data race in pendingItem.done() (#1347)
* fix potential data race in pendingItem.done() * update * use defer
1 parent db5cb7a commit 0ab28c2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pulsar/producer_partition.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1741,8 +1741,10 @@ func (i *pendingItem) done(err error) {
17411741
if i.isDone {
17421742
return
17431743
}
1744+
17441745
i.isDone = true
1745-
buffersPool.Put(i.buffer)
1746+
// return the buffer to the pool after all callbacks have been called.
1747+
defer buffersPool.Put(i.buffer)
17461748
if i.flushCallback != nil {
17471749
i.flushCallback(err)
17481750
}

0 commit comments

Comments
 (0)