AliHLTComponent: reverting previous changes which were supposed to fix the mentioned bug
minor argument check in external interface and correction in documentation
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;
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) {
AliHLTComponentBlockData bd;
FillBlockData( bd );
bd.fOffset = fOutputBufferFilled;
- bd.fPtr = fpOutputBuffer;
bd.fSize = iBlkSize;
bd.fDataType = dt;
bd.fSpecification = spec;
AliHLTComponentBlockData bd;
FillBlockData( bd );
bd.fOffset = fOutputBufferFilled;
- bd.fPtr = fpOutputBuffer;
bd.fSize = capacity;
bd.fDataType = dt;
bd.fSpecification = spec;
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;
memset(pTgt, 0, iStructSize);
}
}
- memcpy(pTgt, pSrc, copy);
+ memcpy(pTgt, fpInputBlocks[iBlockNo].fPtr, copy);
*pTgt=iStructSize;
iResult=copy;
} else {
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;
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;
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;
}
}
/**
* @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;
};
* 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
{
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;
}