Skip to content

Commit

Permalink
[C++] Connect timer cancellation does not call timeout callback (apac…
Browse files Browse the repository at this point in the history
…he#11486)

Master issue: apache#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]>
  • Loading branch information
2 people authored and ciaocloud committed Oct 16, 2021
1 parent a962fe3 commit 53acc12
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pulsar-client-cpp/lib/PeriodicTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 53acc12

Please sign in to comment.