From 4f96ace6d567f266b7ce7f13eed7ed6f0a594f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 2 Apr 2013 23:38:43 +0200 Subject: [PATCH] app_server: detach client allocator on quit. * This prevents sending out notification to applications that are already gone, and should thus fix #9116 according to John. --- src/servers/app/ClientMemoryAllocator.cpp | 24 +++++++++++++++++++---- src/servers/app/ClientMemoryAllocator.h | 4 +++- src/servers/app/ServerApp.cpp | 3 ++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/servers/app/ClientMemoryAllocator.cpp b/src/servers/app/ClientMemoryAllocator.cpp index 8f3001d992..f9ec018f31 100644 --- a/src/servers/app/ClientMemoryAllocator.cpp +++ b/src/servers/app/ClientMemoryAllocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006-2012, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2013, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -66,6 +66,10 @@ ClientMemoryAllocator::~ClientMemoryAllocator() void* ClientMemoryAllocator::Allocate(size_t size, block** _address, bool& newArea) { + // A detached allocator no longer allows any further allocations + if (fApplication == NULL) + return NULL; + BAutolock locker(fLock); // Search best matching free block from the list @@ -179,18 +183,30 @@ ClientMemoryAllocator::Free(block* freeBlock) fChunks.Remove(chunk); delete_area(chunk->area); - fApplication->NotifyDeleteClientArea(chunk->area); + + if (fApplication != NULL) + fApplication->NotifyDeleteClientArea(chunk->area); free(chunk); } } +void +ClientMemoryAllocator::Detach() +{ + BAutolock locker(fLock); + fApplication = NULL; +} + + void ClientMemoryAllocator::Dump() { - debug_printf("Application %" B_PRId32 ", %s: chunks:\n", - fApplication->ClientTeam(), fApplication->Signature()); + if (fApplication != NULL) { + debug_printf("Application %" B_PRId32 ", %s: chunks:\n", + fApplication->ClientTeam(), fApplication->Signature()); + } chunk_list::Iterator iterator = fChunks.GetIterator(); int32 i = 0; diff --git a/src/servers/app/ClientMemoryAllocator.h b/src/servers/app/ClientMemoryAllocator.h index 7af6f3a0ef..05ab8df533 100644 --- a/src/servers/app/ClientMemoryAllocator.h +++ b/src/servers/app/ClientMemoryAllocator.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2013, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -43,6 +43,8 @@ public: bool& newArea); void Free(block* cookie); + void Detach(); + void Dump(); private: diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 90651ea40d..057df07912 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2012, Haiku. + * Copyright 2001-2013, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -192,6 +192,7 @@ ServerApp::~ServerApp() fWindowListLock.Lock(); } + fMemoryAllocator.Detach(); fMapLocker.Lock(); while (!fBitmapMap.empty())