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/11/11 05:48:29 UTC

[GitHub] [pulsar] BewareMyPower commented on pull request #8519: [C++] Fix potential crash caused by AckGroupTracker's timer

BewareMyPower commented on pull request #8519:
URL: https://github.com/apache/pulsar/pull/8519#issuecomment-725214827


   By the way, there's another solution that checks `error_code` for `boost::asio::error::operation_aborted`:
   
   ```diff
   diff --git a/pulsar-client-cpp/lib/AckGroupingTrackerEnabled.cc b/pulsar-client-cpp/lib/AckGroupingTrackerEnabled.cc
   index 5c61ccaf164..a5ce0172fb8 100644
   --- a/pulsar-client-cpp/lib/AckGroupingTrackerEnabled.cc
   +++ b/pulsar-client-cpp/lib/AckGroupingTrackerEnabled.cc
   @@ -144,7 +144,7 @@ void AckGroupingTrackerEnabled::scheduleTimer() {
        this->timer_ = this->executor_->createDeadlineTimer();
        this->timer_->expires_from_now(boost::posix_time::milliseconds(std::max(1L, this->ackGroupingTimeMs_)));
        this->timer_->async_wait([this](const boost::system::error_code& ec) -> void {
   -        if (!ec) {
   +        if (!ec && ec != boost::system::error::operation_aborted) {
                this->flush();
                this->scheduleTimer();
            }
   ```
   
   PROS: The `unique_ptr` is more efficient because it avoids the overhead of reference count's atomic operation
   CONS: If the timer was cancelled, the pending messages may not be acknowledged.


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