packagefs: Add more write-locked assertions.
Also fix a memory leak on failure in mount().
This commit is contained in:
@@ -67,16 +67,18 @@ packagefs_mount(fs_volume* fsVolume, const char* device, uint32 flags,
|
||||
Volume* volume = new(std::nothrow) Volume(fsVolume);
|
||||
if (volume == NULL)
|
||||
RETURN_ERROR(B_NO_MEMORY);
|
||||
ObjectDeleter<Volume> volumeDeleter(volume);
|
||||
VolumeWriteLocker volumeWriteLocker(volume);
|
||||
|
||||
// Initialize the fs_volume now already, so it is mostly usable in during
|
||||
// mounting.
|
||||
fsVolume->private_volume = volumeDeleter.Detach();
|
||||
fsVolume->private_volume = volume;
|
||||
fsVolume->ops = &gPackageFSVolumeOps;
|
||||
|
||||
status_t error = volume->Mount(parameters);
|
||||
if (error != B_OK)
|
||||
if (error != B_OK) {
|
||||
delete volume;
|
||||
return error;
|
||||
}
|
||||
|
||||
// set return values
|
||||
*_rootID = volume->RootDirectory()->ID();
|
||||
|
||||
@@ -89,6 +89,7 @@ Directory::AddChild(Node* node)
|
||||
void
|
||||
Directory::RemoveChild(Node* node)
|
||||
{
|
||||
ASSERT_WRITE_LOCKED_RW_LOCK(&fLock);
|
||||
Node* nextNode = fChildList.GetNext(node);
|
||||
|
||||
fChildTable.Remove(node);
|
||||
@@ -114,6 +115,7 @@ Directory::FindChild(const StringKey& name)
|
||||
void
|
||||
Directory::AddDirectoryIterator(DirectoryIterator* iterator)
|
||||
{
|
||||
ASSERT_WRITE_LOCKED_RW_LOCK(&fLock);
|
||||
fIterators.Add(iterator);
|
||||
}
|
||||
|
||||
@@ -121,5 +123,6 @@ Directory::AddDirectoryIterator(DirectoryIterator* iterator)
|
||||
void
|
||||
Directory::RemoveDirectoryIterator(DirectoryIterator* iterator)
|
||||
{
|
||||
ASSERT_WRITE_LOCKED_RW_LOCK(&fLock);
|
||||
fIterators.Remove(iterator);
|
||||
}
|
||||
|
||||
@@ -568,6 +568,7 @@ Volume::IOCtl(Node* node, uint32 operation, void* buffer, size_t size)
|
||||
void
|
||||
Volume::AddNodeListener(NodeListener* listener, Node* node)
|
||||
{
|
||||
ASSERT_WRITE_LOCKED_RW_LOCK(&fLock);
|
||||
ASSERT(!listener->IsListening());
|
||||
|
||||
listener->StartedListening(node);
|
||||
@@ -582,6 +583,7 @@ Volume::AddNodeListener(NodeListener* listener, Node* node)
|
||||
void
|
||||
Volume::RemoveNodeListener(NodeListener* listener)
|
||||
{
|
||||
ASSERT_WRITE_LOCKED_RW_LOCK(&fLock);
|
||||
ASSERT(listener->IsListening());
|
||||
|
||||
Node* node = listener->ListenedNode();
|
||||
@@ -604,6 +606,7 @@ Volume::RemoveNodeListener(NodeListener* listener)
|
||||
void
|
||||
Volume::AddQuery(Query* query)
|
||||
{
|
||||
ASSERT_WRITE_LOCKED_RW_LOCK(&fLock);
|
||||
fQueries.Add(query);
|
||||
}
|
||||
|
||||
@@ -611,6 +614,7 @@ Volume::AddQuery(Query* query)
|
||||
void
|
||||
Volume::RemoveQuery(Query* query)
|
||||
{
|
||||
ASSERT_WRITE_LOCKED_RW_LOCK(&fLock);
|
||||
fQueries.Remove(query);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user