From 7c6865642c9d63f98875742a47e9f28b281f3653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 25 Nov 2005 21:06:37 +0000 Subject: [PATCH] * Don't trust a message that we got goes to a handler that belongs to us. * when we terminate gracefully and in the looper's thread, we no longer unlock ourselves. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15155 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Looper.cpp | 9 +++++++++ src/kits/interface/Window.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/kits/app/Looper.cpp b/src/kits/app/Looper.cpp index b69e0a7746..8121a02b95 100644 --- a/src/kits/app/Looper.cpp +++ b/src/kits/app/Looper.cpp @@ -1250,6 +1250,10 @@ BLooper::task_looper() gDefaultTokens.GetToken(messagePrivate.GetTarget(), B_HANDLER_TOKEN, (void **)&handler); + // if this handler doesn't belong to us, we drop the message + if (handler != NULL && handler->Looper() != this) + handler = NULL; + PRINT(("LOOPER: use %ld, handler: %p, this: %p\n", messagePrivate.GetTarget(), handler, this)); } @@ -1271,6 +1275,11 @@ BLooper::task_looper() } } + if (fTerminating) { + // we leave the looper locked when we quit + return; + } + // Unlock the looper Unlock(); diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 6c47db0abc..85128b6893 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -2248,6 +2248,10 @@ BWindow::task_looper() } else { gDefaultTokens.GetToken(messagePrivate.GetTarget(), B_HANDLER_TOKEN, (void **)&handler); + + // if this handler doesn't belong to us, we drop the message + if (handler != NULL && handler->Looper() != this) + handler = NULL; } if (handler == NULL || usePreferred) @@ -2280,6 +2284,11 @@ BWindow::task_looper() } } + if (fTerminating) { + // we leave the looper locked when we quit + return; + } + Unlock(); // Are any messages on the port?