Skip to content

Commit

Permalink
ALIROOT-5642 fixing HLT re-initialization
Browse files Browse the repository at this point in the history
After a reconstruction run the (global) HLT component handler is
destroyed but still referenced by the various module agents. During
subsequent runs a new component handler can't be registered with the
agents which leaves HLT system in error state (component registration
fails).

Now the component handler is properly deregistered from the agents
on destruction.
  • Loading branch information
tbreitne authored and hristov committed Oct 2, 2014
1 parent f53099d commit 96f1d3c
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 19 deletions.
13 changes: 13 additions & 0 deletions HLT/BASE/AliHLTComponentHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ AliHLTComponentHandler::AliHLTComponentHandler(AliHLTAnalysisEnvironment* pEnv)
AliHLTComponentHandler::~AliHLTComponentHandler()
{
// destructor
DeactivateAgents();
DeleteOwnedComponents();
UnloadLibraries();
if (fRunType) delete [] fRunType;
Expand Down Expand Up @@ -639,6 +640,18 @@ int AliHLTComponentHandler::ActivateAgents(const char* library, const char* blac
return agents.size();
}

int AliHLTComponentHandler::DeactivateAgents() const {
int ret=0;
for (AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent();
pAgent!=NULL; pAgent=AliHLTModuleAgent::GetNextAgent()) {
if(pAgent->GetComponentHandler()==this){
pAgent->ActivateComponentHandler(NULL);
++ret;
}
}
return ret;
}

int AliHLTComponentHandler::DeleteOwnedComponents()
{
// delete all component samples owned by the handler
Expand Down
6 changes: 6 additions & 0 deletions HLT/BASE/AliHLTComponentHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ class AliHLTComponentHandler : public AliHLTLogging {
*/
int ActivateAgents(const char* library=NULL, const char* blackList=NULL);

/**
* Loop through all the agents and deregister this instance if neccessary.
*/

int DeactivateAgents() const;

public:
/**
* Compound descriptor for component libraries - must be public
Expand Down
7 changes: 7 additions & 0 deletions HLT/BASE/AliHLTModuleAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging {
return GetReconstructionChains(NULL,runloader);
}

/**
* Get current component handler
*/
AliHLTComponentHandler* GetComponentHandler() const {
return fpComponentHandler;
}

protected:

private:
Expand Down
2 changes: 1 addition & 1 deletion HLT/BASE/AliHLTPluginBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ AliHLTPluginBase::~AliHLTPluginBase()
// see header file for class documentation
if (--fNofInstances<=0) {
delete fpSystem;
fpSystem=NULL;

// 2010-04-07 not sure whether this is the best place for
// the global cleanup of memory pages. In case of AliReconstruction
Expand All @@ -53,7 +54,6 @@ AliHLTPluginBase::~AliHLTPluginBase()
// when we arrive at this point.
AliHLTDataBuffer::AliHLTRawPage::GlobalClean();
}
fpSystem=NULL;
}

void AliHLTPluginBase::InitInstance()
Expand Down
1 change: 0 additions & 1 deletion HLT/BASE/AliHLTSystem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ AliHLTSystem::AliHLTSystem(AliHLTComponentLogSeverity loglevel, const char* name
// AliHLTSystem is used in multiple instances for the kChain HLTOUT handler
//HLTWarning("multiple instances of AliHLTSystem, you should not use more than one at a time");
}

SetGlobalLoggingLevel(loglevel);
SetFrameworkLog(loglevel);
if (fpComponentHandler) {
Expand Down
37 changes: 22 additions & 15 deletions HLT/MUON/OfflineInterface/AliHLTMUONAgent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
// The single global instance of the dimuon HLT agent.
AliHLTMUONAgent AliHLTMUONAgent::fgkInstance;

AliHLTOUTHandlerChain AliHLTMUONAgent::fgkESDMakerChain("libAliHLTMUON.so chains=dHLT-make-esd");
AliHLTOUTHandlerChain AliHLTMUONAgent::fgkRootifyDumpChain("libAliHLTMUON.so chains=dHLT-rootify-and-dump");
AliHLTOUTHandlerIgnore AliHLTMUONAgent::fgkDataIgnoreHandler;
Int_t AliHLTMUONAgent::fgMuonModuleLoaded = 0;
bool AliHLTMUONAgent::fgRunRootifyChain = false;
Expand Down Expand Up @@ -90,7 +88,9 @@ bool AliHLTMUONAgent::IsMuonModuleLoaded()
}


AliHLTMUONAgent::AliHLTMUONAgent() : AliHLTModuleAgent("MUON")
AliHLTMUONAgent::AliHLTMUONAgent() : AliHLTModuleAgent("MUON"),
fgkESDMakerChain(NULL),
fgkRootifyDumpChain(NULL)
{
///
/// Default constructor.
Expand Down Expand Up @@ -581,7 +581,10 @@ AliHLTOUTHandler* AliHLTMUONAgent::GetOutputHandler(
dt == AliHLTMUONConstants::TracksBlockDataType()
)
{
return &fgkESDMakerChain;
if(fgkESDMakerChain==NULL){
fgkESDMakerChain=new AliHLTOUTHandlerChain("libAliHLTMUON.so chains=dHLT-make-esd");
}
return fgkESDMakerChain;
}

if (dt == AliHLTMUONConstants::TriggerRecordsBlockDataType() or
Expand All @@ -598,7 +601,10 @@ AliHLTOUTHandler* AliHLTMUONAgent::GetOutputHandler(
{
if (fgRunRootifyChain)
{
return &fgkRootifyDumpChain;
if(fgkRootifyDumpChain==NULL){
fgkRootifyDumpChain=new AliHLTOUTHandlerChain("libAliHLTMUON.so chains=dHLT-rootify-and-dump");
}
return fgkRootifyDumpChain;
}
else
{
Expand All @@ -617,18 +623,19 @@ AliHLTOUTHandler* AliHLTMUONAgent::GetOutputHandler(

int AliHLTMUONAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
{
/// Deletes the HLTOUT handlers. In this case since the handlers are
/// allocated statically, we just check that the right pointer was
/// given and exit.

HLTDebug("Trying to delete HLTOUT handler: %p", pInstance);

if (pInstance != &fgkESDMakerChain or pInstance != &fgkRootifyDumpChain
or pInstance != &fgkDataIgnoreHandler
)
{
return -EINVAL;
if (pInstance==NULL) return -EINVAL;

if (pInstance==fgkESDMakerChain) {
delete fgkESDMakerChain;
fgkESDMakerChain=NULL;
}


if (pInstance==fgkRootifyDumpChain) {
delete fgkRootifyDumpChain;
fgkRootifyDumpChain=NULL;
}

return 0;
}
7 changes: 5 additions & 2 deletions HLT/MUON/OfflineInterface/AliHLTMUONAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ class AliHLTMUONAgent : public AliHLTModuleAgent
static void RunRootifyChain(bool value) { fgRunRootifyChain = value; }

private:
AliHLTMUONAgent(const AliHLTMUONAgent&);
AliHLTMUONAgent& operator=(const AliHLTMUONAgent&);

// The following instance is used for automatic agent and component registration.
static AliHLTMUONAgent fgkInstance; ///< The single global instance of the dimuon HLT agent.

static AliHLTOUTHandlerChain fgkESDMakerChain; ///< Chain handler for converting dHLT raw data to ESD format.
static AliHLTOUTHandlerChain fgkRootifyDumpChain; ///< Chain handler for converting dHLT raw data to ROOT objects and dumping to file.
AliHLTOUTHandlerChain* fgkESDMakerChain; ///< Chain handler for converting dHLT raw data to ESD format.
AliHLTOUTHandlerChain* fgkRootifyDumpChain; ///< Chain handler for converting dHLT raw data to ROOT objects and dumping to file.
static AliHLTOUTHandlerIgnore fgkDataIgnoreHandler; ///< HLTOUT handler for ignoring data blocks.

static Int_t fgMuonModuleLoaded; ///< Cached flag for indicating if the MUON module was loaded for a simulation.
Expand Down

0 comments on commit 96f1d3c

Please sign in to comment.