Skip to content

Commit 60b27af

Browse files
committed
[ntuple] Restrict the scope of descriptor guard in ntuple_storage.
Also update the outdated comment about GetNEntries()
1 parent d02a434 commit 60b27af

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tree/ntuple/inc/ROOT/RPageStorage.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ public:
761761
/// The underlying `std::shared_mutex`, however, is neither read nor write recursive:
762762
/// within one thread, only one lock (shared or exclusive) must be acquired at the same time. This requires special
763763
/// care in sections protected by `GetSharedDescriptorGuard()` and `GetExclDescriptorGuard()` especially to avoid
764-
/// that the locks are acquired indirectly (e.g. by a call to `GetNEntries()`). As a general guideline, no other
764+
/// that the locks are acquired indirectly. As a general guideline, no other
765765
/// method of the page source should be called (directly or indirectly) in a guarded section.
766766
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
767767
{

tree/ntuple/test/ntuple_storage.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,10 @@ TEST(RPageSourceFile, OpenDifferentAnchor)
11641164
auto source = std::make_unique<RPageSourceFile>("ntpl1", fileGuard.GetPath(), RNTupleReadOptions());
11651165
source->Attach();
11661166
EXPECT_EQ(source->GetNEntries(), 100);
1167-
auto desc = source->GetSharedDescriptorGuard();
1168-
EXPECT_NE(desc->FindFieldId("f"), ROOT::kInvalidDescriptorId);
1167+
{
1168+
auto desc = source->GetSharedDescriptorGuard();
1169+
EXPECT_NE(desc->FindFieldId("f"), ROOT::kInvalidDescriptorId);
1170+
}
11691171

11701172
auto anchor2 = file->Get<ROOT::RNTuple>("ntpl2");
11711173
ASSERT_NE(anchor2, nullptr);

0 commit comments

Comments
 (0)