Commit d66436c2 authored by derat's avatar derat Committed by Commit bot

chromeos: Avoid crash on thaw failure if freezing failed.

Avoid an "Unable to thaw renderers." LOG(FATAL) in
RendererFreezer if freezing the renderers also failed
earlier. This is a workaround for unexplained EBADF and
ENOENT errors seen when writing to cgroups.

BUG=chromium:661310
TEST=manual: log in and chmod freezer.state in
     /sys/fs/cgroup/freezer/chrome_renderers/to_be_frozen
     to 444; suspend and resume and check that chrome
     doesn't abort

Review-Url: https://codereview.chromium.org/2575933002
Cr-Commit-Position: refs/heads/master@{#438625}
parent 49d2ee2e
......@@ -34,7 +34,9 @@ class FreezerCgroupProcessManager::FileWorker {
explicit FileWorker(scoped_refptr<base::SequencedTaskRunner> file_thread)
: ui_thread_(content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI)),
file_thread_(file_thread) {
file_thread_(file_thread),
enabled_(false),
froze_successfully_(false) {
DCHECK(ui_thread_->RunsTasksOnCurrentThread());
}
......@@ -78,7 +80,8 @@ class FreezerCgroupProcessManager::FileWorker {
return;
}
WriteCommandToFile(kFreezeCommand, to_be_frozen_state_path_);
froze_successfully_ =
WriteCommandToFile(kFreezeCommand, to_be_frozen_state_path_);
}
void ThawRenderers(ResultCallback callback) {
......@@ -91,6 +94,13 @@ class FreezerCgroupProcessManager::FileWorker {
}
bool result = WriteCommandToFile(kThawCommand, to_be_frozen_state_path_);
// TODO(derat): For now, lie and report success if thawing failed but
// freezing also failed previously. Remove after weird EBADF and ENOENT
// problems tracked at http://crbug.com/661310 are fixed.
if (!result && !froze_successfully_)
result = true;
ui_thread_->PostTask(FROM_HERE, base::Bind(callback, result));
}
......@@ -128,6 +138,10 @@ class FreezerCgroupProcessManager::FileWorker {
bool enabled_;
// True iff FreezeRenderers() wrote its command successfully the last time it
// was called.
bool froze_successfully_;
DISALLOW_COPY_AND_ASSIGN(FileWorker);
};
......
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