From 048318e17e4d7fbe790dae88f21093c1fe14a294 Mon Sep 17 00:00:00 2001
From: Ruud Overeem <overeem@astron.nl>
Date: Wed, 26 Jul 2006 14:40:29 +0000
Subject: [PATCH] BugID: 811 When a task cannot find the parsetfile
 argv[0].parset during the init-phase the task no longer aborts, it just gives
 a debug-message in the logfile. This is neccesary for the controlleris since
 the controllers need an observai- tion-related (and instance-related)
 parsetfile that has the treeID and the instanceNr mangled in its name. The
 controllers theirselves know which parset file to open and do this in the
 constructor, so the task will still abort if the right parset file can not be
 found.

---
 MAC/GCF/GCFCommon/include/GCF/Utils.h         |  3 +++
 MAC/GCF/GCFCommon/src/Utils.cc                | 26 +++++++++++++++----
 MAC/GCF/TM/src/GCF_Task.cc                    |  9 +++++--
 .../TM/src/ServiceBroker/GSB_Controller.cc    |  2 +-
 4 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/MAC/GCF/GCFCommon/include/GCF/Utils.h b/MAC/GCF/GCFCommon/include/GCF/Utils.h
index 102d7e0735e..88eb5456ea6 100644
--- a/MAC/GCF/GCFCommon/include/GCF/Utils.h
+++ b/MAC/GCF/GCFCommon/include/GCF/Utils.h
@@ -9,6 +9,9 @@ namespace LOFAR {
  namespace GCF {
   namespace Common {
 
+// Returns the full or short version of the hostname
+string myHostname(bool	giveFullName);
+
 void	convListToString(std::string& listString, 
                          const std::list<std::string>& stringList);
 void	convStringToList(std::list<std::string>& stringList, 
diff --git a/MAC/GCF/GCFCommon/src/Utils.cc b/MAC/GCF/GCFCommon/src/Utils.cc
index 9236dbd0e99..a2e7993777d 100644
--- a/MAC/GCF/GCFCommon/src/Utils.cc
+++ b/MAC/GCF/GCFCommon/src/Utils.cc
@@ -7,13 +7,29 @@
 
 using std::set;
 
-namespace LOFAR 
+namespace LOFAR {
+ namespace GCF {
+  namespace Common {
+
+//
+// myHostname(giveFullname)
+//
+string myHostname(bool	giveFullName)
 {
- namespace GCF 
- {
-  namespace Common 
-  {
+	char	fullhostname[300];
+	if (gethostname(fullhostname, 300) != 0) {
+		return ("localhost");
+	}
+
+	if (!giveFullName) {
+		char*	dot = strchr(fullhostname, '.');
+		if (dot) {
+			*dot='\0';
+		}
+	}
 
+	return (fullhostname);
+}
 
 void convListToString(string& listString, 
                                   const list<string>& stringList)
diff --git a/MAC/GCF/TM/src/GCF_Task.cc b/MAC/GCF/TM/src/GCF_Task.cc
index aba8a0af3c6..09e5eb27c32 100644
--- a/MAC/GCF/TM/src/GCF_Task.cc
+++ b/MAC/GCF/TM/src/GCF_Task.cc
@@ -89,8 +89,13 @@ void GCFTask::init(int argc, char** argv)
 	// Read in the ParameterSet of the task (<task>.conf)
 	ParameterSet*	pParamSet = ACC::APS::globalParameterSet();
 	string			configFile(aCL.locate(procName + ".conf"));
-	LOG_DEBUG_STR ("Using parameterfile: " << configFile);
-	pParamSet->adoptFile(configFile);
+	if (!configFile.empty()) {
+		LOG_DEBUG_STR ("Using parameterfile: " << configFile);
+		pParamSet->adoptFile(configFile);
+	}
+	else {
+		LOG_DEBUG_STR ("NO DEFAULT PARAMETERSET FOUND");
+	}
 
 	if (_doExit) {
 		exit(-1);
diff --git a/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.cc b/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.cc
index ba4c4c0324a..acad7de86d7 100644
--- a/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.cc
+++ b/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.cc
@@ -183,7 +183,7 @@ GCFEvent::TResult GSBController::operational(GCFEvent& event, GCFPortInterface&
 			LOG_INFO(formatString ("Serviceinfo for %s is %d", 
 									request.servicename.c_str(), portNr));
 			response.portnumber = portNr;
-			response.hostname	= Common::myHostname();
+			response.hostname	= Common::myHostname(true);
 			response.result 	= SB_NO_ERROR;
 		}
 		else {
-- 
GitLab