summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/lib/entCache.impl.h17
-rw-r--r--netfs/unittests/testLib.cpp1
2 files changed, 9 insertions, 9 deletions
diff --git a/netfs/lib/entCache.impl.h b/netfs/lib/entCache.impl.h
index 13263af..37aecfd 100644
--- a/netfs/lib/entCache.impl.h
+++ b/netfs/lib/entCache.impl.h
@@ -57,15 +57,19 @@ template<class key_t>
typename EntCache<entry_t>::Resolution
EntCache<entry_t>::getEntry(const key_t & key) const
{
- if (fillTime + 60 > time(nullptr)) {
+ SharedScopeLock(lock) {
+ if (fillTime + 60 > time(nullptr)) {
+ if (auto ent = getEntryNoFill<key_t>(key)) {
+ return ent;
+ }
+ }
+ }
+ ScopeLock(lock) {
+ fillCache();
if (auto ent = getEntryNoFill<key_t>(key)) {
return ent;
}
}
- fillCache();
- if (auto ent = getEntryNoFill<key_t>(key)) {
- return ent;
- }
if (fallback) {
return {fallback, ResolvedAs::Fallback};
}
@@ -77,7 +81,6 @@ template<class key_t>
typename EntCache<entry_t>::entry_ptr
EntCache<entry_t>::getEntryNoFill(const key_t & key) const
{
- SharedLock(lock);
auto & collection = idcache->template get<key_t>();
auto i = collection.find(key);
if (i != collection.end()) {
@@ -106,7 +109,6 @@ template<>
void
EntCache<User>::fillCache() const
{
- Lock(lock);
setpwent();
idcache->clear();
std::array<char, BUFSIZ> buf {};
@@ -124,7 +126,6 @@ template<>
void
EntCache<Group>::fillCache() const
{
- Lock(lock);
setgrent();
std::array<char, BUFSIZ> buf {};
idcache->clear();
diff --git a/netfs/unittests/testLib.cpp b/netfs/unittests/testLib.cpp
index d3ce2fe..ff82040 100644
--- a/netfs/unittests/testLib.cpp
+++ b/netfs/unittests/testLib.cpp
@@ -27,7 +27,6 @@ template<>
void
EntCache<TestEntry>::fillCache() const
{
- Lock(lock);
idcache->insert(std::make_shared<TestEntry>(1, "user1"));
idcache->insert(std::make_shared<TestEntry>(2, "user2"));
idcache->insert(std::make_shared<TestEntry>(3, "user3"));