launch_daemon: Fixed job event trigger.
* Always check for events before launching a job unconditionally. * Correctly check for demand before launching a job.
This commit is contained in:
parent
f6647de349
commit
2c756e16e0
@ -139,6 +139,13 @@ Event::Trigger()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Event::ResetTrigger()
|
||||
{
|
||||
fTriggered = false;
|
||||
}
|
||||
|
||||
|
||||
BaseJob*
|
||||
Event::Owner() const
|
||||
{
|
||||
@ -418,16 +425,17 @@ Events::TriggerDemand(Event* event)
|
||||
if (EventContainer* container = dynamic_cast<EventContainer*>(event)) {
|
||||
for (int32 index = 0; index < container->Events().CountItems();
|
||||
index++) {
|
||||
Event* event = container->Events().ItemAt(index);
|
||||
if (dynamic_cast<DemandEvent*>(event) != NULL) {
|
||||
event->Trigger();
|
||||
Event* childEvent = container->Events().ItemAt(index);
|
||||
if (dynamic_cast<DemandEvent*>(childEvent) != NULL) {
|
||||
childEvent->Trigger();
|
||||
return true;
|
||||
}
|
||||
if (dynamic_cast<EventContainer*>(event) != NULL) {
|
||||
if (TriggerDemand(event))
|
||||
return true;
|
||||
if (dynamic_cast<EventContainer*>(childEvent) != NULL) {
|
||||
if (TriggerDemand(childEvent))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return event->Triggered();
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
|
||||
bool Triggered() const;
|
||||
virtual void Trigger();
|
||||
void ResetTrigger();
|
||||
|
||||
virtual BaseJob* Owner() const;
|
||||
virtual void SetOwner(BaseJob* owner);
|
||||
|
@ -311,7 +311,7 @@ LaunchDaemon::MessageReceived(BMessage* message)
|
||||
|
||||
Job* job = FindJob(name);
|
||||
if (job != NULL && job->EventHasTriggered()) {
|
||||
_AddLaunchJob(job);
|
||||
_TriggerJob(job);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -766,7 +766,8 @@ LaunchDaemon::_LaunchJobs(Target* target)
|
||||
for (JobMap::iterator iterator = fJobs.begin(); iterator != fJobs.end();
|
||||
iterator++) {
|
||||
Job* job = iterator->second;
|
||||
if (job->Target() == target && job->Event() == NULL)
|
||||
if (job->Target() == target
|
||||
&& (job->Event() == NULL || job->Event()->Triggered()))
|
||||
_TriggerJob(job);
|
||||
}
|
||||
}
|
||||
@ -785,7 +786,7 @@ LaunchDaemon::_TriggerJob(Job* job)
|
||||
_TriggerJob(requirement);
|
||||
}
|
||||
|
||||
if (!Events::TriggerDemand(job->Event()))
|
||||
if (job->EventHasTriggered() || !Events::TriggerDemand(job->Event()))
|
||||
_AddLaunchJob(job);
|
||||
}
|
||||
|
||||
@ -795,6 +796,8 @@ LaunchDaemon::_AddLaunchJob(Job* job)
|
||||
{
|
||||
if (job->Target() != NULL)
|
||||
job->Target()->ResolveSourceFiles();
|
||||
if (job->Event() != NULL)
|
||||
job->Event()->ResetTrigger();
|
||||
|
||||
if (!job->IsLaunched() && job->CheckCondition(*this))
|
||||
fJobQueue.AddJob(job);
|
||||
|
Loading…
Reference in New Issue
Block a user