From: dbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Date: Tue, 28 Sep 2010 17:35:26 +0000 (+0000)
Subject: Work around a Net::Domain bug that can result in fqdn's like foo.example.com,bar.com
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9d95beb5f998a21f60f38005334478cfc4aa21b9;p=working%2FOpenSRF.git

Work around a Net::Domain bug that can result in fqdn's like foo.example.com,bar.com

The bug manifested when trying to run autogen.sh, with the output:
Updating fieldmapper
No Response from settings server...going to sleep

This was because SettingsParser was generating invalid XPath and consquently
errors in the opensrf.settings service; with no response, the attempt to run
autogen.sh would die.

This workaround splits the fqdn on commas and tries each possible domain in
the server setting XPath. Long term we either need to wait for Net::Domain
bug #60729 (https://rt.cpan.org/Public/Bug/Display.html?id=60729) to be
resolved, or consider alternatives.


git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@2029 9efc2488-bf62-4759-914b-345cdb29e865
---

diff --git a/src/perl/lib/OpenSRF/Utils/SettingsParser.pm b/src/perl/lib/OpenSRF/Utils/SettingsParser.pm
index ac36dca..dd504d6 100644
--- a/src/perl/lib/OpenSRF/Utils/SettingsParser.pm
+++ b/src/perl/lib/OpenSRF/Utils/SettingsParser.pm
@@ -134,7 +134,13 @@ sub XML2perl {
 # returns the full config hash for a given server
 sub get_server_config {
 	my( $self, $server ) = @_;
-	my $xpath = "/opensrf/default|/opensrf/hosts/$server";
+
+    # Work around a Net::Domain bug that can result in fqdn like foo.example.com,bar.com
+    my @servers = split /,/, $server;
+    my $xpath = "/opensrf/default";
+    foreach (@servers) {
+        $xpath .= "|/opensrf/hosts/$_";
+    }
 	return $self->_get( $xpath );
 }