diff --git a/src/servers/launch/Job.cpp b/src/servers/launch/Job.cpp index b999c0530c..c5aec04832 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 d4312956c3..84048f5312 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 fPendingLaunchDataReplies; ::TeamRegistrator* fTeamRegistrator; diff --git a/src/servers/launch/LaunchDaemon.cpp b/src/servers/launch/LaunchDaemon.cpp index 5e45fea977..b8e029f065 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; }