From 5450c6af394936a9f431b52a5dd1e3df3f2fb2be Mon Sep 17 00:00:00 2001 From: Nipa Kumar Date: Wed, 30 Mar 2016 16:14:15 -0700 Subject: [PATCH] DiscoveryClient stops resusbcribing even after ttl period. On no response from discovery server and no error, subscribe timer is not restarted as the subscribe_cb_called_ flag was not reset. Setting the flag appropriately on every subscribe request, so subscribe timer can be restarted during the case above. HeartBeat will not be effected as heartbeat timer is periodic and is started on succesful publish. Remove unnecessary curl timeout traces, use stats counters. Change-Id: Iddd5a3b4f09a6c9c6fbce14878624ada622b3174 Closes-Bug:1563002 --- src/discovery/client/discovery_client.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/discovery/client/discovery_client.cc b/src/discovery/client/discovery_client.cc index 3d2b8d18058..587da95724c 100644 --- a/src/discovery/client/discovery_client.cc +++ b/src/discovery/client/discovery_client.cc @@ -486,6 +486,8 @@ void DiscoveryServiceClient::ReEvaluatePublish(std::string serviceName, resp->publish_msg_ = ss.str(); } + resp->pub_sent_++; + resp->publish_cb_called_ = false; /* Send publish unconditionally */ DISCOVERY_CLIENT_TRACE(DiscoveryClientMsg, resp->publish_hdr_, serviceName, resp->publish_msg_); @@ -666,6 +668,7 @@ void DiscoveryServiceClient::Subscribe(std::string serviceName, uint8_t numbOfIn DSResponseHeader *resp = loc->second; resp->subscribe_timer_->Cancel(); resp->sub_sent_++; + resp->subscribe_cb_called_ = false; SendHttpPostMessage("subscribe", serviceName, resp->subscribe_msg_); } } @@ -894,6 +897,7 @@ void DiscoveryServiceClient::SendHeartBeat(std::string serviceName, std::string msg) { DSPublishResponse *resp = GetPublishResponse(serviceName); resp->pub_hb_sent_++; + resp->heartbeat_cb_called_ = false; SendHttpPostMessage("heartbeat", serviceName, msg); } @@ -930,11 +934,6 @@ void DiscoveryServiceClient::HeartBeatResponseHandler(std::string &xmls, // Errorcode is of type CURLcode if (ec.value() != 0) { - DISCOVERY_CLIENT_TRACE(DiscoveryClientErrorMsg, - "Error HeartBeatResponseHandler ", - serviceName + " " + curl_error_category.message(ec.value()), - ec.value()); - resp->pub_hb_fail_++; // Resend original publish request after exponential back-off resp->attempts_++; @@ -951,6 +950,11 @@ void DiscoveryServiceClient::HeartBeatResponseHandler(std::string &xmls, // reset attempts so publish can be sent right away resp->attempts_ = 0; } + } else { + DISCOVERY_CLIENT_TRACE(DiscoveryClientErrorMsg, + "Error HeartBeatResponseHandler ", + serviceName + " " + curl_error_category.message(ec.value()), + ec.value()); } // Update connection info