* 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
This commit is contained in:
Michael Lotz
2009-08-22 03:07:11 +00:00
parent 8e8130d1f0
commit f1a7a3752f
+8 -11
View File
@@ -1282,6 +1282,7 @@ load_image_internal(char**& _flatArgs, size_t flatArgsSize, int32 argCount,
return thread; return thread;
err5: err5:
sNotificationService.Notify(TEAM_REMOVED, team);
delete_team_user_data(team); delete_team_user_data(team);
err4: err4:
vm_put_address_space(team->address_space); vm_put_address_space(team->address_space);
@@ -1490,7 +1491,6 @@ fork_team(void)
struct fork_arg *forkArgs; struct fork_arg *forkArgs;
struct area_info info; struct area_info info;
thread_id threadID; thread_id threadID;
cpu_status state;
status_t status; status_t status;
int32 cookie; int32 cookie;
@@ -1509,19 +1509,17 @@ fork_team(void)
strlcpy(team->args, parentTeam->args, sizeof(team->args)); strlcpy(team->args, parentTeam->args, sizeof(team->args));
// Inherit the parent's user/group. InterruptsSpinLocker teamLocker(gTeamSpinlock);
inherit_parent_user_and_group(team, parentTeam);
state = disable_interrupts(); // Inherit the parent's user/group.
GRAB_TEAM_LOCK(); inherit_parent_user_and_group_locked(team, parentTeam);
hash_insert(sTeamHash, team); hash_insert(sTeamHash, team);
insert_team_into_parent(parentTeam, team); insert_team_into_parent(parentTeam, team);
insert_team_into_group(parentTeam->group, team); insert_team_into_group(parentTeam->group, team);
sUsedTeams++; sUsedTeams++;
RELEASE_TEAM_LOCK(); teamLocker.Unlock();
restore_interrupts(state);
forkArgs = (struct fork_arg *)malloc(sizeof(struct fork_arg)); forkArgs = (struct fork_arg *)malloc(sizeof(struct fork_arg));
if (forkArgs == NULL) { if (forkArgs == NULL) {
@@ -1635,6 +1633,7 @@ fork_team(void)
return threadID; return threadID;
err5: err5:
sNotificationService.Notify(TEAM_REMOVED, team);
remove_images(team); remove_images(team);
err4: err4:
vm_delete_address_space(team->address_space); vm_delete_address_space(team->address_space);
@@ -1646,15 +1645,13 @@ err2:
free(forkArgs); free(forkArgs);
err1: err1:
// remove the team structure from the team hash table and delete the team structure // remove the team structure from the team hash table and delete the team structure
state = disable_interrupts(); teamLocker.Lock();
GRAB_TEAM_LOCK();
remove_team_from_group(team); remove_team_from_group(team);
remove_team_from_parent(parentTeam, team); remove_team_from_parent(parentTeam, team);
hash_remove(sTeamHash, team); hash_remove(sTeamHash, team);
RELEASE_TEAM_LOCK(); teamLocker.Unlock();
restore_interrupts(state);
delete_team_struct(team); delete_team_struct(team);