Skip to content

Commit

Permalink
Fix cpu spin loop when pending is closed while buf is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr.shibanov committed Jun 5, 2024
1 parent 3fad210 commit 634f4b6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions async_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@ func (p *asyncProducer) newBrokerProducer(broker *Broker) *brokerProducer {
select {
case res, ok := <-pending:
if !ok {
if buf.Length() != 0 {
time.Sleep(bp.parent.conf.Producer.Retry.Backoff)
}
continue
}
buf.Add(res)
Expand Down

0 comments on commit 634f4b6

Please sign in to comment.