kernel/image: Report image removals on team destruction or exec.
We can't call user_debug_image_deleted with the lock held, so clear the list and remove all images before unlocking and looping again. This also means we free() without the lock held, which should reduce contention.
This commit is contained in:
@@ -210,20 +210,28 @@ count_images(Team *team)
|
||||
status_t
|
||||
remove_images(Team *team)
|
||||
{
|
||||
struct image *image;
|
||||
struct image *image = NULL;
|
||||
|
||||
ASSERT(team != NULL);
|
||||
|
||||
mutex_lock(&sImageMutex);
|
||||
|
||||
while ((image = (struct image*)list_remove_head_item(&team->image_list))
|
||||
!= NULL) {
|
||||
struct list images = {};
|
||||
list_move_to_list(&team->image_list, &images);
|
||||
while ((image = (struct image*)list_get_next_item(&images,
|
||||
image)) != NULL) {
|
||||
sImageTable->Remove(image);
|
||||
free(image);
|
||||
}
|
||||
|
||||
mutex_unlock(&sImageMutex);
|
||||
|
||||
while ((image = (struct image*)list_remove_head_item(&images))
|
||||
!= NULL) {
|
||||
user_debug_image_deleted(&image->info.basic_info);
|
||||
sNotificationService.Notify(IMAGE_REMOVED, image);
|
||||
free(image);
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user