This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 8070a82  [C++] Connect timer cancellation does not call timeout 
callback (#11486)
8070a82 is described below

commit 8070a821fd0fc774de9ca41ebcff715841d60458
Author: Jack Vanlightly <[email protected]>
AuthorDate: Fri Jul 30 02:29:15 2021 +0200

    [C++] Connect timer cancellation does not call timeout callback (#11486)
    
    Master issue: #11485
    
    When the PeriodicTask timer is cancelled it calls the handler
    which in turn ends up invoking the callback which closes
    the socket. This prevents the iteration over multiple endpoints
    until the connection succeeds. This change checks the error_code
    in the handler and returns if it is operation_cancelled,
    avoiding erroneously calling the callback.
    
    Co-authored-by: Jack Vanlightly <[email protected]>
---
 pulsar-client-cpp/lib/PeriodicTask.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pulsar-client-cpp/lib/PeriodicTask.cc 
b/pulsar-client-cpp/lib/PeriodicTask.cc
index f25a175..533d38b 100644
--- a/pulsar-client-cpp/lib/PeriodicTask.cc
+++ b/pulsar-client-cpp/lib/PeriodicTask.cc
@@ -43,7 +43,7 @@ void PeriodicTask::stop() {
 }
 
 void PeriodicTask::handleTimeout(const ErrorCode& ec) {
-    if (state_ != Ready) {
+    if (state_ != Ready || ec.value() == 
boost::system::errc::operation_canceled) {
         return;
     }
 

Reply via email to