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.
This commit is contained in:
@@ -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
|
bool
|
||||||
Job::CheckCondition(ConditionContext& context) const
|
Job::CheckCondition(ConditionContext& context) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ public:
|
|||||||
BStringList& Requirements();
|
BStringList& Requirements();
|
||||||
void AddRequirement(const char* requirement);
|
void AddRequirement(const char* requirement);
|
||||||
|
|
||||||
|
const BStringList& Pending() const;
|
||||||
|
BStringList& Pending();
|
||||||
|
void AddPending(const char* pending);
|
||||||
|
|
||||||
virtual bool CheckCondition(ConditionContext& context) const;
|
virtual bool CheckCondition(ConditionContext& context) const;
|
||||||
|
|
||||||
status_t Init(const Finder& jobs,
|
status_t Init(const Finder& jobs,
|
||||||
@@ -137,6 +141,7 @@ private:
|
|||||||
mutex fLaunchStatusLock;
|
mutex fLaunchStatusLock;
|
||||||
::Target* fTarget;
|
::Target* fTarget;
|
||||||
::Condition* fCondition;
|
::Condition* fCondition;
|
||||||
|
BStringList fPendingJobs;
|
||||||
BObjectList<BMessage>
|
BObjectList<BMessage>
|
||||||
fPendingLaunchDataReplies;
|
fPendingLaunchDataReplies;
|
||||||
::TeamRegistrator* fTeamRegistrator;
|
::TeamRegistrator* fTeamRegistrator;
|
||||||
|
|||||||
@@ -1463,6 +1463,7 @@ LaunchDaemon::_CanLaunchJobRequirements(Job* job, uint32 options)
|
|||||||
&& !requirement->IsRunning() && !requirement->IsLaunching()
|
&& !requirement->IsRunning() && !requirement->IsLaunching()
|
||||||
&& (!_CanLaunchJob(requirement, options, true)
|
&& (!_CanLaunchJob(requirement, options, true)
|
||||||
|| _CanLaunchJobRequirements(requirement, options))) {
|
|| _CanLaunchJobRequirements(requirement, options))) {
|
||||||
|
requirement->AddPending(job->Name());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1521,6 +1522,18 @@ LaunchDaemon::_LaunchJob(Job* job, uint32 options)
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user