]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderDateOnline.cxx
Bug fix - array non initialized in certain conditions (Marian)
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDateOnline.cxx
index 242b230020cbbdba2e283dff48047971b3be54a9..139aaf4d95786cebae44dc461cfd83909f8d64e2 100644 (file)
@@ -27,6 +27,7 @@
 ///
 /// Cvetan Cheshkov 1/04/2008
 ///////////////////////////////////////////////////////////////////////////////
+#include <TSystem.h>
 
 #include "AliRawReaderDateOnline.h"
 #include "AliLog.h"
@@ -44,7 +45,8 @@ AliRawReaderDateOnline::AliRawReaderDateOnline(
                                   const char* /* filename */
 #endif
                                   ) :
-  AliRawReaderDate((void*)NULL)
+  AliRawReaderDate((void*)NULL),
+  fStop(kFALSE)
 {
 
 // Constructor
@@ -76,10 +78,13 @@ AliRawReaderDateOnline::AliRawReaderDateOnline(
   monitorSetNoWaitNetworkTimeout(1000);
 
   const Char_t* table[]  = {"ALL", "yes", "*", "*",
-                            "EOR", "all","*", "*",
+                            "EOR", "yes","*", "*",
                             NULL, NULL, NULL, NULL};
   monitorDeclareTableExtended(const_cast<char**>(table));
 
+  // install SIGUSR1 handler to allow clean end-of-events loop
+  gSystem->AddSignalHandler(new AliRawReaderDateIntHandler(this));
+
 #else
   Fatal("AliRawReaderDateOnline", "this class was compiled without DATE");
 #endif
@@ -92,6 +97,14 @@ Bool_t AliRawReaderDateOnline::NextEvent()
 
 #ifdef ALI_DATE
 
+  // Stop on SIGUSR1
+  if (fStop) {
+    AliInfo("Raw-data reading stopped by SIGUSR1");
+    if (fEvent) free(fEvent);
+    fEvent = NULL;
+    return kFALSE;
+  }
+
   // Event already loaded no need take a new one
   if (AliRawReaderDate::NextEvent()) return kTRUE;
 
@@ -133,6 +146,7 @@ Bool_t AliRawReaderDateOnline::NextEvent()
     
     if (!IsEventSelected()) {
       free(fEvent);
+      fEvent = NULL;
       continue;
     }
 
@@ -177,7 +191,7 @@ void AliRawReaderDateOnline::SelectEvents(Int_t type,
 #ifdef ALI_DATE
   const Char_t* table[]  = {"ALL", "no", "*", "*",
                            "PHY", "yes","*", "*",
-                            "EOR", "all","*", "*",
+                            "EOR", "yes","*", "*",
                            NULL, NULL, NULL, NULL};
   TString trSelection;
   for (Int_t i = 0; i < 50; i++) {
@@ -188,8 +202,17 @@ void AliRawReaderDateOnline::SelectEvents(Int_t type,
   }
   table[7] = trSelection.Data();
 
+  monitorLogout();
   monitorDeclareTableExtended(const_cast<char**>(table));
   
 #endif
   AliRawReader::SelectEvents(type,triggerMask,triggerExpr);
 }
+
+//______________________________________________________________________________
+void AliRawReaderDateOnline::Stop()
+{
+  // Stop the event loop (called on SIGUSR1)
+
+  fStop = kTRUE; 
+}