Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: device/serial/serial_io_handler_posix.cc

Issue 2212273002: [serial] Cancel read watcher if immediate read succeeded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/serial/serial_io_handler_posix.cc
diff --git a/device/serial/serial_io_handler_posix.cc b/device/serial/serial_io_handler_posix.cc
index 71b398c889b9eae7284bb699319f9114a50772a5..59582c5b84e7dea1ffe4b2d8306a103e6e0baebe 100644
--- a/device/serial/serial_io_handler_posix.cc
+++ b/device/serial/serial_io_handler_posix.cc
@@ -348,10 +348,16 @@ bool SerialIoHandlerPosix::AttemptRead(bool within_read) {
void SerialIoHandlerPosix::RunReadCompleted(bool within_read,
int bytes_read,
serial::ReceiveError error) {
- if (within_read)
+ if (within_read) {
+ // Stop watching the fd to avoid more reads until the queued ReadCompleted()
+ // completes and releases the pending_read_buffer.
+ is_watching_reads_ = false;
+ file_read_watcher_.StopWatchingFileDescriptor();
+
QueueReadCompleted(bytes_read, error);
- else
+ } else {
ReadCompleted(bytes_read, error);
+ }
}
void SerialIoHandlerPosix::OnFileCanWriteWithoutBlocking(int fd) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698