From f1a7a3752fda65e71edcfbb15de67e0cd0859fcb Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 22 Aug 2009 03:07:11 +0000 Subject: [PATCH] * Use the locked version of inherit_parent_user_and_group() by moving the call into the scope of the lock. Saves an InterruptsSpinLocker. * Use an InterruptsSpinLocker() as in other places. * When creating/forking a team fails because the kernel thread cannot be spawned balance the already sent TEAM_ADDED notification by sending a TEAM_REMOVED one. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32595 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/team.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 2d6b66649c..a9793e5dfe 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -1282,6 +1282,7 @@ load_image_internal(char**& _flatArgs, size_t flatArgsSize, int32 argCount, return thread; err5: + sNotificationService.Notify(TEAM_REMOVED, team); delete_team_user_data(team); err4: vm_put_address_space(team->address_space); @@ -1490,7 +1491,6 @@ fork_team(void) struct fork_arg *forkArgs; struct area_info info; thread_id threadID; - cpu_status state; status_t status; int32 cookie; @@ -1509,19 +1509,17 @@ fork_team(void) strlcpy(team->args, parentTeam->args, sizeof(team->args)); - // Inherit the parent's user/group. - inherit_parent_user_and_group(team, parentTeam); + InterruptsSpinLocker teamLocker(gTeamSpinlock); - state = disable_interrupts(); - GRAB_TEAM_LOCK(); + // Inherit the parent's user/group. + inherit_parent_user_and_group_locked(team, parentTeam); hash_insert(sTeamHash, team); insert_team_into_parent(parentTeam, team); insert_team_into_group(parentTeam->group, team); sUsedTeams++; - RELEASE_TEAM_LOCK(); - restore_interrupts(state); + teamLocker.Unlock(); forkArgs = (struct fork_arg *)malloc(sizeof(struct fork_arg)); if (forkArgs == NULL) { @@ -1635,6 +1633,7 @@ fork_team(void) return threadID; err5: + sNotificationService.Notify(TEAM_REMOVED, team); remove_images(team); err4: vm_delete_address_space(team->address_space); @@ -1646,15 +1645,13 @@ err2: free(forkArgs); err1: // remove the team structure from the team hash table and delete the team structure - state = disable_interrupts(); - GRAB_TEAM_LOCK(); + teamLocker.Lock(); remove_team_from_group(team); remove_team_from_parent(parentTeam, team); hash_remove(sTeamHash, team); - RELEASE_TEAM_LOCK(); - restore_interrupts(state); + teamLocker.Unlock(); delete_team_struct(team);