From 054e6877854f4f3a14a99052578a9b64c1d9069f Mon Sep 17 00:00:00 2001 From: Jack Vanlightly Date: Wed, 28 Jul 2021 17:53:42 +0200 Subject: [PATCH] [C++] Connect timer cancellation does not call timeout callback 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. --- 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 f25a175e4d073..533d38b5efa94 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; }