cckellogg commented on a change in pull request #712:
URL: https://github.com/apache/pulsar-client-go/pull/712#discussion_r787241978



##########
File path: pulsar/producer_partition.go
##########
@@ -709,35 +709,40 @@ func (p *partitionProducer) internalFlush(fr 
*flushRequest) {
                // The last item in the queue has been completed while we were
                // looking at it. It's safe at this point to assume that every
                // message enqueued before Flush() was called are now persisted
-               fr.waitGroup.Done()
+               close(fr.doneCh)
                return
        }
 
        sendReq := &sendRequest{
                msg: nil,
                callback: func(id MessageID, message *ProducerMessage, e error) 
{
                        fr.err = e
-                       fr.waitGroup.Done()
+                       close(fr.doneCh)
                },
        }
 
        pi.sendRequests = append(pi.sendRequests, sendReq)
 }
 
 func (p *partitionProducer) Send(ctx context.Context, msg *ProducerMessage) 
(MessageID, error) {
-       wg := sync.WaitGroup{}
-       wg.Add(1)
-
        var err error
        var msgID MessageID
 
+       // use atomic bool to avoid race
+       isDone := uAtomic.NewBool(false)

Review comment:
       Why is `isDone` needed? Each call to this function will get it's own 
channel instance.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to