You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/11/28 02:18:07 UTC

[GitHub] [pulsar-client-cpp] RobertIndie commented on a diff in pull request #125: [fix] Fix PartitionedProducerImpl::closeAsync to close sub-producers properly

RobertIndie commented on code in PR #125:
URL: https://github.com/apache/pulsar-client-cpp/pull/125#discussion_r1033067388


##########
lib/PartitionedProducerImpl.cc:
##########
@@ -266,13 +266,10 @@ void PartitionedProducerImpl::closeAsync(CloseCallback originalCallback) {
             originalCallback(result);
         }
     };
-    if (state_ == Closed) {
-        closeCallback(ResultAlreadyClosed);
-        return;
-    }
-    State expectedState = Ready;
-    if (!state_.compare_exchange_strong(expectedState, Closing)) {
-        return;
+
+    State previous_state = state_.exchange(Closed);
+    if (previous_state == Closed) {
+        return closeCallback(ResultAlreadyClosed);

Review Comment:
   We should exchange it with the `Closing` state. And if the producer is already in `Closing`, this code still be passed, which results in wrong behavior.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org