launch_daemon: Fixed the remaining "operation not allowed" bug.

* This was the harmless part: a job was been requeued that already was
  being launched.
* I was already aware of this one, and only accidentally stumbled over
  the non-harmless case in the JobQueue code when I tried to fix that
  little issue... (ie. never ignore warnings, even if you think you
  know what's going on).
This commit is contained in:
Axel Dörfler 2015-10-18 13:07:26 +02:00
parent c80084b025
commit 4ae4b3ff57
3 changed files with 25 additions and 3 deletions

View File

@ -25,6 +25,7 @@ Job::Job(const char* name)
fEnabled(true),
fService(false),
fCreateDefaultPort(false),
fLaunching(false),
fInitStatus(B_NO_INIT),
fTeam(-1),
fLaunchStatus(B_NO_INIT),
@ -349,6 +350,20 @@ Job::IsRunning() const
}
bool
Job::IsLaunching() const
{
return fLaunching;
}
void
Job::SetLaunching(bool launching)
{
fLaunching = launching;
}
status_t
Job::HandleGetLaunchData(BMessage* message)
{
@ -376,10 +391,12 @@ Job::Run()
status_t
Job::Execute()
{
status_t status = B_OK;
if (!IsLaunched() || !IsService())
return Launch();
status = Launch();
return B_OK;
fLaunching = false;
return status;
}

View File

@ -73,6 +73,9 @@ public:
bool IsLaunched() const;
bool IsRunning() const;
bool IsLaunching() const;
void SetLaunching(bool launching);
status_t HandleGetLaunchData(BMessage* message);
virtual status_t Run();
@ -104,6 +107,7 @@ private:
bool fEnabled;
bool fService;
bool fCreateDefaultPort;
bool fLaunching;
PortMap fPortMap;
status_t fInitStatus;
team_id fTeam;

View File

@ -1074,7 +1074,7 @@ LaunchDaemon::_LaunchJobs(Target* target, bool forceNow)
void
LaunchDaemon::_LaunchJob(Job* job, uint32 options)
{
if (job == NULL || (job->IsService() && job->IsLaunched())
if (job == NULL || job->IsLaunching() || job->IsRunning()
|| ((options & FORCE_NOW) == 0
&& (!job->EventHasTriggered() || !job->CheckCondition(*this)
|| ((options & TRIGGER_DEMAND) != 0
@ -1097,6 +1097,7 @@ LaunchDaemon::_LaunchJob(Job* job, uint32 options)
if (job->Event() != NULL)
job->Event()->ResetTrigger();
job->SetLaunching(true);
fJobQueue.AddJob(job);
}