From f34a88c77bb23c26be1e85284364bdc0e0778579 Mon Sep 17 00:00:00 2001
From: Alexander Mueller <alexander.mueller@hs.uni-hamburg.de>
Date: Mon, 19 Sep 2005 08:54:57 +0000
Subject: [PATCH] BugID: 258 removed the dpGet from the dpAccessable. For this
 solution a method is introduced, which must be invoked once in each
 navigator.

---
 MAC/Navigator/panels/nav_fw/navigator.pnl     |  2 +-
 .../scripts/libs/nav_fw/gcf-common.ctl        | 54 ++++++++++++++-----
 2 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/MAC/Navigator/panels/nav_fw/navigator.pnl b/MAC/Navigator/panels/nav_fw/navigator.pnl
index 0ac2b3c8d54..64a64e3301d 100644
--- a/MAC/Navigator/panels/nav_fw/navigator.pnl
+++ b/MAC/Navigator/panels/nav_fw/navigator.pnl
@@ -4,8 +4,8 @@ LANG:1 15 LOFAR Navigator
 PANEL,417 201 1272 960 N "_3DFace" 0
 "main()
 {
+  gcfStartFollowDistSystems();
   navConfigCheckResourceRoots();
-  navPMLinitialize();
   Navigator_HandleEventInitialize();
   navConfigInitPathNames();
 }
diff --git a/MAC/Navigator/scripts/libs/nav_fw/gcf-common.ctl b/MAC/Navigator/scripts/libs/nav_fw/gcf-common.ctl
index 6a881016d65..4b4914aaf2f 100644
--- a/MAC/Navigator/scripts/libs/nav_fw/gcf-common.ctl
+++ b/MAC/Navigator/scripts/libs/nav_fw/gcf-common.ctl
@@ -7,28 +7,56 @@
 // Output: TRUE, if accessable and existing,
 //         FALSE, if not accessable and/or not existing
 ///////////////////////////////////////////////////////////////////////////
+
+global dyn_int g_distributedSystems;
+global int g_distSysVarSem = 0;
+
+void gcfStartFollowDistSystems()
+{
+  g_distSysVarSem = 0;
+  dpConnect("followDistributedSystems", "_DistManager.State.SystemNums");
+}
+
+void followDistributedSystems(string dp, dyn_int value)
+{
+  while (g_distSysVarSem > 0) // wait until the "semaphore" is freed by the dpAccessable method
+  ;
+  g_distributedSystems = value;
+}
+
 bool dpAccessable(string dpName)
 {
-  string dpSystemName = strrtrim(dpSubStr(dpName,DPSUB_SYS),":");
-  if(getSystemName()==(dpSystemName+":"))
-  {
-    return dpExists(dpName);
-  }
-  else if (getSystemName()!=(dpSystemName+":"))
+  if (dpExists(dpName))
   {
-    dyn_int distributedSystems;
-    dpGet("_DistManager.State.SystemNums", distributedSystems);
-    //Check if dpSystemName is in the distributedSystems list
-    if (dynlen(distributedSystems)>0)
+	string dpSystemName = strrtrim(dpSubStr(dpName, DPSUB_SYS), ":");
+  	if (getSystemName() == (dpSystemName + ":"))
     {
-      for(int i=1; i<=dynlen(distributedSystems); i++)
+      return TRUE;
+    }
+    else
+    {
+	  g_distSysVarSem++; // set "semaphore"
+	  // check if the dist. system with the systemname from the dpName is reachable
+      if (dynlen(g_distributedSystems) > 0)
       {
-        if(getSystemName(distributedSystems[i])==(dpSystemName+":"))  //if the system is reacheable
+        // Check whether the first part of the dpName is a valid system name 
+        // and the name of a reachable dist. system
+        dyn_string splitedDPName = strsplit(dpName, ':');
+        for (int i = 1; i <= dynlen(g_distributedSystems); i++)
         {
-          return dpExists(dpName);
+          if (getSystemName(g_distributedSystems[i]) == (splitedDPName[1] + ":"))
+          {
+		    g_distSysVarSem--; // release "semaphore"
+            return TRUE;
+          }          
         }
       }
+	  g_distSysVarSem--; // release "semaphore"
+      return FALSE;
     }
+  }
+  else
+  {
     return FALSE;
   }
 }
-- 
GitLab