apply idendical policy as PubSub for exchanged data blocks: NULL output allowed,...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Sep 2007 11:21:09 +0000 (11:21 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Sep 2007 11:21:09 +0000 (11:21 +0000)
HLT/BASE/AliHLTConfiguration.cxx
HLT/BASE/AliHLTDataBuffer.cxx

index 543b089ac9411b34607d8f6b6999fdfb548a8dfb..3944ae37f2daab8414a49276231cd9dc13eac9ef 100644 (file)
@@ -828,7 +828,7 @@ int AliHLTTask::ProcessTask(Int_t eventNo)
            HLTDebug("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this);
          }
        }
-       if ((iResult=pSrcTask->Subscribe(this, &fBlockDataArray[iSourceDataBlock],fBlockDataArray.size()-iSourceDataBlock))>0) {
+       if ((iResult=pSrcTask->Subscribe(this, &fBlockDataArray[iSourceDataBlock],fBlockDataArray.size()-iSourceDataBlock))>=0) {
          for (int i=0; i<iResult; i++) {
            iInputDataVolume+=fBlockDataArray[i+iSourceDataBlock].fSize;
            // put the source task as many times into the list as it provides data blocks
@@ -884,7 +884,7 @@ int AliHLTTask::ProcessTask(Int_t eventNo)
       if (pTgtBuffer!=NULL || iOutputDataSize==0) {
        iResult=pComponent->ProcessEvent(evtData, &fBlockDataArray[0], trigData, pTgtBuffer, size, outputBlockCnt, outputBlocks, edd);
        HLTDebug("task %s: component %s ProcessEvent finnished (%d): size=%d blocks=%d", GetName(), pComponent->GetComponentID(), iResult, size, outputBlockCnt);
-       if (iResult>=0 && pTgtBuffer) {
+       if (iResult>=0 && pTgtBuffer && outputBlocks) {
          iResult=fpDataBuffer->SetSegments(pTgtBuffer, outputBlocks, outputBlockCnt);
          delete [] outputBlocks; outputBlocks=NULL; outputBlockCnt=0;
        } else {
index 4dc06ccecfb0e9da7dc9f7cd8ef3842fb791b3ab..d00b9d1deb19aea40e6d5632a20ae4573d3dad1c 100644 (file)
@@ -151,6 +151,14 @@ int AliHLTDataBuffer::FindMatchingDataSegments(const AliHLTComponent* pConsumer,
 {
   // see header file for function documentation
   int iResult=0;
+
+  // Matthias 26.09.2007 relax the restriction to matching data blocks
+  // all blocks are passed to the consumer, which is the policy also in
+  // PubSub
+  tgtList.assign(fSegments.begin(), fSegments.end());
+  iResult=tgtList.size();
+  return iResult;
+  
   if (pConsumer) {
     vector<AliHLTComponentDataType> dtlist;
     ((AliHLTComponent*)pConsumer)->GetInputDataTypes(dtlist);
@@ -183,11 +191,10 @@ int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponen
       AliHLTConsumerDescriptor* pDesc=FindConsumer(pConsumer, fConsumers);
       if (pDesc) {
        vector<AliHLTDataBuffer::AliHLTDataSegment> tgtList;
-       /* TODO: think about a good policy for this check
-        * is it enough that at least one segment is available, or have all to be available?
-        * or is it possible to have optional segments?
-        */
-       if ((iResult=FindMatchingDataSegments(pConsumer, tgtList))>0) {
+       // Matthias 26.07.2007 AliHLTSystem should behave the same way as PubSub
+       // so it does not matter if there are matching data types or not, unless
+       // we implement such a check in PubSub
+       if ((iResult=FindMatchingDataSegments(pConsumer, tgtList))>=0) {
          int i =0;
          vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=tgtList.begin();
          while (segment!=tgtList.end() && i<iArraySize) {
@@ -210,6 +217,11 @@ int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponen
            i++;
            segment++;
          }
+         // check whether there was enough space for the segments
+         if (i!=tgtList.size()) {
+           HLTError("too little space in block descriptor array: required %d, available %d", tgtList.size(), iArraySize);
+           iResult=-ENOSPC;
+         } else {
          // move this consumer to the active list
          if (ChangeConsumerState(pDesc, fConsumers, fActiveConsumers)>=0) {
            HLTDebug("component %p (%s) subscribed to data buffer %p", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID(), this);
@@ -219,6 +231,7 @@ int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponen
            HLTError("can not activate consumer %p for data buffer %p", pConsumer, this);
            iResult=-EACCES;
          }
+         }
        } else {
          HLTError("unresolved data segment(s) for component %p (%s)", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID());
          iResult=-EBADF;
@@ -228,8 +241,11 @@ int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponen
        iResult=-ENOENT;
       }
     } else {
-      HLTError("data buffer %p is empty", this);
-      iResult=-ENODATA;
+      // Matthias 26.07.2007 until now, data had to be present for successful subscription
+      // in order to be consistent with the PubSub framework, this restiction has been
+      // removed
+      //HLTError("data buffer %p is empty", this);
+      //iResult=-ENODATA;
     }
   } else {
     HLTError("invalid parameter");