Commit 9aa77988 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Speculative fix for bad SerialConnection behavior

If a SerialConnection consumer calls StartPolling() and then eventually
SetPaused(true), they should reasonably be able to assume that the
callback given to StartPolling() will no longer fire.

This changes SerialConnection::SetPaused() to ensure that any pending
timeout task is cancelled when pausing, satisfying the above assumption
where it was not previously satisfied.

This should fix a memory bug in ViscaWebcam which has been causing
crashes on Chrome OS.

Fixed: 1028819
Change-Id: I54c233fbc90fc2996d624548326ccda624fc9383
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1974732Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#726271}
parent 7e469f7f
......@@ -203,7 +203,10 @@ void SerialConnection::SetPaused(bool paused) {
return;
paused_ = paused;
if (!paused_) {
if (paused_) {
// Make sure no pending timeout task fires.
receive_timeout_task_.Cancel();
} else {
// If |receive_pipe_| is closed and there is no pending ReceiveError event,
// try to reconnect the data pipe.
if (!receive_pipe_ && !read_error_) {
......
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