Improve log messages for ApiListener::ApiTimerHandler

This commit is contained in:
Gunnar Beutner 2015-02-17 15:46:03 +01:00
parent b7e991b1cc
commit 667b62cc3c
1 changed files with 20 additions and 5 deletions

View File

@ -378,8 +378,11 @@ void ApiListener::ApiTimerHandler(void)
BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) { BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) {
/* only connect to endpoints in a) the same zone b) our parent zone c) immediate child zones */ /* only connect to endpoints in a) the same zone b) our parent zone c) immediate child zones */
if (my_zone != zone && my_zone != zone->GetParent() && zone != my_zone->GetParent()) if (my_zone != zone && my_zone != zone->GetParent() && zone != my_zone->GetParent()) {
Log(LogDebug, "ApiListener")
<< "Not connecting to Endpoint '" << zone->GetName() << "' because it's not in the same zone, a parent or a child zone.";
continue; continue;
}
bool connected = false; bool connected = false;
@ -391,21 +394,33 @@ void ApiListener::ApiTimerHandler(void)
} }
/* don't connect to an endpoint if we already have a connection to the zone */ /* don't connect to an endpoint if we already have a connection to the zone */
if (connected) if (connected) {
Log(LogDebug, "ApiListener")
<< "Not connecting to Endpoint '" << zone->GetName() << "' because we're already connected to it.";
continue; continue;
}
BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) { BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) {
/* don't connect to ourselves */ /* don't connect to ourselves */
if (endpoint->GetName() == GetIdentity()) if (endpoint->GetName() == GetIdentity()) {
Log(LogDebug, "ApiListener")
<< "Not connecting to Endpoint '" << zone->GetName() << "' because that's us.";
continue; continue;
}
/* don't try to connect to endpoints which don't have a host and port */ /* don't try to connect to endpoints which don't have a host and port */
if (endpoint->GetHost().IsEmpty() || endpoint->GetPort().IsEmpty()) if (endpoint->GetHost().IsEmpty() || endpoint->GetPort().IsEmpty()) {
Log(LogDebug, "ApiListener")
<< "Not connecting to Endpoint '" << zone->GetName() << "' because the host/port attributes are missing.";
continue; continue;
}
/* don't try to connect if there's already a connection attempt */ /* don't try to connect if there's already a connection attempt */
if (endpoint->GetConnecting()) if (endpoint->GetConnecting()) {
Log(LogDebug, "ApiListener")
<< "Not connecting to Endpoint '" << zone->GetName() << "' because we're already trying to connect to it.";
continue; continue;
}
boost::thread thread(boost::bind(&ApiListener::AddConnection, this, endpoint)); boost::thread thread(boost::bind(&ApiListener::AddConnection, this, endpoint));
thread.detach(); thread.detach();