Eliminate the second add-on monitor looper by inheriting AddOnManger
from AddOnMonitor. This solves a concurrency problem in the AddOnMonitorHandler implementation which called into AddOnManager private methods on the wrong looper thread without locking. Would have corrupted memory when unplugging input devices during input_server initialization (so normally not encountered). The code paths for adding devices were locking already, since those can be called from other threads as well and this was anticipated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39741 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
445751e17a
commit
509a3787b1
|
@ -123,14 +123,17 @@ instantiate_add_on(image_id image, const char* path, const char* type)
|
|||
|
||||
AddOnManager::AddOnManager(bool safeMode)
|
||||
:
|
||||
BLooper("add-on manager"),
|
||||
AddOnMonitor(),
|
||||
fHandler(new(std::nothrow) MonitorHandler(this)),
|
||||
fSafeMode(safeMode)
|
||||
{
|
||||
SetHandler(fHandler);
|
||||
}
|
||||
|
||||
|
||||
AddOnManager::~AddOnManager()
|
||||
{
|
||||
delete fHandler;
|
||||
}
|
||||
|
||||
|
||||
|
@ -175,6 +178,7 @@ AddOnManager::MessageReceived(BMessage* message)
|
|||
return;
|
||||
|
||||
default:
|
||||
AddOnMonitor::MessageReceived(message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -255,17 +259,6 @@ AddOnManager::_RegisterAddOns()
|
|||
{
|
||||
CALLED();
|
||||
BAutolock locker(this);
|
||||
status_t err;
|
||||
|
||||
fHandler = new MonitorHandler(this);
|
||||
fAddOnMonitor = new AddOnMonitor(fHandler);
|
||||
|
||||
err = fAddOnMonitor->InitCheck();
|
||||
if (err != B_OK) {
|
||||
ERROR("AddOnManager::RegisterAddOns(): fAddOnMonitor->InitCheck() "
|
||||
"returned %s\n", strerror(err));
|
||||
return;
|
||||
}
|
||||
|
||||
const directory_which directories[] = {
|
||||
B_USER_ADDONS_DIRECTORY,
|
||||
|
@ -302,13 +295,6 @@ AddOnManager::_UnregisterAddOns()
|
|||
{
|
||||
BAutolock locker(this);
|
||||
|
||||
BMessenger messenger(fAddOnMonitor);
|
||||
messenger.SendMessage(B_QUIT_REQUESTED);
|
||||
int32 exitValue;
|
||||
wait_for_thread(fAddOnMonitor->Thread(), &exitValue);
|
||||
delete fHandler;
|
||||
fHandler = NULL;
|
||||
|
||||
// We have to stop manually the add-ons because the monitor doesn't
|
||||
// disable them on exit
|
||||
|
||||
|
@ -624,9 +610,9 @@ AddOnManager::_LoadReplicant()
|
|||
be_app->GetAppInfo(&info);
|
||||
|
||||
status_t err = BDeskbar().AddItem(&info.ref);
|
||||
if (err != B_OK) {
|
||||
if (err != B_OK)
|
||||
ERROR("Deskbar refuses to add method replicant: %s\n", strerror(err));
|
||||
}
|
||||
|
||||
BMessage request(B_GET_PROPERTY);
|
||||
BMessenger to;
|
||||
BMessenger status;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
using namespace BPrivate;
|
||||
|
||||
class AddOnManager : public BLooper {
|
||||
class AddOnManager : public AddOnMonitor {
|
||||
public:
|
||||
AddOnManager(bool safeMode);
|
||||
~AddOnManager();
|
||||
|
@ -122,9 +122,8 @@ private:
|
|||
PathList fDevicePaths;
|
||||
|
||||
MonitorHandler* fHandler;
|
||||
AddOnMonitor* fAddOnMonitor;
|
||||
|
||||
bool fSafeMode;
|
||||
bool fSafeMode;
|
||||
};
|
||||
|
||||
#endif // ADD_ON_MANAGER_H
|
||||
|
|
Loading…
Reference in New Issue