From a99e2783086ea4e11cc974bba456d6ce6384f621 Mon Sep 17 00:00:00 2001 From: beveloper Date: Mon, 6 Jan 2003 14:23:20 +0000 Subject: [PATCH] added cleanup of dead nodes. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2370 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/media/NodeManager.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/servers/media/NodeManager.cpp b/src/servers/media/NodeManager.cpp index 0e5a813525..29fda11d83 100644 --- a/src/servers/media/NodeManager.cpp +++ b/src/servers/media/NodeManager.cpp @@ -614,8 +614,36 @@ void NodeManager::CleanupTeam(team_id team) { BAutolock lock(fLocker); - FATAL("NodeManager::CleanupTeam: should cleanup team %ld\n", team); + fDefaultManager->CleanupTeam(team); + + FATAL("NodeManager::CleanupTeam: team %ld\n", team); + + registered_node *rn; + for (fRegisteredNodeMap->Rewind(); fRegisteredNodeMap->GetNext(&rn); ) { + // if the team hosting this node is gone, remove node from database + if (rn->team == team) { + FATAL("NodeManager::CleanupTeam: removing node id %ld, team %ld\n", rn->nodeid, team); + fRegisteredNodeMap->RemoveCurrent(); + continue; + } + // check the list of teams that have references to this node, and remove the team + team_id *pteam; + int32 *prefcount; + for (rn->teamrefcount.Rewind(); rn->teamrefcount.GetNext(&prefcount); ) { + rn->teamrefcount.GetCurrentKey(&pteam); + if (*pteam == team) { + FATAL("NodeManager::CleanupTeam: removing %ld refs from node id %ld, team %ld\n", *prefcount, rn->nodeid, team); + rn->teamrefcount.RemoveCurrent(); + break; + } + } + // if the team refcount is now empty, also remove the node + if (rn->teamrefcount.IsEmpty()) { + FATAL("NodeManager::CleanupTeam: removing node id %ld that has no teams\n", rn->nodeid); + fRegisteredNodeMap->RemoveCurrent(); + } + } } status_t