processor: Flush pending jobs during cancel(), not destroy

During shutdown, cancel queued jobs earlier to avoid having cleanup functions
accessing infrastructure not available anymore, for example watcher.
This commit is contained in:
Martin Willi
2014-05-07 14:13:34 +02:00
parent 9e93251397
commit 874e212f71
+11 -1
View File
@@ -467,6 +467,8 @@ METHOD(processor_t, cancel, void,
{
enumerator_t *enumerator;
worker_thread_t *worker;
job_t *job;
int i;
this->mutex->lock(this->mutex);
this->desired_threads = 0;
@@ -496,6 +498,14 @@ METHOD(processor_t, cancel, void,
worker->thread->join(worker->thread);
free(worker);
}
for (i = 0; i < JOB_PRIO_MAX; i++)
{
while (this->jobs[i]->remove_first(this->jobs[i],
(void**)&job) == SUCCESS)
{
job->destroy(job);
}
}
this->mutex->unlock(this->mutex);
}
@@ -510,7 +520,7 @@ METHOD(processor_t, destroy, void,
this->mutex->destroy(this->mutex);
for (i = 0; i < JOB_PRIO_MAX; i++)
{
this->jobs[i]->destroy_offset(this->jobs[i], offsetof(job_t, destroy));
this->jobs[i]->destroy(this->jobs[i]);
}
this->threads->destroy(this->threads);
free(this);