]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding extra protection to prevent cycles in the Agent linked list, which can cause...
authoraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 24 Jul 2008 08:27:36 +0000 (08:27 +0000)
committeraszostak <aszostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 24 Jul 2008 08:27:36 +0000 (08:27 +0000)
HLT/BASE/AliHLTModuleAgent.cxx

index 169878eb1878618e3d7b03696fcf96fbbc0e0ab0..64505145e9d93961f432550336fcddc2668f16c8 100644 (file)
@@ -207,6 +207,14 @@ int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
   // see header file for function documentation
   AliHLTLogging log;
   if (!pAgent) return -EINVAL;
+  // The following check is for extra protection. In some strange cases the agent might
+  // try to register itself more than once. So we need to check for that and prevent it.
+  // Otherwise we create a cycle in our linked list and go into an infinite loop.
+  AliHLTModuleAgent* current=fgAnchor;
+  while (current!=NULL) {
+    if (current == pAgent) return 0;
+    current = current->fpNext;
+  }
   if (fgAnchor==NULL) {
     fgAnchor=pAgent;
   } else {