[haiku-commits] haiku: hrev49892 - src/servers/launch src/servers/mail data/launch src/bin/multiuser

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 28 Nov 2015 14:18:45 +0100 (CET)

hrev49892 adds 5 changesets to branch 'master'
old head: f9422dc81ddf0ca154bbfa9302f55447d7564984
new head: 893e3de866127920293f3de1b4d7968717468045
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=893e3de86612+%5Ef9422dc81ddf

----------------------------------------------------------------------------

ea3e5d43d5ec: passwd: Fixed copy&paste error in error message.

236e68efdc9e: launch_daemon: Check requirements before launching a job.

* They were only launched, but we didn't check if we can actually
launch them.

59e6d9d2e223: launch_daemon: Maintain pending jobs for requirements.

* If a requirement cannot be launched, a job is now added to the
requirement as pending job.
* If the requirement enters the launch queue at a later time, the
pending job will be put there, too.

f92aeedd7f20: User login: Fixed missing Deskbar tray icons.

* The mail_daemon could have been launched too early, which caused it
not to be able to add its Deskbar icon. We don't really want a
dependency to the Deskbar, though, which is why we only run the
mail_daemon on the same event (which makes the Deskbar available
at that point).
* Ideally, the mail_daemon should be smart enough to install its Deskbar
icon once the Deskbar is available, though.
* Similar issue for the first login scripts. Here, we have a real
dependency to the Deskbar which makes the script launch once the
Deskbar is available.
* This finally fixes #12454.

893e3de86612: mail_daemon: Converted to BServer.

[ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

10 files changed, 122 insertions(+), 28 deletions(-)
data/launch/user | 13 ++--
src/bin/multiuser/passwd.cpp | 4 +-
src/servers/launch/Events.cpp | 9 ++-
src/servers/launch/Events.h | 2 +-
src/servers/launch/Job.cpp | 21 +++++++
src/servers/launch/Job.h | 5 ++
src/servers/launch/LaunchDaemon.cpp | 85 +++++++++++++++++++++++---
src/servers/mail/Jamfile | 2 +-
src/servers/mail/MailDaemonApplication.cpp | 3 +-
src/servers/mail/MailDaemonApplication.h | 6 +-

############################################################################

Commit: ea3e5d43d5ec7b73e4dd1da9ce56026844f5f8be
URL: http://cgit.haiku-os.org/haiku/commit/?id=ea3e5d43d5ec
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Fri Nov 27 18:07:58 2015 UTC

passwd: Fixed copy&paste error in error message.

----------------------------------------------------------------------------

diff --git a/src/bin/multiuser/passwd.cpp b/src/bin/multiuser/passwd.cpp
index 920002c..44beda2 100644
--- a/src/bin/multiuser/passwd.cpp
+++ b/src/bin/multiuser/passwd.cpp
@@ -3,6 +3,7 @@
* Distributed under the terms of the MIT License.
*/

+
#include <errno.h>
#include <getopt.h>
#include <pwd.h>
@@ -189,7 +190,8 @@ main(int argc, const char* const* argv)
KMessage reply;
status_t error = send_authentication_request_to_registrar(message,
reply);
if (error != B_OK) {
- fprintf(stderr, "Error: Failed to create user: %s\n",
strerror(error));
+ fprintf(stderr, "Error: Failed to set the password: %s\n",
+ strerror(error));
exit(1);
}


############################################################################

Commit: 236e68efdc9eed77818832b42d9b02161b21395d
URL: http://cgit.haiku-os.org/haiku/commit/?id=236e68efdc9e
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Fri Nov 27 18:09:39 2015 UTC

launch_daemon: Check requirements before launching a job.

* They were only launched, but we didn't check if we can actually
launch them.

----------------------------------------------------------------------------

diff --git a/src/servers/launch/Events.cpp b/src/servers/launch/Events.cpp
index 316292a..c5d9aab 100644
--- a/src/servers/launch/Events.cpp
+++ b/src/servers/launch/Events.cpp
@@ -775,11 +775,13 @@ Events::ResetStickyExternalEvent(Event* event, const
char* name)

/*! This will trigger a demand event, if it exists.

+ \param testOnly If \c true, the deman will not actually be triggered,
+ it will only be checked if it could.
\return \c true, if there is a demand event, and it has been
triggered by this call. \c false if not.
*/
/*static*/ bool
-Events::TriggerDemand(Event* event)
+Events::TriggerDemand(Event* event, bool testOnly)
{
if (event == NULL || event->Triggered())
return false;
@@ -789,11 +791,14 @@ Events::TriggerDemand(Event* event)
index++) {
Event* childEvent = container->Events().ItemAt(index);
if (dynamic_cast<DemandEvent*>(childEvent) != NULL) {
+ if (testOnly)
+ return true;
+
childEvent->Trigger();
break;
}
if (dynamic_cast<EventContainer*>(childEvent) != NULL) {
- if (TriggerDemand(childEvent))
+ if (TriggerDemand(childEvent, testOnly))
break;
}
}
diff --git a/src/servers/launch/Events.h b/src/servers/launch/Events.h
index 4605975..862b5ca 100644
--- a/src/servers/launch/Events.h
+++ b/src/servers/launch/Events.h
@@ -62,7 +62,7 @@ public:
const char*
name);
static void ResetStickyExternalEvent(Event* event,
const char*
name);
- static bool TriggerDemand(Event* event);
+ static bool TriggerDemand(Event* event, bool
testOnly = false);
};


