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

Unified Diff: remoting/protocol/message_reader.cc

Issue 10703159: Fix MessageReader to handle errors properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « remoting/protocol/fake_session.cc ('k') | remoting/protocol/message_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/message_reader.cc
diff --git a/remoting/protocol/message_reader.cc b/remoting/protocol/message_reader.cc
index 02dc99792626db5dba362f006509267d696a769b..441d7295b1dc4340fe5a8e5e17b388a52a87c41f 100644
--- a/remoting/protocol/message_reader.cc
+++ b/remoting/protocol/message_reader.cc
@@ -66,14 +66,14 @@ void MessageReader::HandleReadResult(int result) {
if (result > 0) {
OnDataReceived(read_buffer_, result);
+ } else if (result == net::ERR_IO_PENDING) {
+ read_pending_ = true;
} else {
- if (result == net::ERR_CONNECTION_CLOSED) {
- closed_ = true;
- } else if (result == net::ERR_IO_PENDING) {
- read_pending_ = true;
- } else {
+ if (result != net::ERR_CONNECTION_CLOSED) {
LOG(ERROR) << "Read() returned error " << result;
}
+ // Stop reading after any error.
+ closed_ = true;
}
}
@@ -115,7 +115,8 @@ void MessageReader::ProcessDoneEvent() {
pending_messages_--;
DCHECK_GE(pending_messages_, 0);
- DoRead(); // Start next read if neccessary.
+ if (!read_pending_)
+ DoRead(); // Start next read if neccessary.
}
} // namespace protocol
« no previous file with comments | « remoting/protocol/fake_session.cc ('k') | remoting/protocol/message_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698