launch_daemon: Use BRoster::Launch() without registrar.
* BRoster now allows settings a "no-registrar" mode that is currently only honored in _LaunchApp(), though. * Job::Launch() is now using this, which also allows launching applications by signature (ie. if the job name matches the signature, you can omit the "launch" option).
This commit is contained in:
@@ -212,6 +212,8 @@ private:
|
|||||||
const entry_ref* ref,
|
const entry_ref* ref,
|
||||||
bool readyToRun) const;
|
bool readyToRun) const;
|
||||||
|
|
||||||
|
void _SetWithoutRegistrar(bool noRegistrar);
|
||||||
|
|
||||||
void _InitMessenger();
|
void _InitMessenger();
|
||||||
|
|
||||||
static status_t _InitMimeMessenger(void* data);
|
static status_t _InitMimeMessenger(void* data);
|
||||||
@@ -229,7 +231,8 @@ private:
|
|||||||
BMessenger fMessenger;
|
BMessenger fMessenger;
|
||||||
BMessenger fMimeMessenger;
|
BMessenger fMimeMessenger;
|
||||||
int32 fMimeMessengerInitOnce;
|
int32 fMimeMessengerInitOnce;
|
||||||
uint32 _reserved[2];
|
bool fNoRegistrar;
|
||||||
|
uint32 _reserved[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
// global BRoster instance
|
// global BRoster instance
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2015, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -52,6 +52,9 @@ class BRoster::Private {
|
|||||||
{ return fRoster->_IsAppRegistered(ref, team, token, preRegistered,
|
{ return fRoster->_IsAppRegistered(ref, team, token, preRegistered,
|
||||||
info); }
|
info); }
|
||||||
|
|
||||||
|
void SetWithoutRegistrar(bool noRegistrar) const
|
||||||
|
{ fRoster->_SetWithoutRegistrar(noRegistrar); }
|
||||||
|
|
||||||
status_t RemoveApp(team_id team) const
|
status_t RemoveApp(team_id team) const
|
||||||
{ return fRoster->_RemoveApp(team); }
|
{ return fRoster->_RemoveApp(team); }
|
||||||
|
|
||||||
|
|||||||
+16
-4
@@ -554,7 +554,8 @@ BRoster::BRoster()
|
|||||||
:
|
:
|
||||||
fMessenger(),
|
fMessenger(),
|
||||||
fMimeMessenger(),
|
fMimeMessenger(),
|
||||||
fMimeMessengerInitOnce(INIT_ONCE_UNINITIALIZED)
|
fMimeMessengerInitOnce(INIT_ONCE_UNINITIALIZED),
|
||||||
|
fNoRegistrar(false)
|
||||||
{
|
{
|
||||||
_InitMessenger();
|
_InitMessenger();
|
||||||
}
|
}
|
||||||
@@ -1871,7 +1872,7 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
|||||||
uint32 appToken = 0;
|
uint32 appToken = 0;
|
||||||
app_info appInfo;
|
app_info appInfo;
|
||||||
bool isScript = wasDocument && docRef != NULL && *docRef == appRef;
|
bool isScript = wasDocument && docRef != NULL && *docRef == appRef;
|
||||||
if (!isScript) {
|
if (!isScript && !fNoRegistrar) {
|
||||||
error = _AddApplication(signature, &appRef, appFlags, -1, -1, -1,
|
error = _AddApplication(signature, &appRef, appFlags, -1, -1, -1,
|
||||||
false, &appToken, &team);
|
false, &appToken, &team);
|
||||||
if (error == B_ALREADY_RUNNING) {
|
if (error == B_ALREADY_RUNNING) {
|
||||||
@@ -1910,7 +1911,7 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
|||||||
|
|
||||||
DBG(OUT(" load image: %s (%lx)\n", strerror(error), error));
|
DBG(OUT(" load image: %s (%lx)\n", strerror(error), error));
|
||||||
// finish the registration
|
// finish the registration
|
||||||
if (error == B_OK && !isScript)
|
if (error == B_OK && !isScript && !fNoRegistrar)
|
||||||
error = _SetThreadAndTeam(appToken, appThread, team);
|
error = _SetThreadAndTeam(appToken, appThread, team);
|
||||||
|
|
||||||
DBG(OUT(" set thread and team: %s (%lx)\n", strerror(error),
|
DBG(OUT(" set thread and team: %s (%lx)\n", strerror(error),
|
||||||
@@ -1926,6 +1927,7 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
|||||||
kill_thread(appThread);
|
kill_thread(appThread);
|
||||||
|
|
||||||
if (!isScript) {
|
if (!isScript) {
|
||||||
|
if (!fNoRegistrar)
|
||||||
_RemovePreRegApp(appToken);
|
_RemovePreRegApp(appToken);
|
||||||
|
|
||||||
if (!wasDocument) {
|
if (!wasDocument) {
|
||||||
@@ -1953,7 +1955,7 @@ BRoster::_LaunchApp(const char* mimeType, const entry_ref* ref,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send "on launch" messages
|
// send "on launch" messages
|
||||||
if (error == B_OK) {
|
if (error == B_OK && !fNoRegistrar) {
|
||||||
// If the target app is B_ARGV_ONLY, only if it is newly launched
|
// If the target app is B_ARGV_ONLY, only if it is newly launched
|
||||||
// messages are sent to it (namely B_ARGV_RECEIVED and B_READY_TO_RUN).
|
// messages are sent to it (namely B_ARGV_RECEIVED and B_READY_TO_RUN).
|
||||||
// An already running B_ARGV_ONLY app won't get any messages.
|
// An already running B_ARGV_ONLY app won't get any messages.
|
||||||
@@ -2581,6 +2583,16 @@ BRoster::_SendToRunning(team_id team, int argc, const char* const* args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Allows to use certain functionality of the BRoster class without
|
||||||
|
accessing the registrar.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BRoster::_SetWithoutRegistrar(bool noRegistrar)
|
||||||
|
{
|
||||||
|
fNoRegistrar = noRegistrar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BRoster::_InitMessenger()
|
BRoster::_InitMessenger()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
|
||||||
#include "Target.h"
|
#include "Target.h"
|
||||||
|
|
||||||
@@ -317,13 +318,10 @@ status_t
|
|||||||
Job::Launch()
|
Job::Launch()
|
||||||
{
|
{
|
||||||
if (fArguments.IsEmpty()) {
|
if (fArguments.IsEmpty()) {
|
||||||
// TODO: Launch via signature
|
// Launch by signature
|
||||||
// We cannot use the BRoster here as it tries to pre-register
|
|
||||||
// the application.
|
|
||||||
BString signature("application/");
|
BString signature("application/");
|
||||||
signature << Name();
|
signature << Name();
|
||||||
return B_NOT_SUPPORTED;
|
return be_roster->Launch(signature.String(), (BMessage*)NULL, &fTeam);
|
||||||
//return be_roster->Launch(signature.String(), (BMessage*)NULL, &fTeam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
@@ -331,23 +329,14 @@ Job::Launch()
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
size_t count = fArguments.CountStrings();
|
size_t count = fArguments.CountStrings() - 1;
|
||||||
const char* args[count + 1];
|
const char* args[count + 1];
|
||||||
for (int32 i = 0; i < fArguments.CountStrings(); i++) {
|
for (int32 i = 1; i < fArguments.CountStrings(); i++) {
|
||||||
args[i] = fArguments.StringAt(i);
|
args[i - 1] = fArguments.StringAt(i);
|
||||||
}
|
}
|
||||||
args[count] = NULL;
|
args[count] = NULL;
|
||||||
|
|
||||||
thread_id thread = load_image(count, args,
|
return be_roster->Launch(&ref, count, args, &fTeam);
|
||||||
const_cast<const char**>(environ));
|
|
||||||
if (thread >= 0)
|
|
||||||
resume_thread(thread);
|
|
||||||
|
|
||||||
thread_info info;
|
|
||||||
if (get_thread_info(thread, &info) == B_OK)
|
|
||||||
fTeam = info.team;
|
|
||||||
return B_OK;
|
|
||||||
// return be_roster->Launch(&ref, count, args, &fTeam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <DriverSettingsMessageAdapter.h>
|
#include <DriverSettingsMessageAdapter.h>
|
||||||
#include <LaunchDaemonDefs.h>
|
#include <LaunchDaemonDefs.h>
|
||||||
#include <LaunchRosterPrivate.h>
|
#include <LaunchRosterPrivate.h>
|
||||||
|
#include <RosterPrivate.h>
|
||||||
#include <syscalls.h>
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include "multiuser_utils.h"
|
#include "multiuser_utils.h"
|
||||||
@@ -185,6 +186,10 @@ LaunchDaemon::LaunchDaemon(bool userMode, status_t& error)
|
|||||||
fMainWorker = new MainWorker(fJobQueue);
|
fMainWorker = new MainWorker(fJobQueue);
|
||||||
if (fInitTarget != NULL)
|
if (fInitTarget != NULL)
|
||||||
_AddTarget(fInitTarget);
|
_AddTarget(fInitTarget);
|
||||||
|
|
||||||
|
// We may not be able to talk to the registrar
|
||||||
|
if (!fUserMode)
|
||||||
|
BRoster::Private().SetWithoutRegistrar(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user