Skip to content

Commit

Permalink
Merge pull request #15670 from dan131riley/unregister-tfile-context
Browse files Browse the repository at this point in the history
Create a context around TFile::Open() so the context is unregistered …
  • Loading branch information
cmsbuild committed Aug 31, 2016
2 parents dade4dc + 42c803c commit 2c5ce50
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions IOPool/Input/src/InputFile.cc
Expand Up @@ -18,6 +18,13 @@ namespace edm {
InputFile::InputFile(char const* fileName, char const* msg, InputType inputType) :
file_(), fileName_(fileName), reportToken_(0), inputType_(inputType) {

// ROOT's context management implicitly assumes that a file is opened and
// closed on the same thread. To avoid the problem, we declare a local
// TContext object; when it goes out of scope, its destructor unregisters
// the context, guaranteeing the context is unregistered in the same thread
// it was registered in. Fixes issue #15524.
TDirectory::TContext contextEraser;

logFileAction(msg, fileName);
file_ = std::unique_ptr<TFile>(TFile::Open(fileName)); // propagate_const<T> has no reset() function
std::exception_ptr e = edm::threadLocalException::getException();
Expand Down

0 comments on commit 2c5ce50

Please sign in to comment.