diff --git a/src/servers/launch/LaunchDaemon.cpp
b/src/servers/launch/LaunchDaemon.cpp
index 36a4a56..5e45fea 100644
--- a/src/servers/launch/LaunchDaemon.cpp
+++ b/src/servers/launch/LaunchDaemon.cpp
@@ -184,7 +184,11 @@ private:
void _InitJobs(Target*
target);
void _LaunchJobs(Target*
target,
bool
forceNow = false);
- void _LaunchJob(Job* job,
uint32 options = 0);
+ bool _CanLaunchJob(Job* job,
uint32 options,
+ bool
testOnly = false);
+ bool
_CanLaunchJobRequirements(Job* job,
+ uint32
options);
+ bool _LaunchJob(Job* job,
uint32 options = 0);
void _StopJob(Job* job, bool
force);
void _AddTarget(Target*
target);
void _SetCondition(BaseJob*
job,
@@ -1428,6 +1432,45 @@ LaunchDaemon::_LaunchJobs(Target* target, bool forceNow)
}


+/*! Checks whether or not the specified \a job can be launched.
+ If \a testOnly is \c false, calling this method will trigger a demand
+ to the \a job.
+*/
+bool
+LaunchDaemon::_CanLaunchJob(Job* job, uint32 options, bool testOnly)
+{
+ if (job == NULL || !job->CanBeLaunched())
+ return false;
+
+ return (options & FORCE_NOW) != 0
+ || (job->EventHasTriggered() && job->CheckCondition(*this)
+ && ((options & TRIGGER_DEMAND) == 0
+ || Events::TriggerDemand(job->Event(),
testOnly)));
+}
+
+
+/*! Checks recursively if the requirements of the specified job can be
launched,
+ if they are not running already.
+ Calling this method will not trigger a demand for the requirements.
+*/
+bool
+LaunchDaemon::_CanLaunchJobRequirements(Job* job, uint32 options)
+{
+ int32 count = job->Requirements().CountStrings();
+ for (int32 index = 0; index < count; index++) {
+ Job* requirement = FindJob(job->Requirements().StringAt(index));
+ if (requirement != NULL
+ && !requirement->IsRunning() &&
!requirement->IsLaunching()
+ && (!_CanLaunchJob(requirement, options, true)
+ || _CanLaunchJobRequirements(requirement,
options))) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
/*! Adds the specified \a job to the launch queue
queue, except those that are triggered by events.

@@ -1437,24 +1480,30 @@ LaunchDaemon::_LaunchJobs(Target* target, bool forceNow)
Calling this method will trigger a demand event if \c TRIGGER_DEMAND has
been set.
*/
-void
+bool
LaunchDaemon::_LaunchJob(Job* job, uint32 options)
{
- if (job == NULL || !job->CanBeLaunched()
- || ((options & FORCE_NOW) == 0
- && (!job->EventHasTriggered() ||
!job->CheckCondition(*this)
- || ((options & TRIGGER_DEMAND) != 0
- &&
Events::TriggerDemand(job->Event()))))) {
- return;
- }
+ if (job != NULL && (job->IsLaunching() || job->IsRunning()))
+ return true;
+
+ if (!_CanLaunchJob(job, options))
+ return false;

+ // Test if we can launch all requirements
+ if (!_CanLaunchJobRequirements(job, options | TRIGGER_DEMAND))
+ return false;
+
+ // Actually launch the requirements
int32 count = job->Requirements().CountStrings();
for (int32 index = 0; index < count; index++) {
Job* requirement = FindJob(job->Requirements().StringAt(index));
if (requirement != NULL) {
// TODO: For jobs that have their communication
channels set up,
// we would not need to trigger demand at this point
- _LaunchJob(requirement, TRIGGER_DEMAND);
+ if (!_LaunchJob(requirement, options | TRIGGER_DEMAND))
{
+ // Failed to put a requirement into the launch
queue
+ return false;
+ }
}
}

@@ -1469,7 +1518,10 @@ LaunchDaemon::_LaunchJob(Job* job, uint32 options)
if (status != B_OK) {
debug_printf("Adding job %s to queue failed: %s\n", job->Name(),
strerror(status));
+ return false;
}
+
+ return true;
}



############################################################################

Commit: 59e6d9d2e2239c2d522cf820cac3a2e9c8a99c55
URL: http://cgit.haiku-os.org/haiku/commit/?id=59e6d9d2e223
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Fri Nov 27 19:34:02 2015 UTC

launch_daemon: Maintain pending jobs for requirements.

* If a requirement cannot be launched, a job is now added to the
requirement as pending job.
* If the requirement enters the launch queue at a later time, the
pending job will be put there, too.

----------------------------------------------------------------------------

diff --git a/src/servers/launch/Job.cpp b/src/servers/launch/Job.cpp
index b999c05..c5aec04 100644
--- a/src/servers/launch/Job.cpp
+++ b/src/servers/launch/Job.cpp
@@ -207,6 +207,27 @@ Job::AddRequirement(const char* requirement)
}


+const BStringList&
+Job::Pending() const
+{
+ return fPendingJobs;
+}
+
+
+BStringList&
+Job::Pending()
+{
+ return fPendingJobs;
+}
+
+
+void
+Job::AddPending(const char* pending)
+{
+ fPendingJobs.Add(pending);
+}
+
+
bool
Job::CheckCondition(ConditionContext& context) const
{
diff --git a/src/servers/launch/Job.h b/src/servers/launch/Job.h
index d431295..84048f5 100644
--- a/src/servers/launch/Job.h
+++ b/src/servers/launch/Job.h
@@ -70,6 +70,10 @@ public:
BStringList& Requirements();
void AddRequirement(const
char* requirement);

+ const BStringList& Pending() const;
+ BStringList& Pending();
+ void AddPending(const char*
pending);
+
virtual bool
CheckCondition(ConditionContext& context) const;

status_t Init(const Finder& jobs,
@@ -137,6 +141,7 @@ private:
mutex fLaunchStatusLock;
::Target* fTarget;
::Condition* fCondition;
+ BStringList fPendingJobs;
BObjectList<BMessage>

fPendingLaunchDataReplies;
::TeamRegistrator* fTeamRegistrator;
diff --git a/src/servers/launch/LaunchDaemon.cpp
b/src/servers/launch/LaunchDaemon.cpp
index 5e45fea..b8e029f 100644
--- a/src/servers/launch/LaunchDaemon.cpp
+++ b/src/servers/launch/LaunchDaemon.cpp
@@ -1463,6 +1463,7 @@ LaunchDaemon::_CanLaunchJobRequirements(Job* job, uint32
options)
&& !requirement->IsRunning() &&
!requirement->IsLaunching()
&& (!_CanLaunchJob(requirement, options, true)
|| _CanLaunchJobRequirements(requirement,
options))) {
+ requirement->AddPending(job->Name());
return false;
}
}
@@ -1521,6 +1522,18 @@ LaunchDaemon::_LaunchJob(Job* job, uint32 options)
return false;
}

