nfs4: DirectoryCache::GetSnapshot may return NULL

This commit is contained in:
Pawel Dziepak
2013-01-16 10:47:35 +01:00
parent 1c6f502549
commit 65edbee7c8
2 changed files with 15 additions and 7 deletions
@@ -54,7 +54,7 @@ public:
bool created = false);
void RemoveEntry(const char* name);
inline DirectoryCacheSnapshot* GetSnapshot();
inline status_t GetSnapshot(DirectoryCacheSnapshot** snapshot);
inline SinglyLinkedList<NameCacheEntry>& EntriesList();
@@ -113,12 +113,16 @@ DirectoryCache::Valid()
}
inline DirectoryCacheSnapshot*
DirectoryCache::GetSnapshot()
inline status_t
DirectoryCache::GetSnapshot(DirectoryCacheSnapshot** snapshot)
{
ASSERT(snapshot != NULL);
status_t result = B_OK;
if (fDirectoryCache == NULL)
_LoadSnapshot(false);
return fDirectoryCache;
result = _LoadSnapshot(false);
*snapshot = fDirectoryCache;
return result;
}
@@ -324,8 +324,12 @@ Inode::ReadDir(void* _buffer, uint32 size, uint32* _count,
return result;
}
DirectoryCacheSnapshot* snapshot = cache->GetSnapshot();
ASSERT(snapshot != NULL);
DirectoryCacheSnapshot* snapshot;
result = cache->GetSnapshot(&snapshot);
if (result != B_OK) {
cache->Unlock();
return result;
}
cookie->fSnapshot = new DirectoryCacheSnapshot(*snapshot);
cache->Unlock();