BewareMyPower commented on a change in pull request #6732: Auto update topic 
partitions for C++ client
URL: https://github.com/apache/pulsar/pull/6732#discussion_r409680606
 
 

 ##########
 File path: pulsar-client-cpp/lib/PartitionedConsumerImpl.cc
 ##########
 @@ -162,14 +174,17 @@ void 
PartitionedConsumerImpl::handleUnsubscribeAsync(Result result, unsigned int
         callback(ResultUnknownError);
         return;
     }
-    assert(unsubscribedSoFar_ <= numPartitions_);
-    assert(consumerIndex <= numPartitions_);
+    Lock consumersLock(consumersMutex_);
+    const auto numPartitions = numPartitions_;
 
 Review comment:
   I'll change soon, here I should've called method like 
`getNumPartitionsWithLock()` (like I did in `PartitionedConsumerImpl`.
   Because `producers_`/`consumers_` may be modified in timer's callback, the 
code that accessed `producers_`/`consumers_` and some other members (see 
comments in headers) should be protected by lock()/unlock(), except in 
`start()`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to