Skip to content

Commit

Permalink
Merge "Agent crash@ DiscoveryServiceClient::Subscribe" into R3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Aug 9, 2016
2 parents 0f3b780 + 3ddee66 commit a85be0d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/discovery/client/discovery_client.cc
Expand Up @@ -825,19 +825,22 @@ void DiscoveryServiceClient::Subscribe(std::string serviceName) {
}
}

if (resp->inuse_service_list_.size()) {
pugi::xml_node node_service = pugi->FindNode(serviceName);
if (!pugi->IsNull(node_service)) {
pugi->ReadNode(serviceName); //SetContext
pugi->AddChildNode("service-in-use-list", "");
std::vector<boost::asio::ip::tcp::endpoint>::iterator it;
for (it = resp->inuse_service_list_.begin();
it != resp->inuse_service_list_.end(); it++) {
boost::asio::ip::tcp::endpoint ep = *it;
std::string pub_id =
resp->GetPublisherId(ep.address().to_string());
pugi->AddChildNode("publisher-id", pub_id);
pugi->ReadNode("service-in-use-list");
{
tbb::mutex::scoped_lock lock(mutex_);
if (resp->inuse_service_list_.size()) {
pugi::xml_node node_service = pugi->FindNode(serviceName);
if (!pugi->IsNull(node_service)) {
pugi->ReadNode(serviceName); //SetContext
pugi->AddChildNode("service-in-use-list", "");
std::vector<boost::asio::ip::tcp::endpoint>::iterator it;
for (it = resp->inuse_service_list_.begin();
it != resp->inuse_service_list_.end(); it++) {
boost::asio::ip::tcp::endpoint ep = *it;
std::string pub_id =
resp->GetPublisherId(ep.address().to_string());
pugi->AddChildNode("publisher-id", pub_id);
pugi->ReadNode("service-in-use-list");
}
}
}
}
Expand Down Expand Up @@ -1235,6 +1238,7 @@ void DiscoveryServiceClient::AddSubscribeInUseServiceList(

DSSubscribeResponse *resp = GetSubscribeResponse(serviceName);
if (resp) {
tbb::mutex::scoped_lock lock(mutex_);
resp->AddInUseServiceList(ep);
}
}
Expand All @@ -1244,6 +1248,7 @@ void DiscoveryServiceClient::DeleteSubscribeInUseServiceList(

DSSubscribeResponse *resp = GetSubscribeResponse(serviceName);
if (resp) {
tbb::mutex::scoped_lock lock(mutex_);
resp->DeleteInUseServiceList(ep);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/discovery/client/discovery_client.h
Expand Up @@ -246,6 +246,7 @@ class DiscoveryServiceClient {
std::string subscriber_name_;
int heartbeat_interval_;
std::string local_addr_;
tbb::mutex mutex_;
};

#endif // __DISCOVERY_SERVICE_CLIENT_H__

0 comments on commit a85be0d

Please sign in to comment.