Move the actual area deletion out of the locked section as we could otherwise

double/deadlock when we delete heap areas because of other area deletions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36284 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2010-04-15 11:13:16 +00:00
parent 7380abeb44
commit fdad233b47

View File

@ -1711,18 +1711,27 @@ heap_free(heap_allocator *heap, void *address)
WriteLocker areaWriteLocker(heap->area_lock);
MutexLocker pageLocker(heap->page_lock);
area_id areasToDelete[heap->empty_areas - 1];
int32 areasToDeleteIndex = 0;
area = heap->areas;
while (area != NULL && heap->empty_areas > 1) {
heap_area *next = area->next;
if (area->area >= 0
&& area->free_page_count == area->page_count
&& heap_remove_area(heap, area) == B_OK) {
delete_area(area->area);
areasToDelete[areasToDeleteIndex++] = area->area;
heap->empty_areas--;
}
area = next;
}
pageLocker.Unlock();
areaWriteLocker.Unlock();
for (int32 i = 0; i < areasToDeleteIndex; i++)
delete_area(areasToDelete[i]);
}
return B_OK;