Unverified Commit 4409f452 authored by Ge Jun's avatar Ge Jun Committed by GitHub

Merge pull request #638 from eric-buaa-cn/master

bugfix to prevent accessing the reclaimed task
parents 8b74f72a 61b7959b
......@@ -348,12 +348,16 @@ void TimerThread::run() {
// Pull tasks from buckets.
for (size_t i = 0; i < _options.num_buckets; ++i) {
Bucket& bucket = _buckets[i];
for (Task* p = bucket.consume_tasks(); p != NULL;
p = p->next, ++nscheduled) {
for (Task* p = bucket.consume_tasks(); p != nullptr; ++nscheduled) {
// p->next should be kept first
// in case of the deletion of Task p which is unscheduled
Task* next_task = p->next;
if (!p->try_delete()) { // remove the task if it's unscheduled
tasks.push_back(p);
std::push_heap(tasks.begin(), tasks.end(), task_greater);
}
p = next_task;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment