Skip to content

Commit

Permalink
Make JobReport::reportReadBranches thread safe
Browse files Browse the repository at this point in the history
CRAB jobs have been failing to parse the job report because of
this race condition.
  • Loading branch information
Dr15Jones committed Mar 28, 2022
1 parent aef6b64 commit 4e35aa7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion FWCore/MessageLogger/interface/JobReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ namespace edm {
std::map<std::string, long long> readBranches_;
std::map<std::string, long long> readBranchesSecFile_;
tbb::concurrent_unordered_map<std::string, AtomicLongLong> readBranchesSecSource_;
bool printedReadBranches_;
std::atomic<bool> printedReadBranches_;
std::vector<InputFile>::size_type lastOpenedPrimaryInputFile_;
edm::propagate_const<std::ostream*> ost_;
};
Expand Down
4 changes: 2 additions & 2 deletions FWCore/MessageLogger/src/JobReport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,9 @@ namespace edm {
}

void JobReport::reportReadBranches() {
if (impl_->printedReadBranches_)
bool expected = false;
if (not impl_->printedReadBranches_.compare_exchange_strong(expected, true))
return;
impl_->printedReadBranches_ = true;
if (impl_->ost_) {
std::ostream& ost = *(impl_->ost_);
ost << "<ReadBranches>\n";
Expand Down

0 comments on commit 4e35aa7

Please sign in to comment.