Remove unneeded local scope
(no functional change intended)
This commit is contained in:
@@ -508,64 +508,62 @@ void SGTerraSync::SvnThread::run()
|
||||
_active = true;
|
||||
initCompletedTilesPersistentCache();
|
||||
|
||||
{
|
||||
if (_httpServer == "automatic" ) {
|
||||
if (_httpServer == "automatic" ) {
|
||||
|
||||
//TODO: make DN and service settable from properties
|
||||
DNS::NAPTRRequest * naptrRequest = new DNS::NAPTRRequest("terrasync.flightgear.org");
|
||||
naptrRequest->qservice = "ws20";
|
||||
//TODO: make DN and service settable from properties
|
||||
DNS::NAPTRRequest * naptrRequest = new DNS::NAPTRRequest("terrasync.flightgear.org");
|
||||
naptrRequest->qservice = "ws20";
|
||||
|
||||
naptrRequest->qflags = "U";
|
||||
DNS::Request_ptr r(naptrRequest);
|
||||
naptrRequest->qflags = "U";
|
||||
DNS::Request_ptr r(naptrRequest);
|
||||
|
||||
DNS::Client dnsClient;
|
||||
dnsClient.makeRequest(r);
|
||||
while( !r->isComplete() && !r->isTimeout() )
|
||||
dnsClient.update(0);
|
||||
DNS::Client dnsClient;
|
||||
dnsClient.makeRequest(r);
|
||||
while( !r->isComplete() && !r->isTimeout() )
|
||||
dnsClient.update(0);
|
||||
|
||||
if( naptrRequest->entries.empty() ) {
|
||||
SG_LOG(SG_TERRASYNC, SG_ALERT, "ERROR: automatic terrasync http-server requested, but no DNS entry found.");
|
||||
_httpServer = "";
|
||||
} else {
|
||||
// walk through responses, they are ordered by 1. order and 2. preference
|
||||
// For now, only take entries with lowest order
|
||||
// TODO: try all available servers in the order given by preferenc and order
|
||||
int order = naptrRequest->entries[0]->order;
|
||||
if( naptrRequest->entries.empty() ) {
|
||||
SG_LOG(SG_TERRASYNC, SG_ALERT, "ERROR: automatic terrasync http-server requested, but no DNS entry found.");
|
||||
_httpServer = "";
|
||||
} else {
|
||||
// walk through responses, they are ordered by 1. order and 2. preference
|
||||
// For now, only take entries with lowest order
|
||||
// TODO: try all available servers in the order given by preferenc and order
|
||||
int order = naptrRequest->entries[0]->order;
|
||||
|
||||
// get all servers with this order and the same (for now only lowest preference)
|
||||
DNS::NAPTRRequest::NAPTR_list availableServers;
|
||||
for( DNS::NAPTRRequest::NAPTR_list::const_iterator it = naptrRequest->entries.begin();
|
||||
it != naptrRequest->entries.end();
|
||||
++it ) {
|
||||
// get all servers with this order and the same (for now only lowest preference)
|
||||
DNS::NAPTRRequest::NAPTR_list availableServers;
|
||||
for( DNS::NAPTRRequest::NAPTR_list::const_iterator it = naptrRequest->entries.begin();
|
||||
it != naptrRequest->entries.end();
|
||||
++it ) {
|
||||
|
||||
if( (*it)->order != order )
|
||||
continue;
|
||||
if( (*it)->order != order )
|
||||
continue;
|
||||
|
||||
string regex = (*it)->regexp;
|
||||
if( false == simgear::strutils::starts_with( (*it)->regexp, "!^.*$!" ) ) {
|
||||
SG_LOG(SG_TERRASYNC,SG_WARN, "ignoring unsupported regexp: " << (*it)->regexp );
|
||||
continue;
|
||||
}
|
||||
string regex = (*it)->regexp;
|
||||
if( false == simgear::strutils::starts_with( (*it)->regexp, "!^.*$!" ) ) {
|
||||
SG_LOG(SG_TERRASYNC,SG_WARN, "ignoring unsupported regexp: " << (*it)->regexp );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( false == simgear::strutils::ends_with( (*it)->regexp, "!" ) ) {
|
||||
SG_LOG(SG_TERRASYNC,SG_WARN, "ignoring unsupported regexp: " << (*it)->regexp );
|
||||
continue;
|
||||
}
|
||||
if( false == simgear::strutils::ends_with( (*it)->regexp, "!" ) ) {
|
||||
SG_LOG(SG_TERRASYNC,SG_WARN, "ignoring unsupported regexp: " << (*it)->regexp );
|
||||
continue;
|
||||
}
|
||||
|
||||
// always use first entry
|
||||
if( availableServers.empty() || (*it)->preference == availableServers[0]->preference) {
|
||||
SG_LOG(SG_TERRASYNC,SG_DEBUG, "available server regexp: " << (*it)->regexp );
|
||||
availableServers.push_back( *it );
|
||||
}
|
||||
}
|
||||
|
||||
// now pick a random entry from the available servers
|
||||
DNS::NAPTRRequest::NAPTR_list::size_type idx = sg_random() * availableServers.size();
|
||||
_httpServer = availableServers[idx]->regexp;
|
||||
_httpServer = _httpServer.substr( 6, _httpServer.length()-7 ); // strip search pattern and separators
|
||||
|
||||
SG_LOG(SG_TERRASYNC,SG_INFO, "picking entry # " << idx << ", server is " << _httpServer );
|
||||
// always use first entry
|
||||
if( availableServers.empty() || (*it)->preference == availableServers[0]->preference) {
|
||||
SG_LOG(SG_TERRASYNC,SG_DEBUG, "available server regexp: " << (*it)->regexp );
|
||||
availableServers.push_back( *it );
|
||||
}
|
||||
}
|
||||
|
||||
// now pick a random entry from the available servers
|
||||
DNS::NAPTRRequest::NAPTR_list::size_type idx = sg_random() * availableServers.size();
|
||||
_httpServer = availableServers[idx]->regexp;
|
||||
_httpServer = _httpServer.substr( 6, _httpServer.length()-7 ); // strip search pattern and separators
|
||||
|
||||
SG_LOG(SG_TERRASYNC,SG_INFO, "picking entry # " << idx << ", server is " << _httpServer );
|
||||
}
|
||||
}
|
||||
if( _httpServer.empty() ) { // don't resolve SVN server is HTTP server is set
|
||||
|
||||
Reference in New Issue
Block a user