Fix for bug 6991, replace registrars timer tick
Registrar schedules an event every second to do fRoster-CheckSanity(). This uses 2.5% cpu on my machine when idle. Changing it to five seconds lowers it to 0.1% waddlesplash then pointed me to this bug which changes it to watch for team deletion and call fRoster->CheckSanity() As I know little in this area, it's mostly based on what LaunchDaemon does in MessageRecieved. Change-Id: Ie69f9399cab41d2d492d469b5d3dc88e6080c15c Reviewed-on: https://review.haiku-os.org/c/876 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
f290b76670
commit
9edb207fab
@ -96,7 +96,6 @@ enum {
|
|||||||
B_REG_GET_MESSAGE_RUNNER_INFO = 'rgri',
|
B_REG_GET_MESSAGE_RUNNER_INFO = 'rgri',
|
||||||
|
|
||||||
// internal registrar messages
|
// internal registrar messages
|
||||||
B_REG_ROSTER_SANITY_EVENT = 'rgir',
|
|
||||||
B_REG_SHUTDOWN_FINISHED = 'rgsf',
|
B_REG_SHUTDOWN_FINISHED = 'rgsf',
|
||||||
B_REG_ROSTER_DEVICE_RESCAN = 'rgrs',
|
B_REG_ROSTER_DEVICE_RESCAN = 'rgrs',
|
||||||
|
|
||||||
|
@ -16,9 +16,11 @@
|
|||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Clipboard.h>
|
#include <Clipboard.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <MessengerPrivate.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <RegistrarDefs.h>
|
#include <RegistrarDefs.h>
|
||||||
#include <RosterPrivate.h>
|
#include <RosterPrivate.h>
|
||||||
|
#include <system_info.h>
|
||||||
|
|
||||||
#include "AuthenticationManager.h"
|
#include "AuthenticationManager.h"
|
||||||
#include "ClipboardHandler.h"
|
#include "ClipboardHandler.h"
|
||||||
@ -47,9 +49,6 @@ using namespace BPrivate;
|
|||||||
//! Name of the event queue.
|
//! Name of the event queue.
|
||||||
static const char *kEventQueueName = "timer_thread";
|
static const char *kEventQueueName = "timer_thread";
|
||||||
|
|
||||||
//! Time interval between two roster sanity checks (1 s).
|
|
||||||
static const bigtime_t kRosterSanityEventInterval = 1000000LL;
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Creates the registrar application class.
|
/*! \brief Creates the registrar application class.
|
||||||
\param error Passed to the BApplication constructor for returning an
|
\param error Passed to the BApplication constructor for returning an
|
||||||
@ -63,7 +62,6 @@ Registrar::Registrar(status_t* _error)
|
|||||||
fMIMEManager(NULL),
|
fMIMEManager(NULL),
|
||||||
fEventQueue(NULL),
|
fEventQueue(NULL),
|
||||||
fMessageRunnerManager(NULL),
|
fMessageRunnerManager(NULL),
|
||||||
fSanityEvent(NULL),
|
|
||||||
fShutdownProcess(NULL),
|
fShutdownProcess(NULL),
|
||||||
fAuthenticationManager(NULL),
|
fAuthenticationManager(NULL),
|
||||||
fPackageWatchingManager(NULL)
|
fPackageWatchingManager(NULL)
|
||||||
@ -88,7 +86,6 @@ Registrar::~Registrar()
|
|||||||
delete fPackageWatchingManager;
|
delete fPackageWatchingManager;
|
||||||
delete fMessageRunnerManager;
|
delete fMessageRunnerManager;
|
||||||
delete fEventQueue;
|
delete fEventQueue;
|
||||||
delete fSanityEvent;
|
|
||||||
fMIMEManager->Lock();
|
fMIMEManager->Lock();
|
||||||
fMIMEManager->Quit();
|
fMIMEManager->Quit();
|
||||||
RemoveHandler(fClipboardHandler);
|
RemoveHandler(fClipboardHandler);
|
||||||
@ -172,11 +169,15 @@ Registrar::ReadyToRun()
|
|||||||
// create the package watching manager
|
// create the package watching manager
|
||||||
fPackageWatchingManager = new PackageWatchingManager;
|
fPackageWatchingManager = new PackageWatchingManager;
|
||||||
|
|
||||||
// create and schedule the sanity message event
|
// Sanity check roster after team deletion
|
||||||
fSanityEvent = new MessageEvent(system_time() + kRosterSanityEventInterval,
|
BMessenger target(this);
|
||||||
this, B_REG_ROSTER_SANITY_EVENT);
|
BMessenger::Private messengerPrivate(target);
|
||||||
fSanityEvent->SetAutoDelete(false);
|
|
||||||
fEventQueue->AddEvent(fSanityEvent);
|
port_id port = messengerPrivate.Port();
|
||||||
|
int32 token = messengerPrivate.Token();
|
||||||
|
__start_watching_system(-1, B_WATCH_SYSTEM_TEAM_DELETION, port, token);
|
||||||
|
fRoster->CheckSanity();
|
||||||
|
// Clean up any teams that exited before we started watching
|
||||||
|
|
||||||
FUNCTION_END();
|
FUNCTION_END();
|
||||||
}
|
}
|
||||||
@ -352,11 +353,13 @@ Registrar::_MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// internal messages
|
// internal messages
|
||||||
case B_REG_ROSTER_SANITY_EVENT:
|
case B_SYSTEM_OBJECT_UPDATE:
|
||||||
fRoster->CheckSanity();
|
{
|
||||||
fSanityEvent->SetTime(system_time() + kRosterSanityEventInterval);
|
team_id team = (team_id)message->GetInt32("team", -1);
|
||||||
fEventQueue->AddEvent(fSanityEvent);
|
if (team >= 0 && message->GetInt32("opcode", 0) == B_TEAM_DELETED)
|
||||||
|
fRoster->HandleRemoveApp(message);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case B_REG_SHUTDOWN_FINISHED:
|
case B_REG_SHUTDOWN_FINISHED:
|
||||||
if (fShutdownProcess) {
|
if (fShutdownProcess) {
|
||||||
fShutdownProcess->PostMessage(B_QUIT_REQUESTED,
|
fShutdownProcess->PostMessage(B_QUIT_REQUESTED,
|
||||||
|
@ -64,7 +64,6 @@ private:
|
|||||||
MIMEManager *fMIMEManager;
|
MIMEManager *fMIMEManager;
|
||||||
EventQueue *fEventQueue;
|
EventQueue *fEventQueue;
|
||||||
MessageRunnerManager *fMessageRunnerManager;
|
MessageRunnerManager *fMessageRunnerManager;
|
||||||
MessageEvent *fSanityEvent;
|
|
||||||
ShutdownProcess *fShutdownProcess;
|
ShutdownProcess *fShutdownProcess;
|
||||||
AuthenticationManager *fAuthenticationManager;
|
AuthenticationManager *fAuthenticationManager;
|
||||||
PackageWatchingManager *fPackageWatchingManager;
|
PackageWatchingManager *fPackageWatchingManager;
|
||||||
|
Loading…
Reference in New Issue
Block a user