]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
bugfix AliHLTDataBuffer: correct handling of pointer and offset in block descriptor...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Oct 2007 11:13:34 +0000 (11:13 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Oct 2007 11:13:34 +0000 (11:13 +0000)
AliHLTComponent: reverting previous changes which were supposed to fix the mentioned bug
minor argument check in external interface and correction in documentation

HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTDataBuffer.cxx
HLT/BASE/AliHLTDataTypes.h
HLT/BASE/AliHLTModuleAgent.h
HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx

index 45eb482a6b5f67376e5585602978f645a003b231..8917bda3e5084d4854ad4e2fe9f648504bc5b1af 100644 (file)
@@ -502,9 +502,8 @@ int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int start
     for ( ; (UInt_t)idx<fCurrentEventData.fBlockCnt && iResult==-ENOENT; idx++) {
       if (bObject!=0) {
        if (fpInputBlocks[idx].fPtr==NULL) continue;
-       AliHLTUInt8_t* pSrc=reinterpret_cast<AliHLTUInt8_t*>(fpInputBlocks[idx].fPtr);
-       pSrc+=fpInputBlocks[idx].fOffset;
-       if (*reinterpret_cast<AliHLTUInt32_t*>(pSrc)!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue;
+       AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
+       if (firstWord!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue;
       }
       if (dt == kAliHLTAnyDataType || fpInputBlocks[idx].fDataType == dt) {
        iResult=idx;
@@ -521,12 +520,10 @@ TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
   if (fpInputBlocks!=NULL) {
     if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
       if (fpInputBlocks[idx].fPtr) {
-       AliHLTUInt8_t* pSrc=reinterpret_cast<AliHLTUInt8_t*>(fpInputBlocks[idx].fPtr);
-       pSrc+=fpInputBlocks[idx].fOffset;
-       AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pSrc);
+       AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
        if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) {
          HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
-         AliHLTMessage msg((void*)pSrc, fpInputBlocks[idx].fSize);
+         AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize);
          TClass* objclass=msg.GetClass();
          pObj=msg.ReadObject(objclass);
          if (pObj && objclass) {
@@ -782,7 +779,6 @@ int AliHLTComponent::InsertOutputBlock(void* pBuffer, int iBufferSize, const Ali
       AliHLTComponentBlockData bd;
       FillBlockData( bd );
       bd.fOffset        = fOutputBufferFilled;
-      bd.fPtr           = fpOutputBuffer;
       bd.fSize          = iBlkSize;
       bd.fDataType      = dt;
       bd.fSpecification = spec;
@@ -855,7 +851,6 @@ AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity,
        AliHLTComponentBlockData bd;
        FillBlockData( bd );
        bd.fOffset        = fOutputBufferFilled;
-       bd.fPtr           = fpOutputBuffer;
        bd.fSize          = capacity;
        bd.fDataType      = dt;
        bd.fSpecification = spec;
@@ -1212,8 +1207,7 @@ int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigne
     if (fpInputBlocks!=NULL && iBlockNo<fCurrentEventData.fBlockCnt) {
       AliHLTUInt32_t* pTgt=(AliHLTUInt32_t*)pStruct;
       if (fpInputBlocks[iBlockNo].fPtr && fpInputBlocks[iBlockNo].fSize) {
-       AliHLTUInt8_t* pSrc=((AliHLTUInt8_t*)fpInputBlocks[iBlockNo].fPtr)+fpInputBlocks[iBlockNo].fOffset;
-       AliHLTUInt32_t copy=*((AliHLTUInt32_t*)pSrc);
+       AliHLTUInt32_t copy=*((AliHLTUInt32_t*)fpInputBlocks[iBlockNo].fPtr);
        if (fpInputBlocks[iBlockNo].fSize!=copy) {
          HLTWarning("%s event: missmatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy);
          if (copy>fpInputBlocks[iBlockNo].fSize) copy=fpInputBlocks[iBlockNo].fSize;
@@ -1226,7 +1220,7 @@ int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigne
            memset(pTgt, 0, iStructSize);
          }
        }
-       memcpy(pTgt, pSrc, copy);
+       memcpy(pTgt, fpInputBlocks[iBlockNo].fPtr, copy);
        *pTgt=iStructSize;
        iResult=copy;
       } else {
index 67437a25eec2886915150c3b73a950a7b422ae0d..f85a7609f6082e843008e838477c9c678c992dfd 100644 (file)
@@ -182,8 +182,14 @@ int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponen
            arrayBlockDesc[i].fShmKey.fStructSize=sizeof(AliHLTComponentShmData);
            arrayBlockDesc[i].fShmKey.fShmType=gkAliHLTComponentInvalidShmType;
            arrayBlockDesc[i].fShmKey.fShmID=gkAliHLTComponentInvalidShmID;
+           // This models the behavior of PubSub.
+           // For incoming data blocks, fOffset must be ignored by the
+           // processing component. It is set for bookkeeping in the framework.
+           // fPtr always points to the beginning of the data.
            arrayBlockDesc[i].fOffset=(*segment).fSegmentOffset;
-           arrayBlockDesc[i].fPtr=*fpBuffer;
+           AliHLTUInt8_t* pTgt=*fpBuffer;
+           pTgt+=(*segment).fSegmentOffset;
+           arrayBlockDesc[i].fPtr=reinterpret_cast<void*>(pTgt);
            arrayBlockDesc[i].fSize=(*segment).fSegmentSize;
            arrayBlockDesc[i].fDataType=(*segment).fDataType;
            arrayBlockDesc[i].fSpecification=(*segment).fSpecification;
@@ -296,17 +302,14 @@ int AliHLTDataBuffer::SetSegments(AliHLTUInt8_t* pTgt, AliHLTComponentBlockData*
       if (*fpBuffer==pTgt) {
        AliHLTDataBuffer::AliHLTDataSegment segment;
        for (int i=0; i<iSize; i++) {
-         // the pointer can be either NULL, than only the offset is considered, or a valid
-         // pointer in the range of the buffer
-         // The operator '>' includes the size of the buffer
+         // This function has to model the behavior of PubSub
+         // For output blocks only the fOffset value is used, this must be the offset
+         // relative to the output pointer. fPtr must be either NULL or the output
+         // pointer
          if (arrayBlockData[i].fPtr==NULL ||
-             ((*fpBuffer)<=arrayBlockData[i].fPtr && (*fpBuffer)>arrayBlockData[i].fPtr)) {
-           int ptrOffset=0;
-           if (arrayBlockData[i].fPtr!=NULL) {
-             ptrOffset=(*fpBuffer)-arrayBlockData[i].fPtr;
-           }
-           if (arrayBlockData[i].fOffset+ptrOffset+arrayBlockData[i].fSize<=fpBuffer->fSize) {
-             segment.fSegmentOffset=arrayBlockData[i].fOffset+ptrOffset;
+             arrayBlockData[i].fPtr==*fpBuffer) {
+           if (arrayBlockData[i].fOffset+arrayBlockData[i].fSize<=fpBuffer->fSize) {
+             segment.fSegmentOffset=arrayBlockData[i].fOffset;
              segment.fSegmentSize=arrayBlockData[i].fSize;
              segment.fDataType=arrayBlockData[i].fDataType;
              segment.fSpecification=arrayBlockData[i].fSpecification;
@@ -318,7 +321,9 @@ int AliHLTDataBuffer::SetSegments(AliHLTUInt8_t* pTgt, AliHLTComponentBlockData*
              iResult=-E2BIG;
            }
          } else {
-           HLTError("invalid pointer (%p) in block data specification (buffer %p size %d)", arrayBlockData[i].fPtr, fpBuffer->fPtr, fpBuffer->fSize);
+           HLTError("invalid pointer (%p) in block data specification (buffer %p size %d)."
+                    "please note: for output blocks only the fOffset value is valid and must "
+                    "be relative to the output buffer", arrayBlockData[i].fPtr, fpBuffer->fPtr, fpBuffer->fSize);
            iResult=-ERANGE;
          }
        }
index 776cf032f4d752e6cca4d4f8c2b464997f35dafb..2f68d14f5ee48f6adb422815c8485cd5c7e49c02 100644 (file)
@@ -182,16 +182,31 @@ extern "C" {
 
   /**
    * @struct AliHLTComponentBlockData
-   * Descriptor for data blocks.
+   * This is the decription of data blocks exchanged between components.
+   * \b IMPORTANT: The validity of fPtr and fOffset is different for input and
+   * output blocks:
+   * - input blocks: The \em fPtr member always points to the beginning of the data
+   *                 of size \em fSize. fOffset is ignored and should be in most
+   *                 case 0.
+   * - output blocks: The \em fPtr member is ignored by the framework. \em fOffset
+   *                  must specify the start of the data relative to the output
+   *                  buffer. The data block has size \em fSize.
    */
   struct AliHLTComponentBlockData
   {
+    /* size and version of the struct */
     AliHLTUInt32_t fStructSize;
+    /* shared memory key, ignored by processing components */
     AliHLTComponentShmData fShmKey;
+    /* offset of output data relative to the output buffer */
     AliHLTUInt32_t fOffset;
+    /* start of the data for input data blocks, fOffset to be ignored*/
     void* fPtr;
+    /* size of the data block */
     AliHLTUInt32_t fSize;
+    /* data type of the data block */
     AliHLTComponentDataType fDataType;
+    /* data specification of the data block */
     AliHLTUInt32_t fSpecification;
   };
 
index fb0bb11554d9a65441affb68cb33018a15b7f1fb..d9dda5b6771d14205a9c7cea2a5a497cb7c42306 100644 (file)
@@ -51,7 +51,7 @@ class AliRawReader;
  * can be queried when required.
  *
  * This is usually done during running the AliRoot reconstruction (see AliRoot
- * documentation on <tt> AliSimulation </tt> and <tt> AliReconstruction <tt>).
+ * documentation on <tt> AliSimulation </tt> and <tt> AliReconstruction </tt>).
  * The HLT implemets the @ref AliHLTSimulation and @ref
  * AliHLTReconstructor which hold the HLT steering object. Several flags can
  * be specified as options via the <tt>SetRunHLT</tt> method of
index 8e096074528e322e6d3c14a27b1c079deb62f4ff..7de5185c2f104cbec948a7efe04e7d9d54fdd7db 100644 (file)
@@ -77,9 +77,11 @@ int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, in
 {
   if ( !gComponentHandler_C )
     return ENXIO;
+  if ( !handle ) return EINVAL;
   AliHLTComponent* comp;
   int ret = gComponentHandler_C->CreateComponent( componentType, environ_param, argc, argv, comp );
   *handle = reinterpret_cast<AliHLTComponentHandle>( comp );
+
   return ret;
 }