Replace uses of obsolescent BReference[able] API.

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