Made the (BHandler*, BLooper*,) constructor more robust. Now the looper list is locked and the looper checked for validity.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3581 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
adf43596d6
commit
37faaaded5
@ -47,6 +47,7 @@
|
|||||||
// Project Includes ------------------------------------------------------------
|
// Project Includes ------------------------------------------------------------
|
||||||
#include <AppMisc.h>
|
#include <AppMisc.h>
|
||||||
#include <MessageUtils.h>
|
#include <MessageUtils.h>
|
||||||
|
#include "ObjectLocker.h"
|
||||||
#include "TokenSpace.h"
|
#include "TokenSpace.h"
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
// Local Includes --------------------------------------------------------------
|
||||||
@ -56,6 +57,9 @@
|
|||||||
// Globals ---------------------------------------------------------------------
|
// Globals ---------------------------------------------------------------------
|
||||||
|
|
||||||
using BPrivate::gDefaultTokens;
|
using BPrivate::gDefaultTokens;
|
||||||
|
using BPrivate::gLooperList;
|
||||||
|
using BPrivate::BLooperList;
|
||||||
|
using BPrivate::BObjectLocker;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NOT_IMPLEMENTED = B_ERROR,
|
NOT_IMPLEMENTED = B_ERROR,
|
||||||
@ -131,23 +135,17 @@ BMessenger::BMessenger(const BHandler *handler, const BLooper *looper,
|
|||||||
if (looper == NULL)
|
if (looper == NULL)
|
||||||
error = B_MISMATCHED_VALUES;
|
error = B_MISMATCHED_VALUES;
|
||||||
}
|
}
|
||||||
// set port, token,...
|
|
||||||
if (error == B_OK) {
|
|
||||||
fPort = looper->fMsgPort;
|
|
||||||
fHandlerToken = _get_object_token_(handler);
|
|
||||||
fPreferredTarget = false;
|
|
||||||
}
|
|
||||||
} else { // handler == NULL (=> looper != NULL)
|
|
||||||
fPort = looper->fMsgPort;
|
|
||||||
fHandlerToken = false;
|
|
||||||
fPreferredTarget = true;
|
|
||||||
}
|
}
|
||||||
// get and set the team ID
|
// set port, token,...
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
thread_info info;
|
BObjectLocker<BLooperList> locker(gLooperList);
|
||||||
error = get_thread_info(find_thread(NULL), &info);
|
if (locker.IsLocked() && gLooperList.IsLooperValid(looper)) {
|
||||||
if (error == B_OK)
|
fPort = looper->fMsgPort;
|
||||||
fTeam = info.team;
|
fHandlerToken = (handler ? _get_object_token_(handler) : -1);
|
||||||
|
fPreferredTarget = !handler;
|
||||||
|
fTeam = looper->Team();
|
||||||
|
} else
|
||||||
|
error = B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
|
Loading…
Reference in New Issue
Block a user