[haiku-commits] r39741 - haiku/trunk/src/servers/input

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 5 Dec 2010 16:03:11 +0100 (CET)

Author: stippi
Date: 2010-12-05 16:03:11 +0100 (Sun, 05 Dec 2010)
New Revision: 39741
Changeset: http://dev.haiku-os.org/changeset/39741

Modified:
   haiku/trunk/src/servers/input/AddOnManager.cpp
   haiku/trunk/src/servers/input/AddOnManager.h
Log:
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.


Modified: haiku/trunk/src/servers/input/AddOnManager.cpp
===================================================================
--- haiku/trunk/src/servers/input/AddOnManager.cpp      2010-12-05 14:59:27 UTC 
(rev 39740)
+++ haiku/trunk/src/servers/input/AddOnManager.cpp      2010-12-05 15:03:11 UTC 
(rev 39741)
@@ -123,14 +123,17 @@
 
 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 @@
                        return;
 
                default:
+                       AddOnMonitor::MessageReceived(message);
                        return;
        }
 
@@ -255,18 +259,7 @@
 {
        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,
                B_COMMON_ADDONS_DIRECTORY,
@@ -302,13 +295,6 @@
 {
        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 @@
        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;

Modified: haiku/trunk/src/servers/input/AddOnManager.h
===================================================================
--- haiku/trunk/src/servers/input/AddOnManager.h        2010-12-05 14:59:27 UTC 
(rev 39740)
+++ haiku/trunk/src/servers/input/AddOnManager.h        2010-12-05 15:03:11 UTC 
(rev 39741)
@@ -25,7 +25,7 @@
 
 using namespace BPrivate;
 
-class AddOnManager : public BLooper {
+class AddOnManager : public AddOnMonitor {
 public:
                                                                
AddOnManager(bool safeMode);
                                                                ~AddOnManager();
@@ -122,9 +122,8 @@
                        PathList                        fDevicePaths;
 
                        MonitorHandler*         fHandler;
-                       AddOnMonitor*           fAddOnMonitor;
 
-                       bool fSafeMode;
+                       bool                            fSafeMode;
 };
 
 #endif // ADD_ON_MANAGER_H


Other related posts:

  • » [haiku-commits] r39741 - haiku/trunk/src/servers/input - superstippi