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:
Augustin Cavalier
2024-07-17 13:40:16 -04:00
parent 10a7c77a3a
commit 2b916f6121
+12 -4
View File
@@ -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;
}