From 88e38c178a96634d52920e2de8bb3cbd49869f93 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 16 Dec 2010 14:29:37 +0000 Subject: [PATCH] Replace uses of obsolescent BReference[able] API. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39870 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/Notifications.h | 2 +- headers/private/kernel/thread_types.h | 2 +- .../netfs/client/ExtendedServerInfo.cpp | 6 +- .../netfs/client/QueryIterator.cpp | 9 ++- .../file_systems/netfs/client/QueryIterator.h | 3 + .../netfs/client/QueryManager.cpp | 8 +-- .../netfs/client/ServerConnection.cpp | 8 +-- .../netfs/client/ServerConnectionProvider.cpp | 12 ++-- .../netfs/client/ServerManager.cpp | 36 ++++++------ .../netfs/client/ServerVolume.cpp | 12 ++-- .../file_systems/netfs/client/ShareNode.cpp | 6 +- .../file_systems/netfs/client/ShareVolume.cpp | 24 ++++---- .../netfs/client/VirtualVolume.cpp | 4 +- .../file_systems/netfs/client/VolumeEvent.cpp | 2 +- .../netfs/client/VolumeManager.cpp | 12 ++-- .../netfs/headers/shared/FSObject.h | 3 + .../netfs/server/ClientConnection.cpp | 16 ++--- .../netfs/server/ClientVolume.cpp | 10 ++-- .../file_systems/netfs/server/NetFSServer.cpp | 24 ++++---- .../file_systems/netfs/server/NodeHandle.cpp | 2 +- .../netfs/server/NodeHandleMap.cpp | 10 ++-- .../netfs/server/NodeMonitoringEvent.cpp | 4 +- .../netfs/server/SecurityContext.cpp | 44 +++++++------- .../netfs/server/UserSecurityContext.cpp | 6 +- .../netfs/server/VolumeManager.cpp | 58 +++++++++---------- .../file_systems/netfs/shared/FSObject.cpp | 8 ++- .../file_systems/netfs/shared/NetAddress.cpp | 12 +++- .../userlandfs/kernel_add_on/FileSystem.cpp | 4 +- .../kernel_add_on/FileSystemInitializer.cpp | 9 ++- .../kernel_add_on/FileSystemInitializer.h | 4 +- .../kernel_add_on/KernelRequestHandler.cpp | 4 +- .../userlandfs/kernel_add_on/UserlandFS.cpp | 4 +- .../userlandfs/kernel_add_on/Volume.cpp | 10 ++-- .../userlandfs/kernel_add_on/Volume.h | 2 +- .../kernel_add_on/kernel_interface.cpp | 2 +- .../userlandfs/shared/DriverSettings.cpp | 8 +-- .../network/protocols/unix/UnixEndpoint.cpp | 24 ++++---- .../network/protocols/unix/UnixEndpoint.h | 2 +- .../kernel/network/protocols/unix/UnixFifo.h | 2 +- src/add-ons/kernel/network/stack/interfaces.h | 4 +- src/system/kernel/Notifications.cpp | 10 ++-- src/system/kernel/debug/system_profiler.cpp | 10 ++-- 42 files changed, 238 insertions(+), 204 deletions(-) diff --git a/headers/private/kernel/Notifications.h b/headers/private/kernel/Notifications.h index a5a8686f46..78497afc90 100644 --- a/headers/private/kernel/Notifications.h +++ b/headers/private/kernel/Notifications.h @@ -96,7 +96,7 @@ UserMessagingListener::operator==(const NotificationListener& _other) const && other->Token() == Token(); } -class NotificationService : public Referenceable { +class NotificationService : public BReferenceable { public: virtual ~NotificationService(); diff --git a/headers/private/kernel/thread_types.h b/headers/private/kernel/thread_types.h index 42c1cf1be3..34c2f9c852 100644 --- a/headers/private/kernel/thread_types.h +++ b/headers/private/kernel/thread_types.h @@ -161,7 +161,7 @@ struct free_user_thread { class AssociatedDataOwner; -class AssociatedData : public Referenceable, +class AssociatedData : public BReferenceable, public DoublyLinkedListLinkImpl { public: AssociatedData(); diff --git a/src/add-ons/kernel/file_systems/netfs/client/ExtendedServerInfo.cpp b/src/add-ons/kernel/file_systems/netfs/client/ExtendedServerInfo.cpp index c184b15dba..f298dc1845 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/ExtendedServerInfo.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/ExtendedServerInfo.cpp @@ -6,7 +6,7 @@ // constructor ExtendedShareInfo::ExtendedShareInfo() : - BReferenceable(true), + BReferenceable(), fShareName() { } @@ -35,7 +35,7 @@ ExtendedShareInfo::GetShareName() const // constructor ExtendedServerInfo::ExtendedServerInfo(const NetAddress& address) : - BReferenceable(true), + BReferenceable(), fAddress(address), fState(0) { @@ -46,7 +46,7 @@ ExtendedServerInfo::~ExtendedServerInfo() { int32 count = CountShares(); for (int32 i = 0; i < count; i++) - ShareInfoAt(i)->RemoveReference(); + ShareInfoAt(i)->ReleaseReference(); } // GetAddress diff --git a/src/add-ons/kernel/file_systems/netfs/client/QueryIterator.cpp b/src/add-ons/kernel/file_systems/netfs/client/QueryIterator.cpp index d7cba672eb..b017f8809e 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/QueryIterator.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/QueryIterator.cpp @@ -5,7 +5,7 @@ // constructor QueryIterator::QueryIterator(Volume* volume) : - BReferenceable(false), + BReferenceable(), fVolume(volume), fParentIterator(NULL), fVolumeLink() @@ -49,6 +49,13 @@ QueryIterator::ReadQuery(struct dirent* buffer, size_t bufferSize, int32 count, } +void +QueryIterator::LastReferenceReleased() +{ + // don't delete +} + + // #pragma mark - // constructor diff --git a/src/add-ons/kernel/file_systems/netfs/client/QueryIterator.h b/src/add-ons/kernel/file_systems/netfs/client/QueryIterator.h index 9a7acb2d4e..3ab8328da7 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/QueryIterator.h +++ b/src/add-ons/kernel/file_systems/netfs/client/QueryIterator.h @@ -29,6 +29,9 @@ public: struct GetVolumeLink; friend struct GetVolumeLink; +protected: + virtual void LastReferenceReleased(); + private: Volume* fVolume; HierarchicalQueryIterator* fParentIterator; diff --git a/src/add-ons/kernel/file_systems/netfs/client/QueryManager.cpp b/src/add-ons/kernel/file_systems/netfs/client/QueryManager.cpp index 7a2eac087d..33be9bc753 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/QueryManager.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/QueryManager.cpp @@ -89,7 +89,7 @@ QueryManager::AddIterator(QueryIterator* iterator) iteratorList->Insert(iterator); // get a volume reference for the iterator - iterator->GetVolume()->AddReference(); + iterator->GetVolume()->AcquireReference(); return B_OK; } @@ -138,7 +138,7 @@ QueryManager::GetCurrentSubIterator(HierarchicalQueryIterator* iterator) AutoLocker _(fLock); QueryIterator* subIterator = iterator->GetCurrentSubIterator(); if (subIterator) - subIterator->AddReference(); + subIterator->AcquireReference(); return subIterator; } @@ -172,7 +172,7 @@ QueryManager::PutIterator(QueryIterator* iterator) return; AutoLocker locker(fLock); - if (iterator->RemoveReference()) { + if (iterator->ReleaseReference()) { // last reference removed: remove the iterator // remove its subiterators (if any) @@ -250,7 +250,7 @@ QueryManager::VolumeUnmounting(Volume* volume) iterator->GetParentIterator()->RemoveSubIterator(iterator); // remove reference - if (iterator->RemoveReference()) { + if (iterator->ReleaseReference()) { // no more reference: move to our local list iteratorList->Remove(iterator); iterators.Insert(iterator); diff --git a/src/add-ons/kernel/file_systems/netfs/client/ServerConnection.cpp b/src/add-ons/kernel/file_systems/netfs/client/ServerConnection.cpp index 19bf15b652..1554fac8cc 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/ServerConnection.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/ServerConnection.cpp @@ -24,7 +24,7 @@ struct ServerConnection::VolumeMap : HashMap, ShareVolume*> { ServerConnection::ServerConnection(VolumeManager* volumeManager, ExtendedServerInfo* serverInfo) : - BReferenceable(true), + BReferenceable(), RequestHandler(), fLock("server connection"), fVolumeManager(volumeManager), @@ -35,7 +35,7 @@ ServerConnection::ServerConnection(VolumeManager* volumeManager, fConnected(false) { if (fServerInfo) - fServerInfo->AddReference(); + fServerInfo->AcquireReference(); } // destructor @@ -46,9 +46,9 @@ PRINT(("ServerConnection::~ServerConnection()\n")) delete fConnection; delete fVolumes; if (fConnectionBrokenEvent) - fConnectionBrokenEvent->RemoveReference(); + fConnectionBrokenEvent->ReleaseReference(); if (fServerInfo) - fServerInfo->RemoveReference(); + fServerInfo->ReleaseReference(); } // Init diff --git a/src/add-ons/kernel/file_systems/netfs/client/ServerConnectionProvider.cpp b/src/add-ons/kernel/file_systems/netfs/client/ServerConnectionProvider.cpp index 252928609e..841699d8cb 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/ServerConnectionProvider.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/ServerConnectionProvider.cpp @@ -12,7 +12,7 @@ ServerConnectionProvider::ServerConnectionProvider(VolumeManager* volumeManager, ExtendedServerInfo* serverInfo, vnode_id connectionBrokenTarget) : - BReferenceable(true), + BReferenceable(), fLock("server connection provider"), fVolumeManager(volumeManager), fServerInfo(serverInfo), @@ -20,7 +20,7 @@ ServerConnectionProvider::ServerConnectionProvider(VolumeManager* volumeManager, fConnectionBrokenTarget(connectionBrokenTarget) { if (fServerInfo) - fServerInfo->AddReference(); + fServerInfo->AcquireReference(); } // destructor @@ -29,11 +29,11 @@ ServerConnectionProvider::~ServerConnectionProvider() AutoLocker _(fLock); if (fServerConnection) { fServerConnection->Close(); - fServerConnection->RemoveReference(); + fServerConnection->ReleaseReference(); } if (fServerInfo) - fServerInfo->RemoveReference(); + fServerInfo->ReleaseReference(); } // Init @@ -64,7 +64,7 @@ ServerConnectionProvider::GetServerConnection( if (!fServerConnection->IsConnected()) return B_ERROR; - fServerConnection->AddReference(); + fServerConnection->AcquireReference(); *serverConnection = fServerConnection; return B_OK; } @@ -79,7 +79,7 @@ ServerConnectionProvider::GetExistingServerConnection() if (!fServerConnection || !fServerConnection->IsConnected()) return NULL; - fServerConnection->AddReference(); + fServerConnection->AcquireReference(); return fServerConnection; } diff --git a/src/add-ons/kernel/file_systems/netfs/client/ServerManager.cpp b/src/add-ons/kernel/file_systems/netfs/client/ServerManager.cpp index 0a5d61768f..e443f43e9e 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/ServerManager.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/ServerManager.cpp @@ -55,7 +55,7 @@ public: fSuccess(false) { if (fServerInfo) - fServerInfo->AddReference(); + fServerInfo->AcquireReference(); } virtual ~ServerInfoTask() @@ -68,7 +68,7 @@ public: fServerManager->_AddingServerFailed(fServerInfo); } if (fServerInfo) - fServerInfo->RemoveReference(); + fServerInfo->ReleaseReference(); } status_t Init() @@ -195,7 +195,7 @@ ServerManager::Uninit() for (ServerInfoMap::Iterator it = fServerInfos->GetIterator(); it.HasNext();) { ExtendedServerInfo* serverInfo = it.Next().value; - serverInfo->RemoveReference(); + serverInfo->ReleaseReference(); } fServerInfos->Clear(); } @@ -219,7 +219,7 @@ ServerManager::GetServerInfo(const NetAddress& address) && serverInfo->GetState() != STATE_UPDATING)) { return NULL; } - serverInfo->AddReference(); + serverInfo->AcquireReference(); return serverInfo; } @@ -239,11 +239,11 @@ ServerManager::AddServer(const NetAddress& address) if (!serverInfo) return B_NO_MEMORY; serverInfo->SetState(STATE_ADDING); - Reference serverInfoReference(serverInfo, true); + BReference serverInfoReference(serverInfo, true); status_t error = fServerInfos->Put(address, serverInfo); if (error != B_OK) return error; - serverInfo->AddReference(); + serverInfo->AcquireReference(); // create and execute the task -- it will do what is necessary ServerInfoTask task(this, NULL, serverInfo); @@ -269,7 +269,7 @@ ServerManager::RemoveServer(const NetAddress& address) // trying to add/update it. We mark the info STATE_REMOVING, which will // remove the info as soon as possible. if (serverInfo->GetState() == STATE_READY) { - Reference _(serverInfo); + BReference _(serverInfo); _RemoveServer(serverInfo); locker.Unlock(); fListener->ServerRemoved(serverInfo); @@ -366,14 +366,14 @@ ServerManager::_BroadcastListener() if (!serverInfo) return B_NO_MEMORY; serverInfo->SetState(STATE_ADDING); - Reference serverInfoReference(serverInfo, true); + BReference serverInfoReference(serverInfo, true); if (oldServerInfo) { oldServerInfo->SetState(STATE_UPDATING); } else { status_t error = fServerInfos->Put(netAddress, serverInfo); if (error != B_OK) continue; - serverInfo->AddReference(); + serverInfo->AcquireReference(); } // create a task to add/update the server info @@ -384,7 +384,7 @@ ServerManager::_BroadcastListener() oldServerInfo->SetState(STATE_READY); } else { fServerInfos->Remove(serverInfo->GetAddress()); - serverInfo->RemoveReference(); + serverInfo->ReleaseReference(); } continue; } @@ -484,26 +484,26 @@ ServerManager::_ServerUpdated(ExtendedServerInfo* serverInfo) if (serverInfo != oldInfo) { // check whether someone told us to remove the server in the meantime if (oldInfo->GetState() == STATE_REMOVING) { - oldInfo->AddReference(); + oldInfo->AcquireReference(); _RemoveServer(oldInfo); if (fListener) { locker.Unlock(); fListener->ServerRemoved(oldInfo); } - oldInfo->RemoveReference(); + oldInfo->ReleaseReference(); return; } // no, everything is fine: go on... fServerInfos->Put(serverInfo->GetAddress(), serverInfo); - serverInfo->AddReference(); + serverInfo->AcquireReference(); serverInfo->SetState(STATE_READY); oldInfo->SetState(STATE_OBSOLETE); if (fListener) { locker.Unlock(); fListener->ServerUpdated(oldInfo, serverInfo); } - oldInfo->RemoveReference(); + oldInfo->ReleaseReference(); } else { WARN("ServerManager::_ServerUpdated(%p): WARNING: Unexpected server " "info.\n", serverInfo); @@ -518,7 +518,7 @@ ServerManager::_AddingServerFailed(ExtendedServerInfo* serverInfo) if (fServerInfos->Get(serverInfo->GetAddress()) == serverInfo) { bool removing = (serverInfo->GetState() == STATE_REMOVING); fServerInfos->Remove(serverInfo->GetAddress()); - serverInfo->RemoveReference(); + serverInfo->ReleaseReference(); serverInfo->SetState(STATE_OBSOLETE); // notify the listener, if someone told us in the meantime to remove @@ -542,13 +542,13 @@ ServerManager::_UpdatingServerFailed(ExtendedServerInfo* serverInfo) if (serverInfo != oldInfo) { // check whether someone told us to remove the server in the meantime if (oldInfo->GetState() == STATE_REMOVING) { - oldInfo->AddReference(); + oldInfo->AcquireReference(); _RemoveServer(oldInfo); if (fListener) { locker.Unlock(); fListener->ServerRemoved(oldInfo); } - oldInfo->RemoveReference(); + oldInfo->ReleaseReference(); serverInfo->SetState(STATE_OBSOLETE); return; } @@ -575,7 +575,7 @@ ServerManager::_RemoveServer(ExtendedServerInfo* serverInfo) if (oldInfo) { fServerInfos->Remove(oldInfo->GetAddress()); oldInfo->SetState(STATE_OBSOLETE); - oldInfo->RemoveReference(); + oldInfo->ReleaseReference(); } } diff --git a/src/add-ons/kernel/file_systems/netfs/client/ServerVolume.cpp b/src/add-ons/kernel/file_systems/netfs/client/ServerVolume.cpp index 30ebc24be5..a99fecf00a 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/ServerVolume.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/ServerVolume.cpp @@ -27,16 +27,16 @@ ServerVolume::ServerVolume(VolumeManager* volumeManager, fServerInfo(serverInfo), fConnectionProvider(NULL) { - fServerInfo->AddReference(); + fServerInfo->AcquireReference(); } // destructor ServerVolume::~ServerVolume() { if (fConnectionProvider) - fConnectionProvider->RemoveReference(); + fConnectionProvider->ReleaseReference(); if (fServerInfo) - fServerInfo->RemoveReference(); + fServerInfo->ReleaseReference(); } // GetServerAddress @@ -56,10 +56,10 @@ ServerVolume::SetServerInfo(ExtendedServerInfo* serverInfo) // set the new info fLock.Lock(); - fServerInfo->RemoveReference(); + fServerInfo->ReleaseReference(); fServerInfo = serverInfo; - fServerInfo->AddReference(); - Reference newReference(fServerInfo); + fServerInfo->AcquireReference(); + BReference newReference(fServerInfo); // remove shares, that are no longer there diff --git a/src/add-ons/kernel/file_systems/netfs/client/ShareNode.cpp b/src/add-ons/kernel/file_systems/netfs/client/ShareNode.cpp index 0bbe083dfd..636f658fea 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/ShareNode.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/ShareNode.cpp @@ -8,7 +8,7 @@ ShareDirEntry::ShareDirEntry(ShareDir* directory, const char* name, ShareNode* node) : - BReferenceable(true), + BReferenceable(), fDirectory(directory), fName(name), fNode(node), @@ -344,7 +344,7 @@ void RemoteShareDirIterator::Clear() { for (int32 i = 0; i < fCount; i++) - fEntries[i]->RemoveReference(); + fEntries[i]->ReleaseReference(); fCount = 0; fIndex = 0; fDone = false; @@ -359,7 +359,7 @@ RemoteShareDirIterator::AddEntry(ShareDirEntry* entry) return false; fEntries[fCount++] = entry; - entry->AddReference(); + entry->AcquireReference(); return true; } diff --git a/src/add-ons/kernel/file_systems/netfs/client/ShareVolume.cpp b/src/add-ons/kernel/file_systems/netfs/client/ShareVolume.cpp index 98855a08bd..0e64c71959 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/ShareVolume.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/ShareVolume.cpp @@ -167,11 +167,11 @@ ShareVolume::ShareVolume(VolumeManager* volumeManager, { fFlags = fVolumeManager->GetMountFlags(); if (fServerConnectionProvider) - fServerConnectionProvider->AddReference(); + fServerConnectionProvider->AcquireReference(); if (fServerInfo) - fServerInfo->AddReference(); + fServerInfo->AcquireReference(); if (fShareInfo) - fShareInfo->AddReference(); + fShareInfo->AcquireReference(); } // destructor @@ -214,13 +214,13 @@ PRINT(("ShareVolume::~ShareVolume()\n")); delete fRemoteNodeIDs; if (fShareInfo) - fShareInfo->RemoveReference(); + fShareInfo->ReleaseReference(); if (fServerInfo) - fServerInfo->RemoveReference(); + fServerInfo->ReleaseReference(); if (fServerConnection) - fServerConnection->RemoveReference(); + fServerConnection->ReleaseReference(); if (fServerConnectionProvider) - fServerConnectionProvider->RemoveReference(); + fServerConnectionProvider->ReleaseReference(); } // GetID @@ -466,7 +466,7 @@ ShareVolume::ReadVNode(vnode_id vnid, char reenter, Node** _node) *_node = node; // add a volume reference for the node - AddReference(); + AcquireReference(); return B_OK; } @@ -505,7 +505,7 @@ ShareVolume::ReadVNode(vnode_id vnid, char reenter, Node** _node) *_node = node; // add a volume reference for the node - AddReference(); + AcquireReference(); return B_OK; } @@ -2616,7 +2616,7 @@ ShareVolume::_RemoveEntry(ShareDirEntry* entry) entry->GetName())); entry->GetDirectory()->RemoveEntry(entry); entry->GetNode()->RemoveReferringEntry(entry); - entry->RemoveReference(); + entry->ReleaseReference(); } // _IsObsoleteEntryInfo @@ -3001,8 +3001,8 @@ ShareVolume::_MountShare() { // get references to the server and share info AutoLocker locker(fLock); - Reference serverInfoReference(fServerInfo); - Reference shareInfoReference(fShareInfo); + BReference serverInfoReference(fServerInfo); + BReference shareInfoReference(fShareInfo); ExtendedServerInfo* serverInfo = fServerInfo; ExtendedShareInfo* shareInfo = fShareInfo; locker.Unlock(); diff --git a/src/add-ons/kernel/file_systems/netfs/client/VirtualVolume.cpp b/src/add-ons/kernel/file_systems/netfs/client/VirtualVolume.cpp index 149781630d..63ce83b062 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/VirtualVolume.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/VirtualVolume.cpp @@ -147,7 +147,7 @@ VirtualVolume::AddChildVolume(Volume* volume) // set the volume's parent volume volume->SetParentVolume(this); - AddReference(); + AcquireReference(); // send out a notification vnode_id dirID = fRootNode->GetID(); @@ -290,7 +290,7 @@ VirtualVolume::ReadVNode(vnode_id vnid, char reenter, Node** node) *node = fRootNode; // add a volume reference for the node - AddReference(); + AcquireReference(); return B_OK; } diff --git a/src/add-ons/kernel/file_systems/netfs/client/VolumeEvent.cpp b/src/add-ons/kernel/file_systems/netfs/client/VolumeEvent.cpp index b6e731ba7d..25270ab548 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/VolumeEvent.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/VolumeEvent.cpp @@ -5,7 +5,7 @@ // constructor VolumeEvent::VolumeEvent(uint32 type, vnode_id target) : - BReferenceable(true), + BReferenceable(), fType(type), fTarget(target) { diff --git a/src/add-ons/kernel/file_systems/netfs/client/VolumeManager.cpp b/src/add-ons/kernel/file_systems/netfs/client/VolumeManager.cpp index b444320527..2245ad6cae 100644 --- a/src/add-ons/kernel/file_systems/netfs/client/VolumeManager.cpp +++ b/src/add-ons/kernel/file_systems/netfs/client/VolumeManager.cpp @@ -54,7 +54,7 @@ public: while (VolumeEvent* event = fEvents.First()) { fEvents.Remove(event); - event->RemoveReference(); + event->ReleaseReference(); } } @@ -67,7 +67,7 @@ public: if (fCounterSem < 0) return; fEvents.Insert(event); - event->AddReference(); + event->AcquireReference(); release_sem(fCounterSem); } @@ -208,7 +208,7 @@ VolumeManager::MountRootVolume(const char* device, PutVolume(rootVolume); return error; } - rootVolume->AddReference(); + rootVolume->AcquireReference(); *volume = rootVolume; // run the event deliverer @@ -283,7 +283,7 @@ VolumeManager::GetVolume(Volume* volume) AutoLocker _(this); if (fVolumes->Contains(volume)) { // TODO: Any restrictions regarding volumes about to be removed? - volume->AddReference(); + volume->AcquireReference(); return volume; } return NULL; @@ -332,7 +332,7 @@ VolumeManager::PutVolume(Volume* volume) // we unmount and delete it. { AutoLocker locker(this); - if (volume->RemoveReference() && volume->IsRemoved()) { + if (volume->ReleaseReference() && volume->IsRemoved()) { PRINT(("VolumeManager::PutVolume(%p): Removed volume unreferenced. " "Unmounting...\n", volume)); // remove from volume set -- now noone can get a reference to it @@ -400,7 +400,7 @@ VolumeManager::_EventDeliverer() volume->HandleEvent(event); PutVolume(volume); } - event->RemoveReference(); + event->ReleaseReference(); } return 0; } diff --git a/src/add-ons/kernel/file_systems/netfs/headers/shared/FSObject.h b/src/add-ons/kernel/file_systems/netfs/headers/shared/FSObject.h index c4a31bf98e..08f2a86ccb 100644 --- a/src/add-ons/kernel/file_systems/netfs/headers/shared/FSObject.h +++ b/src/add-ons/kernel/file_systems/netfs/headers/shared/FSObject.h @@ -13,6 +13,9 @@ public: void MarkRemoved(); bool IsRemoved() const; +protected: + virtual void LastReferenceReleased(); + private: bool fRemoved; }; diff --git a/src/add-ons/kernel/file_systems/netfs/server/ClientConnection.cpp b/src/add-ons/kernel/file_systems/netfs/server/ClientConnection.cpp index 63f814f411..8a73ad9898 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/ClientConnection.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/ClientConnection.cpp @@ -125,13 +125,13 @@ struct ClientConnection::VolumeNodeMonitoringEvent { event(event) { if (event) - event->AddReference(); + event->AcquireReference(); } ~VolumeNodeMonitoringEvent() { if (event) - event->RemoveReference(); + event->ReleaseReference(); } int32 volumeID; @@ -544,7 +544,7 @@ ClientConnection::VisitMountRequest(MountRequest* request) AutoLocker securityContextLocker(fSecurityContextLock); const char* userName = request->user.GetString(); User* user = fUser; - Reference userReference(user); + BReference userReference(user); bool noPermission = false; if (result == B_OK && !user) { if (userName) { @@ -588,7 +588,7 @@ ClientConnection::VisitMountRequest(MountRequest* request) } else SET_ERROR(result, B_ENTRY_NOT_FOUND); } - Reference shareReference(share, true); + BReference shareReference(share, true); // mount the volume MountReply reply; @@ -2774,7 +2774,7 @@ ClientConnection::_GetVolume(int32 id) ClientVolume* volume = fVolumes->Get(id); if (!volume || volume->IsRemoved()) return NULL; - volume->AddReference(); + volume->AcquireReference(); return volume; } @@ -2789,7 +2789,7 @@ ClientConnection::_PutVolume(ClientVolume* volume) // decrement reference counter and remove the volume, if 0 AutoLocker locker(fVolumes); - bool removed = (volume->RemoveReference() && volume->IsRemoved()); + bool removed = (volume->ReleaseReference() && volume->IsRemoved()); if (removed) fVolumes->Remove(volume->GetID()); locker.Unlock(); @@ -2818,7 +2818,7 @@ ClientConnection::_UnmountVolume(ClientVolume* volume) event->opcode = B_DEVICE_UNMOUNTED; _PushNodeMonitoringEvent(volume->GetID(), event); - event->RemoveReference(); + event->ReleaseReference(); } } @@ -3233,7 +3233,7 @@ ClientConnection::_OpenQuery(const char* queryString, uint32 flags, flags, remotePort, remoteToken, &queryHandle); if (error != B_OK) return error; - Reference handleReference(queryHandle, true); + BReference handleReference(queryHandle, true); // lock the handle queryHandle->Lock(); diff --git a/src/add-ons/kernel/file_systems/netfs/server/ClientVolume.cpp b/src/add-ons/kernel/file_systems/netfs/server/ClientVolume.cpp index 04d1aa19e3..f6af50a733 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/ClientVolume.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/ClientVolume.cpp @@ -43,7 +43,7 @@ ClientVolume::~ClientVolume() Unmount(); if (fShare) - fShare->RemoveReference(); + fShare->ReleaseReference(); delete fNodeHandles; delete fSecurityContext; @@ -84,7 +84,7 @@ ClientVolume::Mount(UserSecurityContext* securityContext, Share* share) securityContextDeleter.Detach(); fShare = share; - fShare->AddReference(); + fShare->AcquireReference(); dev_t volumeID = share->GetVolumeID(); ino_t nodeID = share->GetNodeID(); @@ -400,7 +400,7 @@ ClientVolume::Open(Node* node, int openMode, FileHandle** _handle) status_t error = node->Open(openMode, &handle); if (error != B_OK) return error; - Reference handleReference(handle, true); + BReference handleReference(handle, true); // lock the handle handle->Lock(); @@ -429,7 +429,7 @@ ClientVolume::OpenDir(Directory* directory, DirIterator** _iterator) status_t error = directory->OpenDir(&iterator); if (error != B_OK) return error; - Reference handleReference(iterator, true); + BReference handleReference(iterator, true); // lock the handle iterator->Lock(); @@ -458,7 +458,7 @@ ClientVolume::OpenAttrDir(Node* node, AttrDirIterator** _iterator) status_t error = node->OpenAttrDir(&iterator); if (error != B_OK) return error; - Reference handleReference(iterator, true); + BReference handleReference(iterator, true); // lock the handle iterator->Lock(); diff --git a/src/add-ons/kernel/file_systems/netfs/server/NetFSServer.cpp b/src/add-ons/kernel/file_systems/netfs/server/NetFSServer.cpp index d1fc937463..b425c6727f 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/NetFSServer.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/NetFSServer.cpp @@ -408,7 +408,7 @@ NetFSServer::MessageReceived(BMessage* message) connection->UserRemoved(user); } - user->RemoveReference(); + user->ReleaseReference(); } _SendReply(message, error); @@ -446,7 +446,7 @@ NetFSServer::MessageReceived(BMessage* message) _SendReply(message, B_ENTRY_NOT_FOUND); break; } - Reference userReference(user, true); + BReference userReference(user, true); // get the statistics BMessage statistics; @@ -509,7 +509,7 @@ NetFSServer::MessageReceived(BMessage* message) connection->ShareRemoved(share); } - share->RemoveReference(); + share->ReleaseReference(); } if (error == B_OK) @@ -552,7 +552,7 @@ NetFSServer::MessageReceived(BMessage* message) _SendReply(message, B_ENTRY_NOT_FOUND); break; } - Reference shareReference(share, true); + BReference shareReference(share, true); // get all users BMessage allUsers; @@ -572,7 +572,7 @@ NetFSServer::MessageReceived(BMessage* message) // get the user's permissions Permissions permissions = fSecurityContext ->GetNodePermissions(share->GetPath(), user); - user->RemoveReference(); + user->ReleaseReference(); // add the user, if they have the permission to mount the // share @@ -616,7 +616,7 @@ NetFSServer::MessageReceived(BMessage* message) _SendReply(message, B_ENTRY_NOT_FOUND); break; } - Reference shareReference(share, true); + BReference shareReference(share, true); // get the statistics BMessage statistics; @@ -653,8 +653,8 @@ NetFSServer::MessageReceived(BMessage* message) // get the share and the user Share* share = fSecurityContext->FindShare(shareName); User* user = fSecurityContext->FindUser(userName); - Reference shareReference(share); - Reference userReference(user); + BReference shareReference(share); + BReference userReference(user); if (!share || !user) { _SendReply(message, B_ENTRY_NOT_FOUND); break; @@ -699,8 +699,8 @@ NetFSServer::MessageReceived(BMessage* message) // get the share and the user Share* share = fSecurityContext->FindShare(shareName); User* user = fSecurityContext->FindUser(userName); - Reference shareReference(share); - Reference userReference(user); + BReference shareReference(share); + BReference userReference(user); if (!share || !user) { _SendReply(message, B_ENTRY_NOT_FOUND); break; @@ -837,7 +837,7 @@ NetFSServer::_LoadSecurityContext(SecurityContext** _securityContext) ERROR("ERROR: Failed to add share `%s'\n", shareName); continue; } - Reference shareReference(share, true); + BReference shareReference(share, true); DriverParameter userParameter; // iterate through the share users for (DriverParameterIterator userIt @@ -850,7 +850,7 @@ NetFSServer::_LoadSecurityContext(SecurityContext** _securityContext) ERROR("ERROR: Undefined user `%s'.\n", userName); continue; } - Reference userReference(user, true); + BReference userReference(user, true); DriverParameter permissionsParameter; if (!userParameter.FindParameter("permissions", &permissionsParameter)) { diff --git a/src/add-ons/kernel/file_systems/netfs/server/NodeHandle.cpp b/src/add-ons/kernel/file_systems/netfs/server/NodeHandle.cpp index cdbab87614..fcf3ba2e0c 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/NodeHandle.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/NodeHandle.cpp @@ -21,7 +21,7 @@ // constructor NodeHandle::NodeHandle() - : BReferenceable(true), + : BReferenceable(), Lockable(), fCookie(-1), fNodeRef() diff --git a/src/add-ons/kernel/file_systems/netfs/server/NodeHandleMap.cpp b/src/add-ons/kernel/file_systems/netfs/server/NodeHandleMap.cpp index dbcdfa3367..8d2f5e272d 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/NodeHandleMap.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/NodeHandleMap.cpp @@ -42,7 +42,7 @@ NodeHandleMap::AddNodeHandle(NodeHandle* handle) status_t error = Put(handle->GetCookie(), handle); if (error == B_OK) - handle->AddReference(); + handle->AcquireReference(); return error; } @@ -60,7 +60,7 @@ NodeHandleMap::RemoveNodeHandle(NodeHandle* handle) return false; Remove(handle->GetCookie()); - handle->RemoveReference(); + handle->ReleaseReference(); return true; } @@ -81,7 +81,7 @@ NodeHandleMap::LockNodeHandle(int32 cookie, NodeHandle** _handle) handle = Get(cookie); if (!handle) return B_ENTRY_NOT_FOUND; - handle->AddReference(); + handle->AcquireReference(); // first attempt: we just try to lock the node handle, which will fail, // if someone else has the lock at the momemt @@ -109,7 +109,7 @@ NodeHandleMap::LockNodeHandle(int32 cookie, NodeHandle** _handle) // wait for the lock status_t error = lockerCandidate.Block(); if (error != B_OK) { - handle->RemoveReference(); + handle->ReleaseReference(); return error; } @@ -130,7 +130,7 @@ NodeHandleMap::UnlockNodeHandle(NodeHandle* nodeHandle) AutoLocker _(this); nodeHandle->Unlock(); - nodeHandle->RemoveReference(); + nodeHandle->ReleaseReference(); } } diff --git a/src/add-ons/kernel/file_systems/netfs/server/NodeMonitoringEvent.cpp b/src/add-ons/kernel/file_systems/netfs/server/NodeMonitoringEvent.cpp index 4217d7b337..eadca74be6 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/NodeMonitoringEvent.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/NodeMonitoringEvent.cpp @@ -10,7 +10,7 @@ // constructor NodeMonitoringEvent::NodeMonitoringEvent() - : BReferenceable(true), + : BReferenceable(), time(system_time()), queryHandler(NULL), remotePort(-1), @@ -22,7 +22,7 @@ NodeMonitoringEvent::NodeMonitoringEvent() NodeMonitoringEvent::~NodeMonitoringEvent() { if (queryHandler) - queryHandler->RemoveReference(); + queryHandler->ReleaseReference(); } diff --git a/src/add-ons/kernel/file_systems/netfs/server/SecurityContext.cpp b/src/add-ons/kernel/file_systems/netfs/server/SecurityContext.cpp index 0021e19361..8662ac0b53 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/SecurityContext.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/SecurityContext.cpp @@ -38,7 +38,7 @@ get_node_ref_for_path(const char* path, node_ref* ref) // constructor User::User() - : BReferenceable(true), + : BReferenceable(), BArchivable(), fName(), fPassword() @@ -47,7 +47,7 @@ User::User() // constructor User::User(BMessage* archive) - : BReferenceable(true), + : BReferenceable(), BArchivable(archive), fName(), fPassword() @@ -145,7 +145,7 @@ User::GetPassword() const // constructor Share::Share() - : BReferenceable(true), + : BReferenceable(), BArchivable(), fName(), fNodeRef(), @@ -155,7 +155,7 @@ Share::Share() // constructor Share::Share(BMessage* archive) - : BReferenceable(true), + : BReferenceable(), BArchivable(archive), fName(), fNodeRef(), @@ -436,7 +436,7 @@ SecurityContext::SecurityContext(BMessage* archive) User* user = FindUser(userName); if (!user) return; - Reference userReference(user, true); + BReference userReference(user, true); error = permissionsArchive.FindMessage(userName, &userArchive); if (error != B_OK) return; @@ -464,13 +464,13 @@ SecurityContext::~SecurityContext() // remove all user references for (UserMap::Iterator it = fUsers->GetIterator(); it.HasNext();) { User* user = it.Next().value; - user->RemoveReference(); + user->ReleaseReference(); } // remove all share references for (ShareMap::Iterator it = fShares->GetIterator(); it.HasNext();) { Share* share = it.Next().value; - share->RemoveReference(); + share->ReleaseReference(); } delete fUsers; @@ -609,7 +609,7 @@ SecurityContext::AddUser(const char* name, const char* password, User** _user) User* user = new(std::nothrow) User; if (!user) return B_NO_MEMORY; - Reference userReference(user, true); + BReference userReference(user, true); status_t error = user->Init(name, password); if (error != B_OK) return error; @@ -622,7 +622,7 @@ SecurityContext::AddUser(const char* name, const char* password, User** _user) userReference.Detach(); if (_user) { *_user = user; - user->AddReference(); + user->AcquireReference(); } return B_OK; } @@ -642,13 +642,13 @@ SecurityContext::RemoveUser(const char* name, User** _user) User* user = FindUser(name); if (!user) return B_ENTRY_NOT_FOUND; - Reference userReference(user, true); + BReference userReference(user, true); // remove it status_t error = RemoveUser(user); if (error == B_OK && _user) { *_user = user; - user->AddReference(); + user->AcquireReference(); } return error; @@ -677,7 +677,7 @@ SecurityContext::RemoveUser(User* user) } // surrender our user reference - user->RemoveReference(); + user->ReleaseReference(); return B_OK; } @@ -694,7 +694,7 @@ SecurityContext::FindUser(const char* name) ContextLocker _(this); User* user = fUsers->Get(name); if (user) - user->AddReference(); + user->AcquireReference(); return user; } @@ -713,7 +713,7 @@ SecurityContext::AuthenticateUser(const char* name, const char* password, User* user = FindUser(name); if (!user) return B_PERMISSION_DENIED; - Reference userReference(user, true); + BReference userReference(user, true); // check password if (user->GetPassword()) { @@ -773,7 +773,7 @@ SecurityContext::AddShare(const char* name, const node_ref& ref, Share** _share) Share* share = new(std::nothrow) Share; if (!share) return B_NO_MEMORY; - Reference shareReference(share, true); + BReference shareReference(share, true); status_t error = share->Init(name, ref); if (error != B_OK) return error; @@ -786,7 +786,7 @@ SecurityContext::AddShare(const char* name, const node_ref& ref, Share** _share) shareReference.Detach(); if (_share) { *_share = share; - share->AddReference(); + share->AcquireReference(); } return B_OK; } @@ -809,7 +809,7 @@ SecurityContext::AddShare(const char* name, const char* path, Share** _share) Share* share = new(std::nothrow) Share; if (!share) return B_NO_MEMORY; - Reference shareReference(share, true); + BReference shareReference(share, true); status_t error = share->Init(name, path); if (error != B_OK) return error; @@ -822,7 +822,7 @@ SecurityContext::AddShare(const char* name, const char* path, Share** _share) shareReference.Detach(); if (_share) { *_share = share; - share->AddReference(); + share->AcquireReference(); } return B_OK; } @@ -842,13 +842,13 @@ SecurityContext::RemoveShare(const char* name, Share** _share) Share* share = FindShare(name); if (!share) return B_ENTRY_NOT_FOUND; - Reference shareReference(share, true); + BReference shareReference(share, true); // remove it status_t error = RemoveShare(share); if (error == B_OK && _share) { *_share = share; - share->AddReference(); + share->AcquireReference(); } return error; @@ -869,7 +869,7 @@ SecurityContext::RemoveShare(Share* share) fShares->Remove(share->GetName()); // surrender our share reference - share->RemoveReference(); + share->ReleaseReference(); return B_OK; } @@ -886,7 +886,7 @@ SecurityContext::FindShare(const char* name) ContextLocker _(this); Share* share = fShares->Get(name); if (share) - share->AddReference(); + share->AcquireReference(); return share; } diff --git a/src/add-ons/kernel/file_systems/netfs/server/UserSecurityContext.cpp b/src/add-ons/kernel/file_systems/netfs/server/UserSecurityContext.cpp index a5ec4527e0..4b3a3a2992 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/UserSecurityContext.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/UserSecurityContext.cpp @@ -23,7 +23,7 @@ UserSecurityContext::UserSecurityContext() UserSecurityContext::~UserSecurityContext() { if (fUser) - fUser->RemoveReference(); + fUser->ReleaseReference(); delete fPermissions; } @@ -33,11 +33,11 @@ status_t UserSecurityContext::Init(User* user) { if (fUser) - fUser->RemoveReference(); + fUser->ReleaseReference(); fUser = user; if (fUser) - fUser->AddReference(); + fUser->AcquireReference(); delete fPermissions; fPermissions = new(std::nothrow) PermissionMap; diff --git a/src/add-ons/kernel/file_systems/netfs/server/VolumeManager.cpp b/src/add-ons/kernel/file_systems/netfs/server/VolumeManager.cpp index c636afe486..f964b54bca 100644 --- a/src/add-ons/kernel/file_systems/netfs/server/VolumeManager.cpp +++ b/src/add-ons/kernel/file_systems/netfs/server/VolumeManager.cpp @@ -38,7 +38,7 @@ public: : BHandler(), QueryListener(), - BReferenceable(true), + BReferenceable(), fListener(listener), fQueryDomain(queryDomain), fHandle(handle) @@ -77,7 +77,7 @@ public: } if (event) { event->queryHandler = this; - AddReference(); + AcquireReference(); if (event->Init(message) == B_OK) fListener->ProcessNodeMonitoringEvent(event); else @@ -98,7 +98,7 @@ public: looper->Unlock(); } handle->SetQueryListener(NULL); - RemoveReference(); + ReleaseReference(); } private: @@ -227,21 +227,21 @@ VolumeManager::~VolumeManager() // entry created events for (EntryCreatedEventMap::Iterator it = fEntryCreatedEvents->GetIterator(); it.HasNext();) { - it.Next().value->RemoveReference(); + it.Next().value->ReleaseReference(); } delete fEntryCreatedEvents; // entry removed events for (EntryRemovedEventMap::Iterator it = fEntryRemovedEvents->GetIterator(); it.HasNext();) { - it.Next().value->RemoveReference(); + it.Next().value->ReleaseReference(); } delete fEntryRemovedEvents; // entry moved events for (EntryMovedEventMap::Iterator it = fEntryMovedEvents->GetIterator(); it.HasNext();) { - it.Next().value->RemoveReference(); + it.Next().value->ReleaseReference(); } delete fEntryMovedEvents; @@ -249,7 +249,7 @@ VolumeManager::~VolumeManager() for (NodeStatChangedEventMap::Iterator it = fNodeStatChangedEvents->GetIterator(); it.HasNext();) { - it.Next().value->RemoveReference(); + it.Next().value->ReleaseReference(); } delete fNodeStatChangedEvents; @@ -257,7 +257,7 @@ VolumeManager::~VolumeManager() for (NodeAttributeChangedEventMap::Iterator it = fNodeAttributeChangedEvents->GetIterator(); it.HasNext();) { - it.Next().value->RemoveReference(); + it.Next().value->ReleaseReference(); } delete fNodeAttributeChangedEvents; @@ -1071,13 +1071,13 @@ VolumeManager::_EntryCreated(EntryCreatedEvent* event) fEntryCreatedEvents->Remove(ref); fRecentNodeMonitoringEvents.Remove(oldEvent); notify = !_IsRecentEvent(oldEvent); - oldEvent->RemoveReference(); + oldEvent->ReleaseReference(); } // add the new event if (fEntryCreatedEvents->Put(ref, event) == B_OK) { fRecentNodeMonitoringEvents.Insert(event); - event->AddReference(); + event->AcquireReference(); } // if the directory is complete or at least has iterators attached to it, @@ -1148,13 +1148,13 @@ VolumeManager::_EntryRemoved(EntryRemovedEvent* event, bool keepNode) fEntryRemovedEvents->Remove(ref); fRecentNodeMonitoringEvents.Remove(oldEvent); notify = !_IsRecentEvent(oldEvent); - oldEvent->RemoveReference(); + oldEvent->ReleaseReference(); } // add the new event if (fEntryRemovedEvents->Put(ref, event) == B_OK) { fRecentNodeMonitoringEvents.Insert(event); - event->AddReference(); + event->AcquireReference(); } // remove the entry @@ -1236,13 +1236,13 @@ VolumeManager::_EntryMoved(EntryMovedEvent* event) fEntryMovedEvents->Remove(key); fRecentNodeMonitoringEvents.Remove(oldEvent); notify = !_IsRecentEvent(oldEvent); - oldEvent->RemoveReference(); + oldEvent->ReleaseReference(); } // add the new event if (fEntryMovedEvents->Put(key, event) == B_OK) { fRecentNodeMonitoringEvents.Insert(event); - event->AddReference(); + event->AcquireReference(); } } @@ -1301,7 +1301,7 @@ VolumeManager::_EntryMoved(EntryMovedEvent* event) if (event->fromName.GetLength() > 0) removedEvent->name = event->fromName; clientVolume->ProcessNodeMonitoringEvent(removedEvent); - removedEvent->RemoveReference(); + removedEvent->ReleaseReference(); } } else if (containsTo) { // contains only the target directory: generate an @@ -1316,7 +1316,7 @@ VolumeManager::_EntryMoved(EntryMovedEvent* event) createdEvent->directoryID = event->toDirectoryID; createdEvent->name = event->toName; clientVolume->ProcessNodeMonitoringEvent(createdEvent); - createdEvent->RemoveReference(); + createdEvent->ReleaseReference(); } } } @@ -1341,13 +1341,13 @@ VolumeManager::_NodeStatChanged(StatChangedEvent* event) fNodeStatChangedEvents->Remove(ref); fRecentNodeMonitoringEvents.Remove(oldEvent); notify = !_IsRecentEvent(oldEvent); - oldEvent->RemoveReference(); + oldEvent->ReleaseReference(); } // add the new event if (fNodeStatChangedEvents->Put(ref, event) == B_OK) { fRecentNodeMonitoringEvents.Insert(event); - event->AddReference(); + event->AcquireReference(); } if (notify) { @@ -1384,13 +1384,13 @@ VolumeManager::_NodeAttributeChanged(AttributeChangedEvent* event) fNodeAttributeChangedEvents->Remove(ref); fRecentNodeMonitoringEvents.Remove(oldEvent); notify = !_IsRecentEvent(oldEvent); - oldEvent->RemoveReference(); + oldEvent->ReleaseReference(); } // add the new event if (fNodeAttributeChangedEvents->Put(ref, event) == B_OK) { fRecentNodeMonitoringEvents.Insert(event); - event->AddReference(); + event->AcquireReference(); } // send notifications @@ -1425,7 +1425,7 @@ VolumeManager::_VolumeMounted(VolumeMountedEvent* event) if (_GenerateEntryRemovedEvent(entry, system_time(), &event) == B_OK) { _EntryRemoved(event, true); - event->RemoveReference(); + event->ReleaseReference(); } else { RemoveEntry(entry); delete entry; @@ -1471,7 +1471,7 @@ VolumeManager::_VolumeUnmounted(VolumeUnmountedEvent* event) if (_GenerateEntryRemovedEvent(entry, event->time, &removedEvent) == B_OK) { _EntryRemoved(removedEvent, true); - removedEvent->RemoveReference(); + removedEvent->ReleaseReference(); } else { RemoveEntry(entry); delete entry; @@ -1590,7 +1590,7 @@ VolumeManager::_QueryEntryMoved(EntryMovedEvent* event) removedEvent->opcode = B_ENTRY_REMOVED; removedEvent->time = event->time; removedEvent->queryHandler = event->queryHandler; - removedEvent->queryHandler->AddReference(); + removedEvent->queryHandler->AcquireReference(); removedEvent->volumeID = event->volumeID; removedEvent->directoryID = event->fromDirectoryID; removedEvent->nodeVolumeID = event->volumeID; @@ -1601,7 +1601,7 @@ VolumeManager::_QueryEntryMoved(EntryMovedEvent* event) createdEvent->opcode = B_ENTRY_CREATED; createdEvent->time = event->time; createdEvent->queryHandler = event->queryHandler; - createdEvent->queryHandler->AddReference(); + createdEvent->queryHandler->AcquireReference(); createdEvent->volumeID = event->volumeID; createdEvent->directoryID = event->toDirectoryID; createdEvent->nodeID = event->nodeID; @@ -1609,9 +1609,9 @@ VolumeManager::_QueryEntryMoved(EntryMovedEvent* event) // send them _QueryEntryRemoved(removedEvent); - removedEvent->RemoveReference(); + removedEvent->ReleaseReference(); _QueryEntryCreated(createdEvent); - createdEvent->RemoveReference(); + createdEvent->ReleaseReference(); } // _IsRecentEvent @@ -1650,7 +1650,7 @@ VolumeManager::_GenerateEntryCreatedEvent(const entry_ref& ref, bigtime_t time, *_event = event; } else { _EntryCreated(event); - event->RemoveReference(); + event->ReleaseReference(); } return B_OK; @@ -1682,7 +1682,7 @@ VolumeManager::_GenerateEntryRemovedEvent(Entry* entry, bigtime_t time, *_event = event; } else { _EntryRemoved(event, false); - event->RemoveReference(); + event->ReleaseReference(); } return B_OK; @@ -1776,7 +1776,7 @@ VolumeManager::_NodeMonitoringProcessor() break; } } - event->RemoveReference(); + event->ReleaseReference(); // If there is another event available, get it as long as we // have the VolumeManager lock. diff --git a/src/add-ons/kernel/file_systems/netfs/shared/FSObject.cpp b/src/add-ons/kernel/file_systems/netfs/shared/FSObject.cpp index 0dd15966e1..808ab1d2f6 100644 --- a/src/add-ons/kernel/file_systems/netfs/shared/FSObject.cpp +++ b/src/add-ons/kernel/file_systems/netfs/shared/FSObject.cpp @@ -5,7 +5,7 @@ // constructor FSObject::FSObject() : - BReferenceable(false), + BReferenceable(), fRemoved(false) { } @@ -29,3 +29,9 @@ FSObject::IsRemoved() const return fRemoved; } + +void +FSObject::LastReferenceReleased() +{ + // don't delete +} diff --git a/src/add-ons/kernel/file_systems/netfs/shared/NetAddress.cpp b/src/add-ons/kernel/file_systems/netfs/shared/NetAddress.cpp index ecda42695d..90d1f291ab 100644 --- a/src/add-ons/kernel/file_systems/netfs/shared/NetAddress.cpp +++ b/src/add-ons/kernel/file_systems/netfs/shared/NetAddress.cpp @@ -191,7 +191,7 @@ NetAddress::operator!=(const NetAddress& address) const class NetAddressResolver::Resolver : public BReferenceable { public: Resolver() - : BReferenceable(false), + : BReferenceable(), fLock() { } @@ -217,6 +217,12 @@ public: return B_OK; } +protected: + virtual void LastReferenceReleased() + { + // don't delete + } + private: Locker fLock; }; @@ -227,7 +233,7 @@ NetAddressResolver::NetAddressResolver() _Lock(); // initialize static instance, if not done yet if (sResolver) { - sResolver->AddReference(); + sResolver->AcquireReference(); fResolver = sResolver; } else { sResolver = new(std::nothrow) Resolver; @@ -247,7 +253,7 @@ NetAddressResolver::~NetAddressResolver() { if (fResolver) { _Lock(); - if (sResolver->RemoveReference()) { + if (sResolver->ReleaseReference()) { delete sResolver; sResolver = NULL; } diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp index 3bf68bc8ce..fdf376fdcc 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp @@ -382,7 +382,7 @@ FileSystem::Mount(fs_volume* fsVolume, const char* device, uint32 flags, MutexLocker locker(fVolumeLock); fVolumes.Remove(volume); locker.Unlock(); - volume->RemoveReference(); + volume->ReleaseReference(); return error; } @@ -442,7 +442,7 @@ FileSystem::GetVolume(dev_t id) it++) { Volume* volume = *it; if (volume->GetID() == id) { - volume->AddReference(); + volume->AcquireReference(); return volume; } } diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystemInitializer.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystemInitializer.cpp index 850174e501..4cf4946538 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystemInitializer.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystemInitializer.cpp @@ -26,7 +26,7 @@ // constructor FileSystemInitializer::FileSystemInitializer(const char* name) : - Referenceable(false), + BReferenceable(), fName(name), fFileSystem(NULL) { @@ -99,6 +99,13 @@ FileSystemInitializer::FirstTimeInit() } +void +FileSystemInitializer::LastReferenceReleased() +{ + // don't delete +} + + status_t FileSystemInitializer::_Init(port_id port) { diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystemInitializer.h b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystemInitializer.h index b8eae7f148..c3f4ed1762 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystemInitializer.h +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystemInitializer.h @@ -20,7 +20,7 @@ using UserlandFSUtil::RequestPort; class FileSystem; -class FileSystemInitializer : public LazyInitializable, public Referenceable { +class FileSystemInitializer : public LazyInitializable, public BReferenceable { public: FileSystemInitializer(const char* name); ~FileSystemInitializer(); @@ -30,6 +30,8 @@ public: protected: virtual status_t FirstTimeInit(); + virtual void LastReferenceReleased(); + private: status_t _Init(port_id port); diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/KernelRequestHandler.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/KernelRequestHandler.cpp index 90ad31fd44..5bdbbb7ac1 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/KernelRequestHandler.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/KernelRequestHandler.cpp @@ -24,7 +24,7 @@ public: ~VolumePutter() { if (fVolume) - fVolume->RemoveReference(); + fVolume->ReleaseReference(); } private: @@ -906,7 +906,7 @@ KernelRequestHandler::_GetVolume(dev_t id, Volume** volume) *volume = NULL; return B_BAD_VALUE; } - fVolume->AddReference(); + fVolume->AcquireReference(); *volume = fVolume; return B_OK; } diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/UserlandFS.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/UserlandFS.cpp index 54ec21eda4..7728fc9137 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/UserlandFS.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/UserlandFS.cpp @@ -87,7 +87,7 @@ UserlandFS::RegisterFileSystem(const char* name, FileSystem** _fileSystem) FileSystemLocker _(fFileSystems); fileSystemInitializer = fFileSystems->Get(name); if (fileSystemInitializer) { - fileSystemInitializer->AddReference(); + fileSystemInitializer->AcquireReference(); } else { fileSystemInitializer = new(nothrow) FileSystemInitializer(name); if (!fileSystemInitializer) @@ -164,7 +164,7 @@ UserlandFS::_UnregisterFileSystem(const char* name) if (!fileSystemInitializer) return B_BAD_VALUE; - deleteFS = fileSystemInitializer->RemoveReference(); + deleteFS = fileSystemInitializer->ReleaseReference(); if (deleteFS) fFileSystems->Remove(name); } diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp index cc63ccf4d4..78b61bca4f 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp @@ -173,7 +173,7 @@ struct Volume::IORequestStructMap // IterativeFDIOCookie -struct Volume::IterativeFDIOCookie : public Referenceable { +struct Volume::IterativeFDIOCookie : public BReferenceable { Volume* volume; int fd; int32 requestID; @@ -295,7 +295,7 @@ Volume::HasVNodeCapability(VNode* vnode, int capability) const // constructor Volume::Volume(FileSystem* fileSystem, fs_volume* fsVolume) : - Referenceable(true), + BReferenceable(), fFileSystem(fileSystem), fFSVolume(fsVolume), fUserlandVolume(NULL), @@ -741,7 +741,7 @@ Volume::DoIterativeFDIO(int fd, int32 requestID, void* clientCookie, } // we need another reference, so we can still access the cookie below - cookie->AddReference(); + cookie->AcquireReference(); // TODO: Up to this point we're responsible for calling the finished hook on // error! @@ -754,7 +754,7 @@ Volume::DoIterativeFDIO(int fd, int32 requestID, void* clientCookie, MutexLocker _(fLock); cookie->vecs = NULL; cookie->vecCount = 0; - cookie->RemoveReference(); + cookie->ReleaseReference(); return error; } @@ -4765,7 +4765,7 @@ Volume::_IterativeFDIOFinished(void* _cookie, io_request* ioRequest, // At any rate, we're done with the cookie after this call -- it will not // be used anymore. - Reference _(cookie, true); + BReference _(cookie, true); // We also want to dispose of the request. IORequestRemover _2(volume, cookie->requestID); diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.h b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.h index d7ec67f9a2..0c47db573b 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.h +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.h @@ -32,7 +32,7 @@ using UserlandFSUtil::userlandfs_ioctl; class FileSystem; -class Volume : public Referenceable { +class Volume : public BReferenceable { public: Volume(FileSystem* fileSystem, fs_volume* fsVolume); diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/kernel_interface.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/kernel_interface.cpp index c7eb8c3157..6dda107fa0 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/kernel_interface.cpp @@ -125,7 +125,7 @@ userlandfs_unmount(fs_volume* fsVolume) status_t error = volume->Unmount(); // The error code the FS's unmount hook returns is completely irrelevant to // the VFS. It considers the volume unmounted in any case. - volume->RemoveReference(); + volume->ReleaseReference(); UserlandFS::GetUserlandFS()->UnregisterFileSystem(fileSystem); PRINT(("userlandfs_unmount() done: %lx\n", error)); diff --git a/src/add-ons/kernel/file_systems/userlandfs/shared/DriverSettings.cpp b/src/add-ons/kernel/file_systems/userlandfs/shared/DriverSettings.cpp index dff2a23fd7..9e4c2553ab 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/shared/DriverSettings.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/shared/DriverSettings.cpp @@ -22,9 +22,9 @@ static const int32 kTrueValueStringCount // #pragma mark ----- DriverParameterIterator ----- // Delegate -class DriverParameterIterator::Delegate : public Referenceable { +class DriverParameterIterator::Delegate : public BReferenceable { public: - Delegate() : Referenceable(true) {} + Delegate() : BReferenceable() {} virtual ~Delegate() {} virtual Delegate* Clone() const = 0; @@ -94,10 +94,10 @@ void DriverParameterIterator::_SetTo(Delegate* delegate, bool addReference) { if (fDelegate) - fDelegate->RemoveReference(); + fDelegate->ReleaseReference(); fDelegate = delegate; if (fDelegate && addReference) - fDelegate->AddReference(); + fDelegate->AcquireReference(); } diff --git a/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp b/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp index 9ec89f348e..fff75d0950 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp @@ -90,7 +90,7 @@ UnixEndpoint::Uninit() Close(); } - RemoveReference(); + ReleaseReference(); } @@ -115,7 +115,7 @@ UnixEndpoint::Close() TRACE("[%ld] %p->UnixEndpoint::Close()\n", find_thread(NULL), this); UnixEndpointLocker locker(this); - + if (fState == UNIX_ENDPOINT_CONNECTED) { UnixEndpointLocker peerLocker; if (_LockConnectedEndpoints(locker, peerLocker) == B_OK) { @@ -317,7 +317,7 @@ UnixEndpoint::Connect(const struct sockaddr *_address) UnixEndpoint* listeningEndpoint = gAddressManager.Lookup(unixAddress); if (listeningEndpoint == NULL) RETURN_ERROR(ECONNREFUSED); - Reference peerReference(listeningEndpoint); + BReference peerReference(listeningEndpoint); addressLocker.Unlock(); UnixEndpointLocker peerLocker(listeningEndpoint); @@ -359,7 +359,7 @@ UnixEndpoint::Connect(const struct sockaddr *_address) fPeerEndpoint = connectedEndpoint; PeerAddress().SetTo(&connectedEndpoint->socket->address); - fPeerEndpoint->AddReference(); + fPeerEndpoint->AcquireReference(); fReceiveFifo = fifo; fCredentials.pid = getpid(); @@ -433,7 +433,7 @@ UnixEndpoint::Send(const iovec *vecs, size_t vecCount, UnixEndpointLocker locker(this); - Reference peerReference; + BReference peerReference; UnixEndpointLocker peerLocker; status_t error = _LockConnectedEndpoints(locker, peerLocker); @@ -445,7 +445,7 @@ UnixEndpoint::Send(const iovec *vecs, size_t vecCount, // lock the peer's FIFO UnixFifo* peerFifo = peerEndpoint->fReceiveFifo; - Reference _(peerFifo); + BReference _(peerFifo); UnixFifoLocker fifoLocker(peerFifo); // unlock endpoints @@ -530,7 +530,7 @@ UnixEndpoint::Receive(const iovec *vecs, size_t vecCount, RETURN_ERROR(ENOTCONN); UnixEndpoint* peerEndpoint = fPeerEndpoint; - Reference peerReference(peerEndpoint); + BReference peerReference(peerEndpoint); // Copy the peer address upfront. This way, if we read something, we don't // get into a potential race with Close(). @@ -542,7 +542,7 @@ UnixEndpoint::Receive(const iovec *vecs, size_t vecCount, // lock our FIFO UnixFifo* fifo = fReceiveFifo; - Reference _(fifo); + BReference _(fifo); UnixFifoLocker fifoLocker(fifo); // unlock endpoint @@ -742,7 +742,7 @@ UnixEndpoint::_Spawn(UnixEndpoint* connectingEndpoint, fIsChild = true; fPeerEndpoint = connectingEndpoint; - fPeerEndpoint->AddReference(); + fPeerEndpoint->AcquireReference(); fReceiveFifo = fifo; @@ -769,7 +769,7 @@ UnixEndpoint::_Disconnect() gSocketModule->notify(socket, B_SELECT_WRITE, ECONNRESET); // Unset the peer endpoint. - fPeerEndpoint->RemoveReference(); + fPeerEndpoint->ReleaseReference(); fPeerEndpoint = NULL; // We're officially disconnected. @@ -788,7 +788,7 @@ UnixEndpoint::_LockConnectedEndpoints(UnixEndpointLocker& locker, // We need to lock the peer, too. Get a reference -- we might need to // unlock ourselves to get the locking order right. - Reference peerReference(fPeerEndpoint); + BReference peerReference(fPeerEndpoint); UnixEndpoint* peerEndpoint = fPeerEndpoint; if (fIsChild) { @@ -852,7 +852,7 @@ void UnixEndpoint::_UnsetReceiveFifo() { if (fReceiveFifo) { - fReceiveFifo->RemoveReference(); + fReceiveFifo->ReleaseReference(); fReceiveFifo = NULL; } } diff --git a/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h b/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h index fb1bc96d86..5e09fb022f 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h +++ b/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h @@ -38,7 +38,7 @@ typedef AutoLocker UnixEndpointLocker; class UnixEndpoint : public net_protocol, public ProtocolSocket, - public Referenceable { + public BReferenceable { public: UnixEndpoint(net_socket* socket); virtual ~UnixEndpoint(); diff --git a/src/add-ons/kernel/network/protocols/unix/UnixFifo.h b/src/add-ons/kernel/network/protocols/unix/UnixFifo.h index cf71655fe1..80935ef87c 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixFifo.h +++ b/src/add-ons/kernel/network/protocols/unix/UnixFifo.h @@ -84,7 +84,7 @@ private: }; -class UnixFifo : public Referenceable { +class UnixFifo : public BReferenceable { public: UnixFifo(size_t capacity); ~UnixFifo(); diff --git a/src/add-ons/kernel/network/stack/interfaces.h b/src/add-ons/kernel/network/stack/interfaces.h index 2640b063ca..f8761289f7 100644 --- a/src/add-ons/kernel/network/stack/interfaces.h +++ b/src/add-ons/kernel/network/stack/interfaces.h @@ -30,7 +30,7 @@ struct net_device_interface; struct InterfaceAddress : DoublyLinkedListLinkImpl, - net_interface_address, Referenceable { + net_interface_address, BReferenceable { InterfaceAddress(); InterfaceAddress(net_interface* interface, net_domain* domain); @@ -112,7 +112,7 @@ typedef BOpenHashTable DatalinkTable; class Interface : public DoublyLinkedListLinkImpl, - public net_interface, public Referenceable { + public net_interface, public BReferenceable { public: Interface(const char* name, net_device_interface* deviceInterface); diff --git a/src/system/kernel/Notifications.cpp b/src/system/kernel/Notifications.cpp index 8ffb62198e..70ca761c61 100644 --- a/src/system/kernel/Notifications.cpp +++ b/src/system/kernel/Notifications.cpp @@ -504,7 +504,7 @@ NotificationManager::RegisterService(NotificationService& service) status_t status = fServiceHash.Insert(&service); if (status == B_OK) - service.AddReference(); + service.AcquireReference(); return status; } @@ -515,7 +515,7 @@ NotificationManager::UnregisterService(NotificationService& service) { MutexLocker _(fLock); fServiceHash.Remove(&service); - service.RemoveReference(); + service.ReleaseReference(); } @@ -541,7 +541,7 @@ NotificationManager::AddListener(const char* serviceName, if (service == NULL) return B_NAME_NOT_FOUND; - Reference reference(service); + BReference reference(service); locker.Unlock(); return service->AddListener(eventSpecifier, listener); @@ -570,7 +570,7 @@ NotificationManager::UpdateListener(const char* serviceName, if (service == NULL) return B_NAME_NOT_FOUND; - Reference reference(service); + BReference reference(service); locker.Unlock(); return service->UpdateListener(eventSpecifier, listener); @@ -586,7 +586,7 @@ NotificationManager::RemoveListener(const char* serviceName, if (service == NULL) return B_NAME_NOT_FOUND; - Reference reference(service); + BReference reference(service); locker.Unlock(); return service->RemoveListener(eventSpecifier, listener); diff --git a/src/system/kernel/debug/system_profiler.cpp b/src/system/kernel/debug/system_profiler.cpp index 7420de9d20..7a6d34f018 100644 --- a/src/system/kernel/debug/system_profiler.cpp +++ b/src/system/kernel/debug/system_profiler.cpp @@ -50,7 +50,7 @@ static SystemProfiler* sProfiler = NULL; static struct system_profiler_parameters* sRecordedParameters = NULL; -class SystemProfiler : public Referenceable, private NotificationListener, +class SystemProfiler : public BReferenceable, private NotificationListener, private SchedulerListener, private WaitObjectListener { public: SystemProfiler(team_id team, @@ -611,7 +611,7 @@ SystemProfiler::EventOccurred(NotificationService& service, sProfiler = NULL; locker.Unlock(); - RemoveReference(); + ReleaseReference(); return; } @@ -1474,7 +1474,7 @@ stop_system_profiler() sProfiler = NULL; locker.Unlock(); - profiler->RemoveReference(); + profiler->ReleaseReference(); } @@ -1558,7 +1558,7 @@ _user_system_profiler_next_buffer(size_t bytesRead, uint64* _droppedEvents) // get a reference to the profiler SystemProfiler* profiler = sProfiler; - Reference reference(profiler); + BReference reference(profiler); locker.Unlock(); uint64 droppedEvents; @@ -1584,7 +1584,7 @@ _user_system_profiler_stop() sProfiler = NULL; locker.Unlock(); - profiler->RemoveReference(); + profiler->ReleaseReference(); return B_OK; }