erobot commented on code in PR #131:
URL: https://github.com/apache/pulsar-client-cpp/pull/131#discussion_r1036704593


##########
lib/ProducerImpl.cc:
##########
@@ -694,6 +705,8 @@ void ProducerImpl::closeAsync(CloseCallback 
originalCallback) {
         }
     };
 
+    Lock lock(mutex_);

Review Comment:
   My understanding is that the race condition problem here is about state 
assumption. `closeAsync` checks state_ then have a assumption about cnx. 
`handleCreatedProducer` checks state_ then have a assumption that don't need to 
close producer.
   
   mutex_ here is like a global producer mutex. When performance is not 
critical, lock on a global mutex is simpler and easy to keep correction. Add 
new dedicated mutex should be possible, but would add complexity. Should we 
keep it simple for now, and refactor latter if necessary?



-- 
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