@@ -317,7 +317,7 @@ void ClientConnection::handlePulsarConnected(const proto::CommandConnected& cmdC
317317 // Only send keep-alive probes if the broker supports it
318318 keepAliveTimer_ = executor_->createDeadlineTimer ();
319319 if (keepAliveTimer_) {
320- keepAliveTimer_->expires_from_now (std::chrono::seconds (keepAliveIntervalInSeconds_));
320+ keepAliveTimer_->expires_after (std::chrono::seconds (keepAliveIntervalInSeconds_));
321321 auto weakSelf = weak_from_this ();
322322 keepAliveTimer_->async_wait ([weakSelf](const ASIO_ERROR&) {
323323 auto self = weakSelf.lock ();
@@ -362,7 +362,7 @@ void ClientConnection::startConsumerStatsTimer(std::vector<uint64_t> consumerSta
362362 // If the close operation has reset the consumerStatsRequestTimer_ then the use_count will be zero
363363 // Check if we have a timer still before we set the request timer to pop again.
364364 if (consumerStatsRequestTimer_) {
365- consumerStatsRequestTimer_->expires_from_now (operationsTimeout_);
365+ consumerStatsRequestTimer_->expires_after (operationsTimeout_);
366366 auto weakSelf = weak_from_this ();
367367 consumerStatsRequestTimer_->async_wait ([weakSelf, consumerStatsRequests](const ASIO_ERROR& err) {
368368 auto self = weakSelf.lock ();
@@ -621,32 +621,12 @@ void ClientConnection::handleResolve(ASIO_ERROR err, const tcp::resolver::result
621621 ptr->connectTimeoutTask_ ->stop ();
622622 });
623623
624- ASIO::async_connect (socket_, results, [weakSelf](const ASIO_ERROR& err, const tcp::endpoint& endpoint) {
624+ ASIO::async_connect (* socket_, results, [weakSelf](const ASIO_ERROR& err, const tcp::endpoint& endpoint) {
625625 auto self = weakSelf.lock ();
626626 if (self) {
627627 self->handleTcpConnected (err, endpoint);
628628 }
629629 });
630-
631- // TODO: use the new resolver results API to iterate over endpoints
632- /*
633- LOG_DEBUG(cnxString_ << "Connecting to " << endpointIterator->endpoint() << "...");
634- connectTimeoutTask_->start();
635- if (endpointIterator != tcp::resolver::iterator()) {
636- LOG_DEBUG(cnxString_ << "Resolved hostname " << endpointIterator->host_name() //
637- << " to " << endpointIterator->endpoint());
638- socket_->async_connect(*endpointIterator, [weakSelf, endpointIterator](const ASIO_ERROR& err) {
639- auto self = weakSelf.lock();
640- if (self) {
641- self->handleTcpConnected(err, endpointIterator);
642- }
643- });
644- } else {
645- LOG_WARN(cnxString_ << "No IP address found");
646- close();
647- return;
648- }
649- */
650630}
651631
652632void ClientConnection::readNextCommand () {
@@ -1050,7 +1030,7 @@ void ClientConnection::newLookup(const SharedBuffer& cmd, uint64_t requestId,
10501030 LookupRequestData requestData;
10511031 requestData.promise = promise;
10521032 requestData.timer = executor_->createDeadlineTimer ();
1053- requestData.timer ->expires_from_now (operationsTimeout_);
1033+ requestData.timer ->expires_after (operationsTimeout_);
10541034 auto weakSelf = weak_from_this ();
10551035 requestData.timer ->async_wait ([weakSelf, requestData](const ASIO_ERROR& ec) {
10561036 auto self = weakSelf.lock ();
@@ -1190,7 +1170,7 @@ Future<Result, ResponseData> ClientConnection::sendRequestWithId(const SharedBuf
11901170
11911171 PendingRequestData requestData;
11921172 requestData.timer = executor_->createDeadlineTimer ();
1193- requestData.timer ->expires_from_now (operationsTimeout_);
1173+ requestData.timer ->expires_after (operationsTimeout_);
11941174 auto weakSelf = weak_from_this ();
11951175 requestData.timer ->async_wait ([weakSelf, requestData](const ASIO_ERROR& ec) {
11961176 auto self = weakSelf.lock ();
@@ -1245,7 +1225,7 @@ void ClientConnection::handleKeepAliveTimeout() {
12451225 // be zero And we do not attempt to dereference the pointer.
12461226 Lock lock (mutex_);
12471227 if (keepAliveTimer_) {
1248- keepAliveTimer_->expires_from_now (std::chrono::seconds (keepAliveIntervalInSeconds_));
1228+ keepAliveTimer_->expires_after (std::chrono::seconds (keepAliveIntervalInSeconds_));
12491229 auto weakSelf = weak_from_this ();
12501230 keepAliveTimer_->async_wait ([weakSelf](const ASIO_ERROR&) {
12511231 auto self = weakSelf.lock ();
@@ -1307,12 +1287,12 @@ void ClientConnection::close(Result result, bool detach) {
13071287 numOfPendingLookupRequest_ = 0 ;
13081288
13091289 if (keepAliveTimer_) {
1310- keepAliveTimer_-> cancel ( );
1290+ cancelTimer (*keepAliveTimer_ );
13111291 keepAliveTimer_.reset ();
13121292 }
13131293
13141294 if (consumerStatsRequestTimer_) {
1315- consumerStatsRequestTimer_-> cancel ( );
1295+ cancelTimer (*consumerStatsRequestTimer_ );
13161296 consumerStatsRequestTimer_.reset ();
13171297 }
13181298
@@ -1424,7 +1404,7 @@ Future<Result, GetLastMessageIdResponse> ClientConnection::newGetLastMessageId(u
14241404 LastMessageIdRequestData requestData;
14251405 requestData.promise = promise;
14261406 requestData.timer = executor_->createDeadlineTimer ();
1427- requestData.timer ->expires_from_now (operationsTimeout_);
1407+ requestData.timer ->expires_after (operationsTimeout_);
14281408 auto weakSelf = weak_from_this ();
14291409 requestData.timer ->async_wait ([weakSelf, requestData](const ASIO_ERROR& ec) {
14301410 auto self = weakSelf.lock ();
@@ -1472,7 +1452,7 @@ Future<Result, SchemaInfo> ClientConnection::newGetSchema(const std::string& top
14721452 lock.unlock ();
14731453
14741454 auto weakSelf = weak_from_this ();
1475- timer->expires_from_now (operationsTimeout_);
1455+ timer->expires_after (operationsTimeout_);
14761456 timer->async_wait ([this , weakSelf, requestId](const ASIO_ERROR& ec) {
14771457 auto self = weakSelf.lock ();
14781458 if (!self) {
@@ -1559,7 +1539,7 @@ void ClientConnection::handleSuccess(const proto::CommandSuccess& success) {
15591539 lock.unlock ();
15601540
15611541 requestData.promise .setValue ({});
1562- requestData.timer -> cancel ( );
1542+ cancelTimer (* requestData.timer );
15631543 }
15641544}
15651545
@@ -1571,7 +1551,8 @@ void ClientConnection::handlePartitionedMetadataResponse(
15711551 Lock lock (mutex_);
15721552 auto it = pendingLookupRequests_.find (partitionMetadataResponse.request_id ());
15731553 if (it != pendingLookupRequests_.end ()) {
1574- it->second .timer ->cancel ();
1554+ cancelTimer (*it->second .timer );
1555+
15751556 LookupDataResultPromisePtr lookupDataPromise = it->second .promise ;
15761557 pendingLookupRequests_.erase (it);
15771558 numOfPendingLookupRequest_--;
@@ -1650,7 +1631,7 @@ void ClientConnection::handleLookupTopicRespose(
16501631 Lock lock (mutex_);
16511632 auto it = pendingLookupRequests_.find (lookupTopicResponse.request_id ());
16521633 if (it != pendingLookupRequests_.end ()) {
1653- it->second .timer -> cancel ( );
1634+ cancelTimer (* it->second .timer );
16541635 LookupDataResultPromisePtr lookupDataPromise = it->second .promise ;
16551636 pendingLookupRequests_.erase (it);
16561637 numOfPendingLookupRequest_--;
@@ -1728,7 +1709,7 @@ void ClientConnection::handleProducerSuccess(const proto::CommandProducerSuccess
17281709 data.topicEpoch = boost::none;
17291710 }
17301711 requestData.promise .setValue (data);
1731- requestData.timer -> cancel ( );
1712+ cancelTimer (* requestData.timer );
17321713 }
17331714 }
17341715}
@@ -1748,7 +1729,7 @@ void ClientConnection::handleError(const proto::CommandError& error) {
17481729 lock.unlock ();
17491730
17501731 requestData.promise .setFailed (result);
1751- requestData.timer -> cancel ( );
1732+ cancelTimer (* requestData.timer );
17521733 } else {
17531734 PendingGetLastMessageIdRequestsMap::iterator it =
17541735 pendingGetLastMessageIdRequests_.find (error.request_id ());
@@ -2041,8 +2022,8 @@ void ClientConnection::unsafeRemovePendingRequest(long requestId) {
20412022 auto it = pendingRequests_.find (requestId);
20422023 if (it != pendingRequests_.end ()) {
20432024 it->second .promise .setFailed (ResultDisconnected);
2044- ASIO_ERROR ec ;
2045- it-> second . timer -> cancel (ec);
2025+ cancelTimer (*it-> second . timer ) ;
2026+
20462027 pendingRequests_.erase (it);
20472028 }
20482029}
0 commit comments