Skip to content

Commit

Permalink
DiscoveryClient stops resusbcribing even after ttl period.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nipak committed Mar 30, 2016
1 parent 4e6eabf commit 5450c6a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/discovery/client/discovery_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down Expand Up @@ -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_);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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_++;
Expand All @@ -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
Expand Down

0 comments on commit 5450c6a

Please sign in to comment.