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/25 09:53:27 UTC

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

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


##########
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:
   ```suggestion
       State previousState = state_.exchange(Closed);
       if (previousState == Closed) {
           return closeCallback(ResultAlreadyClosed);
       }
   ```
   
   Use camel case instead of snake case to make code style consistent. Or just simplify it to `if (state_.exchange(Closed) == Closed)`.



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