From 9e518ee91d7d78dec4d33aeff67f63ee721c34da Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 1 May 2008 21:53:12 +0000 Subject: [PATCH] Also hold the threads lock when removing a team from the team hash table. This is not necessary, but allows for a better solution fo how to lock the IO context of another team. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25281 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/team.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 6867065d57..27265ebbfe 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -2159,7 +2159,14 @@ team_remove_team(struct team *team) parent->dead_children->user_time += team->dead_threads_user_time + team->dead_children->user_time; + // Also grab the thread spinlock while removing the team from the hash. + // This makes the following sequence safe: grab teams lock, lookup team, + // grab threads lock, unlock teams lock, + // mutex_lock_threads_lock(), as used in the VFS code to + // lock another team's IO context. + GRAB_THREAD_LOCK(); hash_remove(sTeamHash, team); + RELEASE_THREAD_LOCK(); sUsedTeams--; team->state = TEAM_STATE_DEATH;