From c9299b3ce8698ba0b2e2d00f0547b26b6181cd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 6 Jul 2005 04:57:57 +0000 Subject: [PATCH] Instead of killing the ServerApps the hard way, the AppServer now quits them if they didn't listen to B_QUIT_REQUESTED. This works much better as how it was done before. Now uses exit() instead of exit_thread() which makes sure no thread survives. Note, there still is a race condition in case an application quits immediately before shutting down the server - in that case, it doesn't participate in the fShutdownSemaphore stuff, and therefore, the app_server could quit it too early. Maybe I'll fix that one day, as well :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13481 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/AppServer.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/servers/app/AppServer.cpp b/src/servers/app/AppServer.cpp index 115ed52e3c..f92ad9b6f4 100644 --- a/src/servers/app/AppServer.cpp +++ b/src/servers/app/AppServer.cpp @@ -560,17 +560,24 @@ AppServer::DispatchMessage(int32 code, BPrivate::PortLink &msg) break; case kMsgShutdownServer: + { // let's kill all remaining applications fAppListLock.Lock(); - for (int32 i = 0; i < fAppList.CountItems(); i++) { + int32 count = fAppList.CountItems(); + for (int32 i = 0; i < count; i++) { ServerApp *app = (ServerApp*)fAppList.ItemAt(i); + team_id clientTeam = app->ClientTeam(); - kill_thread(app->Thread()); - kill_team(app->ClientTeam()); + app->Quit(); + kill_team(clientTeam); } + // wait for the last app to die + if (count > 0) + acquire_sem_etc(fShutdownSemaphore, fShutdownCount, B_RELATIVE_TIMEOUT, 250000); + kill_thread(fPicassoThreadID); fAppListLock.Unlock(); @@ -580,8 +587,9 @@ AppServer::DispatchMessage(int32 code, BPrivate::PortLink &msg) delete gFontServer; // we are now clear to exit - exit_thread(0); + exit(0); break; + } #endif case AS_SET_SYSCURSOR_DEFAULTS: