]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttleTrigger.cxx
Fix for bug #78633 (Diego)
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleTrigger.cxx
index d7ab8fe426b92a4dc39ae801fc3d5ff2194e76a5..9105d3559442db34aef7f3158d4b0f351f7156e0 100644 (file)
@@ -206,6 +206,24 @@ void AliShuttleTrigger::Terminate() {
        fCondition.Signal();
 }
 
+//______________________________________________________________________________________________
+void AliShuttleTrigger::CheckTerminate() 
+{
+       // 
+       // Checks if the Shuttle got an external terminate request by a created file 
+       // This is an alternative to the signal which causes problems with the API libraries
+       //
+
+       if (strlen(fConfig->GetTerminateFilePath()) == 0)
+               return;
+
+       if (gSystem->AccessPathName(fConfig->GetTerminateFilePath()) == kFALSE)
+       {
+               AliInfo("Terminate file exists. Terminating Shuttle...");
+               fTerminate = kTRUE;
+       }
+}
+
 //______________________________________________________________________________________________
 void AliShuttleTrigger::Run() {
        //
@@ -230,6 +248,7 @@ void AliShuttleTrigger::Run() {
 
                while (!(fNotified || fTerminate)) {
                        received=fCondition.TimedWaitRelative(1000*fConfig->GetTriggerWait());
+                       CheckTerminate();
                        if (received==1) break; // 1 = timeout
                }
 
@@ -268,6 +287,7 @@ void AliShuttleTrigger::Run() {
                }
        
                Collect();
+               CheckTerminate();
        }
 
        delete notifier;
@@ -289,7 +309,7 @@ Bool_t AliShuttleTrigger::Collect(Int_t run)
 
        gSystem->GetFsInfo(fConfig->GetShuttleFileSystem(), &id, &bsize, &blocks, &bfree);
 
-       AliInfo(Form("n. of free blocks = %d, total n. of blocks = %d",bfree,blocks));
+       AliInfo(Form("n. of free blocks = %ld, total n. of blocks = %ld",bfree,blocks));
        Int_t spaceFree = (Int_t)(((Float_t)bfree/(Float_t)blocks)*100);
 
        if (spaceFree < fConfig->GetFreeDiskWarningThreshold()) {