The app_server now cleans up better after a team crashed; not only the

application and bitmaps are removed, the team's windows are now removed
as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13251 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-06-23 23:21:10 +00:00
parent d2e5d36050
commit 1b53e8af26
3 changed files with 51 additions and 2 deletions
+43
View File
@@ -46,6 +46,7 @@
#include <stdio.h>
#include <string.h>
#include <syslog.h>
//#define DEBUG_SERVERAPP
@@ -136,6 +137,48 @@ ServerApp::~ServerApp(void)
if (!fQuitting)
CRITICAL("ServerApp: destructor called after Run()!\n");
fWindowListLock.Lock();
// quit all server windows
for (int32 i = fWindowList.CountItems(); i-- > 0;) {
ServerWindow* window = (ServerWindow*)fWindowList.ItemAt(i);
window->Quit();
}
int32 tries = fWindowList.CountItems() + 1;
fWindowListLock.Unlock();
// wait for the windows to quit
while (tries-- > 0) {
fWindowListLock.Lock();
if (fWindowList.CountItems() == 0) {
// we leave the list locked, doesn't matter anymore
break;
}
fWindowListLock.Unlock();
snooze(10000);
}
if (tries < 0) {
// This really shouldn't happen, as it shows we're buggy
syslog(LOG_ERR, "ServerApp %s needs to kill some server windows...\n", Signature());
// there still seem to be some windows left - kill them!
fWindowListLock.Lock();
for (int32 i = 0; i < fWindowList.CountItems(); i++) {
ServerWindow* window = (ServerWindow*)fWindowList.ItemAt(i);
kill_thread(window->Thread());
window->Hide();
delete window;
}
fWindowListLock.Unlock();
}
// first, make sure our monitor thread doesn't
for (int32 i = 0; i < fBitmapList.CountItems(); i++) {
delete static_cast<ServerBitmap *>(fBitmapList.ItemAt(i));
+7 -2
View File
@@ -80,6 +80,7 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app,
fMessagePort(-1),
fClientReplyPort(clientPort),
fClientLooperPort(looperPort),
fQuitting(false),
fClientViewsWithInvalidCoords(B_VIEW_RESIZED),
fHandlerToken(handlerID),
fCurrentLayer(NULL)
@@ -160,6 +161,8 @@ ServerWindow::Run()
void
ServerWindow::Quit()
{
fQuitting = true;
if (fThread < B_OK) {
delete this;
return;
@@ -170,8 +173,10 @@ ServerWindow::Quit()
delete this;
exit_thread(0);
} else
} else {
PostMessage(AS_HIDE_WINDOW);
PostMessage(kMsgWindowQuit);
}
}
@@ -206,7 +211,7 @@ ServerWindow::Show()
// NOTE: if you do something else, other than sending a port message, PLEASE lock
STRACE(("ServerWindow %s: Show\n", Title()));
if (!fWinBorder->IsHidden())
if (fQuitting || !fWinBorder->IsHidden())
return;
fWinBorder->GetRootLayer()->ShowWinBorder(fWinBorder);
+1
View File
@@ -141,6 +141,7 @@ private:
port_id fClientLooperPort;
BPrivate::PortLink fLink;
bool fQuitting;
BMessage fClientViewsWithInvalidCoords;