From d4a1859798586e682ccd80ae726c27bd3096bbff Mon Sep 17 00:00:00 2001 From: richterm Date: Mon, 7 Jul 2008 10:37:55 +0000 Subject: [PATCH] bugfixes, code cleanup and docu - AliHLTDataBuffer: returns number of segments including the forwarded segments - AliHLTConfiguration: comparision operators - AliHLTOUT: subcollections now correctly added and reset - AliHLTSystem: typo corrupted execution of HLTOUT propriatary handlers - AliHLTSystem and AliHLTComponentHandler: suppress general info messages for additional instances - AliHLTOUTHandler: status flags - AliHLTOUT: typo - AliHLTConfigurationHandler: no warnings for duplicate configurations of identical properties --- HLT/BASE/AliHLTComponentHandler.cxx | 10 ++-- HLT/BASE/AliHLTConfiguration.h | 11 +++++ HLT/BASE/AliHLTConfigurationHandler.cxx | 7 ++- HLT/BASE/AliHLTDataBuffer.cxx | 66 ++++++++++++++++--------- HLT/BASE/AliHLTDataBuffer.h | 10 +++- HLT/BASE/AliHLTModuleAgent.h | 8 +-- HLT/BASE/AliHLTOUT.cxx | 4 +- HLT/BASE/AliHLTOUT.h | 2 +- HLT/BASE/AliHLTOUTHandler.cxx | 8 +++ HLT/BASE/AliHLTOUTHandler.h | 36 ++++++++++++++ HLT/BASE/AliHLTOUTHomerBuffer.h | 12 ++++- HLT/BASE/AliHLTSystem.cxx | 17 ++++++- 12 files changed, 151 insertions(+), 40 deletions(-) diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx index 8225108d494..55d9ee6d051 100644 --- a/HLT/BASE/AliHLTComponentHandler.cxx +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -336,6 +336,7 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA AliHLTComponent::SetGlobalComponentHandler(this); AliHLTLibHandle hLib; + AliHLTLibHandle* phSearch=FindLibrary(libraryPath); const char* loadtype=""; #ifdef HAVE_DLFCN_H // use interface to the dynamic linking loader @@ -358,9 +359,8 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA // check if the library was already loaded, as Load returns // 'failure' if the library was already loaded /*try*/ { - AliHLTLibHandle* pLib=FindLibrary(libraryPath); - if (pLib) { - int* pRootHandle=reinterpret_cast(pLib->fHandle); + if (phSearch) { + int* pRootHandle=reinterpret_cast(phSearch->fHandle); (*pRootHandle)++; HLTDebug("instance %d of library %s loaded", (*pRootHandle), libraryPath); hLib.fHandle=pRootHandle; @@ -385,8 +385,9 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA // create TString object to store library path and use pointer as handle hLib.fName=new TString(libraryPath); hLib.fMode=fLibraryMode; - HLTImportant("library %s loaded (%s%s)", libraryPath, hLib.fMode==kStatic?"persistent, ":"", loadtype); fLibraryList.insert(fLibraryList.begin(), hLib); + if (!phSearch) { + HLTImportant("library %s loaded (%s%s)", libraryPath, hLib.fMode==kStatic?"persistent, ":"", loadtype); typedef void (*CompileInfo)( char*& date, char*& time); CompileInfo fctInfo=(CompileInfo)FindSymbol(libraryPath, "CompileInfo"); if (fctInfo) { @@ -399,6 +400,7 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA } else { HLTImportant("no build info available (possible AliRoot embedded build)"); } + } // static registration of components when library is loaded iResult=RegisterScheduledComponents(); diff --git a/HLT/BASE/AliHLTConfiguration.h b/HLT/BASE/AliHLTConfiguration.h index 6bf284b48d2..787d9d32767 100644 --- a/HLT/BASE/AliHLTConfiguration.h +++ b/HLT/BASE/AliHLTConfiguration.h @@ -185,6 +185,17 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging { * @return size in byte or -1 if not specified */ int GetOutputBufferSize() const {return fBufferSize;} + + /** + * Two configurations are considered equal if all properties match + */ + bool operator==(const AliHLTConfiguration& c) const { + return (fID==c.fID) && (fComponent==c.fComponent) && (fStringSources==c.fStringSources) && (fArguments==c.fArguments); + } + bool operator!=(const AliHLTConfiguration& c) const { + return !(*this==c); + } + protected: diff --git a/HLT/BASE/AliHLTConfigurationHandler.cxx b/HLT/BASE/AliHLTConfigurationHandler.cxx index 7d7a2410193..023389caca8 100644 --- a/HLT/BASE/AliHLTConfigurationHandler.cxx +++ b/HLT/BASE/AliHLTConfigurationHandler.cxx @@ -93,7 +93,8 @@ int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf // see header file for function documentation int iResult=0; if (pConf) { - if (FindConfiguration(pConf->GetName()) == NULL) { + AliHLTConfiguration* pExisting=NULL; + if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) { AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf); fgListConfigurations.Add(pClone); HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf); @@ -108,8 +109,10 @@ int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf lnk=lnk->Next(); } } else { + if ((*pExisting)!=(*pConf)) { iResult=-EEXIST; - HLTWarning("configuration \"%s\" already registered", pConf->GetName()); + HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName()); + } } } else { iResult=-EINVAL; diff --git a/HLT/BASE/AliHLTDataBuffer.cxx b/HLT/BASE/AliHLTDataBuffer.cxx index a31d16dccae..bedcd9b2461 100644 --- a/HLT/BASE/AliHLTDataBuffer.cxx +++ b/HLT/BASE/AliHLTDataBuffer.cxx @@ -220,7 +220,11 @@ int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponen 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 { @@ -255,6 +259,39 @@ int AliHLTDataBuffer::Release(AliHLTComponentBlockData* pBlockDesc, } 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(); @@ -281,27 +318,8 @@ int AliHLTDataBuffer::Release(AliHLTComponentBlockData* pBlockDesc, 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; @@ -389,14 +407,14 @@ int AliHLTDataBuffer::SetSegments(AliHLTUInt8_t* pTgt, AliHLTComponentBlockData* 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; } @@ -660,7 +678,7 @@ int AliHLTDataBuffer::CleanupConsumerList() 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(); diff --git a/HLT/BASE/AliHLTDataBuffer.h b/HLT/BASE/AliHLTDataBuffer.h index e7823c4c1d6..618a27a3cbd 100644 --- a/HLT/BASE/AliHLTDataBuffer.h +++ b/HLT/BASE/AliHLTDataBuffer.h @@ -125,6 +125,12 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging int Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTComponent* pConsumer, const AliHLTTask* pOwnerTask); + /** + * Release a forwarded data block. + */ + int ReleaseForwardedBlock(AliHLTComponentBlockData* pBlockDesc, + const AliHLTTask* pOwnerTask); + /** * Register an input data block for forwarding. * Consumer of this data buffer subscribe to forwarded data blocks in te same way. @@ -171,7 +177,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging //int GetTotalSize(); /** - * Get the number of segments + * Get the number of segments including the forwarded data blocks. * @return number of segments */ int GetNofSegments(); @@ -203,7 +209,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * search only in fConsumer list if 0 * @return 1 if found, 0 if not */ - int FindConsumer(AliHLTComponent* pConsumer, int bAllLists=1); + int FindConsumer(const AliHLTComponent* pConsumer, int bAllLists=1); /** * Public method to reset the buffer. diff --git a/HLT/BASE/AliHLTModuleAgent.h b/HLT/BASE/AliHLTModuleAgent.h index 1a430ae269e..0b74fca461b 100644 --- a/HLT/BASE/AliHLTModuleAgent.h +++ b/HLT/BASE/AliHLTModuleAgent.h @@ -330,10 +330,10 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { /** * Delete an HLTOUT handler. - * Even if the agent returned the handler several times, this is the - * final cleanup. The framwork makes sure that the handler is not - * used any further outside the agent. The default implementation just - * deltetes the object. + * This is the final cleanup. The framwork makes sure that the handler is + * not used any further outside the agent. Even if the agent returned the + * same handler several times, cleanup is invoked only once. The default + * implementation just deletes the object. * @param pInstance pointer to handler */ virtual int DeleteOutputHandler(AliHLTOUTHandler* pInstance); diff --git a/HLT/BASE/AliHLTOUT.cxx b/HLT/BASE/AliHLTOUT.cxx index beb8b8c35f5..79a30531f92 100644 --- a/HLT/BASE/AliHLTOUT.cxx +++ b/HLT/BASE/AliHLTOUT.cxx @@ -722,6 +722,7 @@ int AliHLTOUT::AddSubCollection(AliHLTOUT* pCollection) int iResult=0; if (!pCollection) return 0; + SetStatusFlag(kCollecting); int index=-1; for (index=pCollection->SelectFirstDataBlock(); index>=0; @@ -736,6 +737,7 @@ int AliHLTOUT::AddSubCollection(AliHLTOUT* pCollection) if (iResult>0) { pCollection->SetStatusFlag(kIsSubCollection); } + ClearStatusFlag(kCollecting); return iResult; } @@ -765,7 +767,7 @@ int AliHLTOUT::Reset() AliHLTOUTPVector subCollections; AliHLTOUTBlockDescriptorVector::iterator block=fBlockDescList.begin(); while (block!=fBlockDescList.end()) { - if ((*block)==this) { + if (!((*block)==this)) { AliHLTOUTPVector::iterator collection=subCollections.begin(); for (; collection!=subCollections.end(); collection++) if((*block)==*collection) break; diff --git a/HLT/BASE/AliHLTOUT.h b/HLT/BASE/AliHLTOUT.h index 978a886c6e5..820dcf25667 100644 --- a/HLT/BASE/AliHLTOUT.h +++ b/HLT/BASE/AliHLTOUT.h @@ -194,7 +194,7 @@ class AliHLTOUT { bool IsSelected() const {return fSelected;} void Select(bool selected=true) {fSelected=selected;} - bool IsProcessed() const {return fSelected;} + bool IsProcessed() const {return fProcessed;} void MarkProcessed() {fProcessed=true;} /** diff --git a/HLT/BASE/AliHLTOUTHandler.cxx b/HLT/BASE/AliHLTOUTHandler.cxx index 9831003f7a0..cbec6ef8dad 100644 --- a/HLT/BASE/AliHLTOUTHandler.cxx +++ b/HLT/BASE/AliHLTOUTHandler.cxx @@ -28,6 +28,8 @@ ClassImp(AliHLTOUTHandler) AliHLTOUTHandler::AliHLTOUTHandler() + : + fState(kHandlerOK) { // see header file for class documentation // or @@ -53,3 +55,9 @@ int AliHLTOUTHandler::ReleaseProcessedData(const AliHLTUInt8_t* /*pData*/, int / // see header file for class documentation return 0; } + +int AliHLTOUTHandler::FinishEvent() +{ + // see header file for class documentation + return 0; +} diff --git a/HLT/BASE/AliHLTOUTHandler.h b/HLT/BASE/AliHLTOUTHandler.h index 88fead8b452..b401f835404 100644 --- a/HLT/BASE/AliHLTOUTHandler.h +++ b/HLT/BASE/AliHLTOUTHandler.h @@ -80,7 +80,40 @@ class AliHLTOUTHandler : public AliHLTLogging { */ virtual int ReleaseProcessedData(const AliHLTUInt8_t* pData, int size); + /** + * Cleanup the current event processing. + */ + virtual int FinishEvent(); + + enum { + kHandlerUndefined = 0, + kHandlerOK = 0, + kHandlerError = 0x1000 + }; + + /** + * Check state flag of the handler. + * @return true if flag matches + */ + bool CheckStatus(unsigned int flag) { + return (fState&flag)!=0; + } + + /** + * Reset the state flag. + */ + void ResetState() { + fState=kHandlerOK; + } + protected: + void SetStatusFlag(unsigned int flag) { + fState|=flag; + } + + void ClearStatusFlag(unsigned int flag) { + fState&=~flag; + } private: /** copy constructor prohibited */ @@ -88,6 +121,9 @@ class AliHLTOUTHandler : public AliHLTLogging { /** assignment operator prohibited */ AliHLTOUTHandler& operator=(const AliHLTOUTHandler&); + /** internal state of the handler */ + int fState; //!transient + ClassDef(AliHLTOUTHandler, 0) }; #endif diff --git a/HLT/BASE/AliHLTOUTHomerBuffer.h b/HLT/BASE/AliHLTOUTHomerBuffer.h index 4f062059d6d..c23aef3019d 100644 --- a/HLT/BASE/AliHLTOUTHomerBuffer.h +++ b/HLT/BASE/AliHLTOUTHomerBuffer.h @@ -5,7 +5,7 @@ #define ALIHLTOUTHOMERBUFFER_H //* This file is property of and copyright by the ALICE HLT Project * //* ALICE Experiment at CERN, All rights reserved. * -//* See cxx source for full Copyright notice */ +//* See cxx source for full Copyright notice * /** @file AliHLTOUTHomerBuffer.h @author Matthias Richter @@ -23,6 +23,16 @@ class AliHLTHOMERLibManager; /** * @class AliHLTOUTHomerBuffer * Handler of HLTOUT data for buffer input. + * + * The class supports the AliHLTOUT interface in order to access the + * individual data blocks of a HOMER data collection. An AliHOMERReader + * is created to interpret the data. The class can serve as base for + * other HLTOUT implementations supporting different kinds of input like + * the AliHLTOUTHomerCollection and its childs AliHLTOUTRawReader and + * AliHLTOUTDigitReader. + * + * @note The buffer is expected to contain the HOMER data block only, no + * CDH and HLT headers. */ class AliHLTOUTHomerBuffer : public AliHLTOUT, public AliHLTLogging { public: diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx index 05dbf478862..a3c1a1d3764 100644 --- a/HLT/BASE/AliHLTSystem.cxx +++ b/HLT/BASE/AliHLTSystem.cxx @@ -97,7 +97,9 @@ AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel) env.fLoggingFunc=NULL; fpComponentHandler->SetEnvironment(&env); InitAliLogFunc(fpComponentHandler); + if (fgNofInstances==1) { fpComponentHandler->AnnounceVersion(); + } } else { HLTFatal("can not create Component Handler"); } @@ -768,6 +770,9 @@ int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd) // by the framework AliESDEvent* pMasterESD=NULL; pMasterESD=esd; + + AliHLTComponentDataTypeList esdBlocks; + for (iResult=pHLTOUT->SelectFirstDataBlock(); iResult>=0; iResult=pHLTOUT->SelectNextDataBlock()) { @@ -789,6 +794,15 @@ int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd) // schedule for later processing pHLTOUT->InsertHandler(*pEsdHandlers, pHLTOUT->GetDataBlockHandlerDesc()); } else { + AliHLTComponentDataTypeList::iterator element=esdBlocks.begin(); + for (; element!=esdBlocks.end(); element++) { + if (*element==dt) { + HLTWarning("multiple ESDs of identical data type %s, please add appropriate handler to merge ESDs", AliHLTComponent::DataType2Text(dt).c_str()); + break; + } + } + if (element==esdBlocks.end()) esdBlocks.push_back(dt); + // write directly const AliHLTUInt8_t* pBuffer=NULL; AliHLTUInt32_t size=0; @@ -868,7 +882,7 @@ int AliHLTSystem::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd) } // process all kProprietary data blocks - for (handler=pEsdHandlers->begin(); handler!=pEsdHandlers->end() && iResult>=0; handler++) { + for (handler=pProprietaryHandlers->begin(); handler!=pProprietaryHandlers->end() && iResult>=0; handler++) { AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*handler)); AliHLTOUTHandler* pHandler=*handler; const AliHLTUInt8_t* pBuffer=NULL; @@ -909,6 +923,7 @@ int AliHLTSystem::ProcessHLTOUTkChain(AliHLTOUT* pHLTOUT) // process all defined chain handlers AliHLTOUT::AliHLTOUTHandlerListEntryVector::iterator chainHandler; for (chainHandler=pChainHandlers->begin(); chainHandler!=pChainHandlers->end() && iResult>=0; chainHandler++) { + if (chainHandler->IsEmpty()) continue; AliHLTOUT::AliHLTOUTSelectionGuard g(pHLTOUT, &(*chainHandler)); AliHLTOUTHandler* pHandler=*chainHandler; const AliHLTUInt8_t* pBuffer=NULL; -- 2.43.0