Index: webrtc/base/socketadapters.cc |
diff --git a/webrtc/base/socketadapters.cc b/webrtc/base/socketadapters.cc |
index 4a2da0adfcd800ea53519505f6ee458ad36155dd..b1c2a87aa9b2b5ac9e5d7038bb3176104fc1765b 100644 |
--- a/webrtc/base/socketadapters.cc |
+++ b/webrtc/base/socketadapters.cc |
@@ -81,10 +81,18 @@ int BufferedReadAdapter::Recv(void *pv, size_t cb) { |
// FIX: If cb == 0, we won't generate another read event |
int res = AsyncSocketAdapter::Recv(pv, cb); |
- if (res < 0) |
- return res; |
+ if (res >= 0) { |
+ // Read from socket and possibly buffer; return combined length |
+ return res + static_cast<int>(read); |
+ } |
+ |
+ if (read > 0) { |
+ // Failed to read from socket, but still read something from buffer |
+ return static_cast<int>(read); |
+ } |
- return res + static_cast<int>(read); |
+ // Didn't read anything; return error from socket |
+ return res; |
} |
void BufferedReadAdapter::BufferInput(bool on) { |