+ // Try to launch pending jobs as well
+ count = job->Pending().CountStrings();
+ for (int32 index = 0; index < count; index++) {
+ Job* pending = FindJob(job->Pending().StringAt(index));
+ if (pending != NULL && _LaunchJob(pending, 0)) {
+ // Remove the job from the pending list once its in the
launch
+ // queue, so that is not being launched again next time.
+ index--;
+ count--;
+ }
+ }
+
return true;
}


############################################################################

Commit: f92aeedd7f20ae0f53014ab6318a7753747dd517
URL: http://cgit.haiku-os.org/haiku/commit/?id=f92aeedd7f20
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Fri Nov 27 19:41:13 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/12454

User login: Fixed missing Deskbar tray icons.

* The mail_daemon could have been launched too early, which caused it
not to be able to add its Deskbar icon. We don't really want a
dependency to the Deskbar, though, which is why we only run the
mail_daemon on the same event (which makes the Deskbar available
at that point).
* Ideally, the mail_daemon should be smart enough to install its Deskbar
icon once the Deskbar is available, though.
* Similar issue for the first login scripts. Here, we have a real
dependency to the Deskbar which makes the script launch once the
Deskbar is available.
* This finally fixes #12454.

----------------------------------------------------------------------------

diff --git a/data/launch/user b/data/launch/user
index 902c460..e98bd6f 100644
--- a/data/launch/user
+++ b/data/launch/user
@@ -4,21 +4,18 @@ target desktop {
service x-vnd.Be-TRAK {
launch /system/Tracker
legacy
- on {
- initial_volumes_mounted
- }
+ on initial_volumes_mounted
}

service x-vnd.Be-TSKB {
launch /system/Deskbar
- on {
- initial_volumes_mounted
- }
+ on initial_volumes_mounted
}

service x-vnd.Be-POST {
- launch /system/servers/mail_daemon -E
+ launch /system/servers/mail_daemon
if setting ~/config/settings/Mail/new_mail_daemon
DaemonAutoStarts
+ on initial_volumes_mounted
no_safemode
legacy
}
@@ -38,6 +35,7 @@ target desktop {
job first-login {
launch /bin/sh /system/boot/PostInstallScript "first login"
~/config/settings/first_login /boot/system/boot/first-login
if file_exists ~/config/settings/first_login
+ requires x-vnd.Be-TSKB
}

job create-installer-link {

############################################################################

Revision: hrev49892
Commit: 893e3de866127920293f3de1b4d7968717468045
URL: http://cgit.haiku-os.org/haiku/commit/?id=893e3de86612
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Fri Nov 27 19:52:15 2015 UTC

mail_daemon: Converted to BServer.

----------------------------------------------------------------------------

diff --git a/data/launch/user b/data/launch/user
index e98bd6f..2a3b74f 100644
--- a/data/launch/user
+++ b/data/launch/user
@@ -17,7 +17,6 @@ target desktop {
if setting ~/config/settings/Mail/new_mail_daemon
DaemonAutoStarts
on initial_volumes_mounted
no_safemode
- legacy
}

job user-bootscript {
diff --git a/src/servers/mail/Jamfile b/src/servers/mail/Jamfile
index bbabb32..3ac7981 100644
--- a/src/servers/mail/Jamfile
+++ b/src/servers/mail/Jamfile
@@ -7,7 +7,7 @@ if $(TARGET_PLATFORM) != haiku {
}

UsePublicHeaders [ FDirName add-ons mail_daemon ] ;
-UsePrivateHeaders mail shared tracker ;
+UsePrivateHeaders app mail shared tracker ;
SubDirHdrs $(HAIKU_TOP) src kits tracker ;

AddResources mail_daemon : mail_daemon.rdef DeskbarViewIcons.rdef ;
diff --git a/src/servers/mail/MailDaemonApplication.cpp
b/src/servers/mail/MailDaemonApplication.cpp
index df50b10..b46bc4a 100644
--- a/src/servers/mail/MailDaemonApplication.cpp
+++ b/src/servers/mail/MailDaemonApplication.cpp
@@ -162,8 +162,7 @@ account_protocols::account_protocols()

MailDaemonApplication::MailDaemonApplication()
:
- BApplication(B_MAIL_DAEMON_SIGNATURE),
-
+ BServer(B_MAIL_DAEMON_SIGNATURE, true, NULL),
fAutoCheckRunner(NULL)
{
fErrorLogWindow = new ErrorLogWindow(BRect(200, 200, 500, 250),
diff --git a/src/servers/mail/MailDaemonApplication.h
b/src/servers/mail/MailDaemonApplication.h
index 92d43cd..ac465c3 100644
--- a/src/servers/mail/MailDaemonApplication.h
+++ b/src/servers/mail/MailDaemonApplication.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2007-2013, Haiku, Inc. All rights reserved.
+ * Copyright 2007-2015, Haiku, Inc. All rights reserved.
* Copyright 2001-2002 Dr. Zoidberg Enterprises. All rights reserved.
* Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
* Distributed under the terms of the MIT License.
@@ -10,12 +10,12 @@

#include <map>

-#include <Application.h>
#include <ObjectList.h>
#include <Message.h>
#include <MessageRunner.h>
#include <Node.h>
#include <Query.h>
+#include <Server.h>
#include <String.h>

#include <MailProtocol.h>
@@ -41,7 +41,7 @@ struct account_protocols {
typedef std::map<int32, account_protocols> AccountMap;


-class MailDaemonApplication : public BApplication {
+class MailDaemonApplication : public BServer {
public:

MailDaemonApplication();
virtual
~MailDaemonApplication();


Other related posts:

  • » [haiku-commits] haiku: hrev49892 - src/servers/launch src/servers/mail data/launch src/bin/multiuser - axeld