AliHLTLogging AliHLTDataBuffer::fgLogging;
const Int_t AliHLTDataBuffer::fgkSafetyPatternSize=16;
const char AliHLTDataBuffer::fgkSafetyPattern[]={0x28, 0x63, 0x29, 0x4d, 0x52, 0x49, 0x43, 0x48, 0x54, 0x45, 0x52, 0x20, 0x32, 0x30, 0x30, 0x37};
+AliHLTUInt32_t AliHLTDataBuffer::fgEventCount=0;
AliHLTDataBuffer::~AliHLTDataBuffer()
{
iResult=-EBADF;
}
} else {
- HLTError("component %p is not a data consumer of data buffer %s", pConsumer, this);
+ if (!FindConsumer(pConsumer)) {
+ HLTError("component %p is not a data consumer of data buffer %p", pConsumer, this);
+ } else {
+ HLTError("component %p is a valid data consumer of data buffer %p, but did not release it's buffer subscription", pConsumer, this);
+ }
iResult=-ENOENT;
}
} else {
}
if (GetNofPendingConsumers()==0 && fForwardedSegments.size()>0) {
// last consumer, release forwarded segments
+ ReleaseForwardedBlock(pBlockDesc, pOwnerTask);
+ }
+ pBlockDesc->fOffset=0;
+ pBlockDesc->fPtr=NULL;
+ pBlockDesc->fSize=0;
+ if (pDesc->GetNofActiveSegments()==0) {
+ if ((iResult=ChangeConsumerState(pDesc, fActiveConsumers, fReleasedConsumers))>=0) {
+ if (GetNofActiveConsumers()==0 && GetNofPendingConsumers()==0) {
+ // this is the last consumer, reset the consumer list and release the raw buffer
+ ResetDataBuffer();
+ }
+ } else {
+ HLTError("can not deactivate consumer %p for data buffer %p", pConsumer, this);
+ iResult=-EACCES;
+ }
+ }
+ } else {
+ HLTWarning("component %p has currently not subscribed to the data buffer %p", pConsumer, this);
+ iResult=-ENOENT;
+ }
+ } else {
+ HLTError("inavalid parameter: pBlockDesc=%p pConsumer=%p", pBlockDesc, pConsumer);
+ iResult=-EINVAL;
+ }
+ return iResult;
+}
+
+int AliHLTDataBuffer::ReleaseForwardedBlock(AliHLTComponentBlockData* pBlockDesc,
+ const AliHLTTask* pOwnerTask)
+{
+ // see header file for function documentation
+ int iResult=0;
+ if (pBlockDesc && pOwnerTask) {
assert(fForwardedSegments.size()==fForwardedSegmentSources.size());
AliHLTDataSegmentList::iterator segment=fForwardedSegments.begin();
AliHLTTaskPList::iterator src=fForwardedSegmentSources.begin();
break;
}
}
- }
- pBlockDesc->fOffset=0;
- pBlockDesc->fPtr=NULL;
- pBlockDesc->fSize=0;
- if (pDesc->GetNofActiveSegments()==0) {
- if ((iResult=ChangeConsumerState(pDesc, fActiveConsumers, fReleasedConsumers))>=0) {
- if (GetNofActiveConsumers()==0 && GetNofPendingConsumers()==0) {
- // this is the last consumer, reset the consumer list and release the raw buffer
- ResetDataBuffer();
- }
- } else {
- HLTError("can not deactivate consumer %p for data buffer %p", pConsumer, this);
- iResult=-EACCES;
- }
- }
- } else {
- HLTWarning("component %p has currently not subscribed to the data buffer %p", pConsumer, this);
- iResult=-ENOENT;
- }
} else {
- HLTError("inavalid parameter: pBlockDesc=%p pConsumer=%p", pBlockDesc, pConsumer);
+ HLTError("inavalid parameter: pBlockDesc=%p pOwnerTask=%p", pBlockDesc, pOwnerTask);
iResult=-EINVAL;
}
return iResult;
if (arrayBlockData[i].fPtr==NULL ||
arrayBlockData[i].fPtr==*fpBuffer) {
arrayBlockData[i].fPtr=*fpBuffer;
- if (arrayBlockData[i].fOffset+arrayBlockData[i].fSize<=fpBuffer->GetUsedSize()) {
+ if ((arrayBlockData[i].fOffset+arrayBlockData[i].fSize<=fpBuffer->GetUsedSize()) ||
+ ((arrayBlockData[i].fOffset==~(AliHLTUInt32_t)0) && arrayBlockData[i].fSize==0)) {
segment.fSegmentOffset=arrayBlockData[i].fOffset;
segment.fPtr=(AliHLTUInt8_t*)arrayBlockData[i].fPtr;
segment.fSegmentSize=arrayBlockData[i].fSize;
int AliHLTDataBuffer::IsEmpty()
{
// see header file for function documentation
- int iResult=fpBuffer==NULL || GetNofSegments()==0;
+ int iResult=(fpBuffer==NULL && fForwardedSegments.size()==0) || GetNofSegments()==0;
return iResult;
}
int AliHLTDataBuffer::GetNofSegments()
{
// see header file for function documentation
- int iResult=fSegments.size();
+ int iResult=fSegments.size() + fForwardedSegments.size();
return iResult;
}
return iResult;
}
+int AliHLTDataBuffer::PrintStatistics()
+{
+ // see header file for function documentation
+ int iResult=0;
+ int iFree=0;
+ int iActive=0;
+ AliHLTRawBufferPList::iterator buffer;;
+ for (buffer=fgFreeBuffers.begin(); buffer!=fgFreeBuffers.end(); buffer++) {
+ iFree+=(*buffer)->GetTotalSize();
+ }
+ for (buffer=fgActiveBuffers.begin(); buffer!=fgActiveBuffers.end(); buffer++) {
+ iActive+=(*buffer)->GetTotalSize();
+ }
+ fgLogging.Logging(kHLTLogInfo, "AliHLTDataBuffer::PrintStatistics", "data buffer handling", "Total memory allocation: %d byte; %d free buffers (%d byte) - %d active buffers (%d byte) ", iFree+iActive, fgFreeBuffers.size(), iFree, fgActiveBuffers.size(), iActive);
+ return iResult;
+}
+
AliHLTConsumerDescriptor* AliHLTDataBuffer::FindConsumer(const AliHLTComponent* pConsumer, AliHLTConsumerDescriptorPList &list) const
{
// see header file for function documentation
desc=fActiveConsumers.begin();
while (desc!=fActiveConsumers.end()) {
AliHLTConsumerDescriptor* pDesc=*desc;
- HLTWarning("consumer %p was not released", pDesc);
+ HLTWarning("consumer %p (%s) was not released", pDesc, pDesc->GetComponent()?pDesc->GetComponent()->GetComponentID():"### invalid component ###");
fActiveConsumers.erase(desc);
desc=fActiveConsumers.begin();
fConsumers.push_back(pDesc);
return iResult;
}
-int AliHLTDataBuffer::FindConsumer(AliHLTComponent* pConsumer, int bAllLists)
+int AliHLTDataBuffer::FindConsumer(const AliHLTComponent* pConsumer, int bAllLists)
{
// see header file for function documentation
AliHLTConsumerDescriptorPList::iterator desc=fConsumers.begin();
:
fSize(0),
fTotalSize(size),
- fPtr(static_cast<AliHLTUInt8_t*>(malloc(size)))
+ fPtr(static_cast<AliHLTUInt8_t*>(malloc(size))),
+ fLastEventCount(0)
{
// see header file for class documentation
// or
// see header file for function documentation
if (size>0 && fTotalSize>=size) {
fSize=size;
+ fLastEventCount=AliHLTDataBuffer::fgEventCount;
return fPtr;
}
return NULL;
int AliHLTDataBuffer::AliHLTRawBuffer::CheckSize(AliHLTUInt32_t size) const
{
// see header file for function documentation
- return fTotalSize>=size && ((fTotalSize-size)<fgMargin);
+ if (fTotalSize<size) return 0;
+ unsigned adjust=0;
+ if (fLastEventCount+1<AliHLTDataBuffer::fgEventCount) {
+ adjust=AliHLTDataBuffer::fgEventCount-fLastEventCount;
+ }
+ return (adjust>2) || ((fTotalSize-size)<(fgMargin<<adjust));
}
int AliHLTDataBuffer::AliHLTRawBuffer::Reset()