From 9707863cc947e4665f8e302e9781193f83eb5861 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 28 Feb 2005 00:37:16 +0000 Subject: [PATCH] * Changes due to new team debug info locking strategy. * In team_delete_team() we no longer explicitly destroy the team debug info. It is not necessary, since the terminating debug nub thread will do that anyway. Moreover we access the debugger port in a safer manner now. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11504 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/team.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/kernel/core/team.c b/src/kernel/core/team.c index d32c663671..1ad774344f 100644 --- a/src/kernel/core/team.c +++ b/src/kernel/core/team.c @@ -689,7 +689,7 @@ create_team_struct(const char *name, bool kernel) list_init(&team->image_list); - clear_team_debug_info(&team->debug_info); + clear_team_debug_info(&team->debug_info, true); if (arch_team_init_team_struct(team, kernel) < 0) goto error2; @@ -747,12 +747,8 @@ team_remove_team(struct team *team, struct process_group **_freeGroup) void team_delete_team(struct team *team) { - // if the team was being debugged, stop that now team_id teamID = team->id; - port_id debuggerPort - = (team->debug_info.flags & B_TEAM_DEBUG_DEBUGGER_INSTALLED - ? team->debug_info.debugger_port : -1); - destroy_team_debug_info(&team->debug_info); + port_id debuggerPort = -1; if (team->num_threads > 0) { // there are other threads still in this team, @@ -769,6 +765,19 @@ team_delete_team(struct team *team) state = disable_interrupts(); GRAB_TEAM_LOCK(); + + // If the team was being debugged, that will stop with the termination + // of the nub thread. The team structure has already been removed from + // the team hash table at this point, so noone can install a debugger + // anymore. We fetch the debugger's port to send it a message at the + // bitter end. + GRAB_TEAM_DEBUG_INFO_LOCK(team->debug_info); + + if (team->debug_info.flags & B_TEAM_DEBUG_DEBUGGER_INSTALLED) + debuggerPort = team->debug_info.debugger_port; + + RELEASE_TEAM_DEBUG_INFO_LOCK(team->debug_info); + // we can safely walk the list because of the lock. no new threads can be created // because of the TEAM_STATE_DEATH flag on the team temp_thread = team->thread_list;