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 2020/07/17 05:35:30 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #7572: Kevin Wilson changes to fix segment crashes in pulsar

merlimat commented on a change in pull request #7572:
URL: https://github.com/apache/pulsar/pull/7572#discussion_r456227158



##########
File path: pulsar-client-cpp/lib/ClientConnection.cc
##########
@@ -289,13 +286,14 @@ void ClientConnection::startConsumerStatsTimer(std::vector<uint64_t> consumerSta
         consumerStatsRequests.push_back(it->first);
     }
 
-    DeadlineTimerPtr timer = consumerStatsRequestTimer_;
-    if (timer) {
-        timer->expires_from_now(operationsTimeout_);
-        timer->async_wait(std::bind(&ClientConnection::handleConsumerStatsTimeout, shared_from_this(),
-                                    std::placeholders::_1, consumerStatsRequests));
+    // If the close operation has reset the consumerStatsRequestTimer_ then the use_count will be zero
+    // Check if we have a timer still before we set the request timer to pop again.
+    if (consumerStatsRequestTimer_.use_count() > 0) {

Review comment:
       ```suggestion
       if (consumerStatsRequestTimer_) {
   ```

##########
File path: pulsar-client-cpp/lib/ClientConnection.cc
##########
@@ -1344,8 +1324,12 @@ void ClientConnection::handleKeepAliveTimeout() {
         havePendingPingRequest_ = true;
         sendCommand(Commands::newPing());
 
-        keepAliveTimer_->expires_from_now(boost::posix_time::seconds(KeepAliveIntervalInSeconds));
-        keepAliveTimer_->async_wait(std::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
+        // If the close operation has already called the keepAliveTimer_.reset() then the use_count will be zero And we do not attempt
+        // to dereference the pointer.
+        if (keepAliveTimer_.use_count() > 0) {

Review comment:
       ```suggestion
           if (keepAliveTimer_) {
   ```




----------------------------------------------------------------
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:
users@infra.apache.org