Commit 2b16b45b authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

[scheduler] Extra protection against empty tasks in scheduler

R=skyostil@chromium.org
BUG=789901

Change-Id: I39e845e80772571c9bac3c0d5f53fb04c3c53be5
Reviewed-on: https://chromium-review.googlesource.com/823031
Commit-Queue: Alexander Timin <altimin@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524414}
parent 411ce7e1
......@@ -410,7 +410,7 @@ TaskQueueImpl::WakeUpForDelayedWork(LazyNow* lazy_now) {
while (!main_thread_only().delayed_incoming_queue.empty()) {
Task& task =
const_cast<Task&>(main_thread_only().delayed_incoming_queue.top());
if (task.task.IsCancelled()) {
if (!task.task || task.task.IsCancelled()) {
main_thread_only().delayed_incoming_queue.pop();
continue;
}
......
......@@ -477,7 +477,10 @@ TaskQueueManager::ProcessTaskResult TaskQueueManager::ProcessTaskFromWorkQueue(
work_queue->TakeTaskFromWorkQueue();
// It's possible the task was canceled, if so bail out.
if (pending_task.task.IsCancelled())
// The task should be non-null, but it seems to be possible to due
// a hard-to-track bug. The first check is a defence against this bug,
// and this check isn't expected to be true in practice.
if (!pending_task.task || pending_task.task.IsCancelled())
return ProcessTaskResult::kExecuted;
internal::TaskQueueImpl* queue = work_queue->task_queue();
......
......@@ -97,7 +97,7 @@ TaskQueueImpl::Task WorkQueue::TakeTaskFromWorkQueue() {
// Skip over canceled tasks, except for the last one since we always return
// something.
while (work_queue_.size() > 1u) {
if (work_queue_.front().task.IsCancelled()) {
if (!work_queue_.front().task || work_queue_.front().task.IsCancelled()) {
work_queue_.pop_front();
} else {
break;
......
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