summaryrefslogtreecommitdiff
path: root/fastboot/socket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fastboot/socket.cpp')
-rw-r--r--fastboot/socket.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/fastboot/socket.cpp b/fastboot/socket.cpp
index e56ffcf4b..5a14b6377 100644
--- a/fastboot/socket.cpp
+++ b/fastboot/socket.cpp
@@ -54,7 +54,9 @@ ssize_t Socket::ReceiveAll(void* data, size_t length, int timeout_ms) {
while (total < length) {
ssize_t bytes = Receive(reinterpret_cast<char*>(data) + total, length - total, timeout_ms);
- if (bytes == -1) {
+ // Returns 0 only when the peer has disconnected because our requested length is not 0. So
+ // we return immediately to avoid dead loop here.
+ if (bytes <= 0) {
if (total == 0) {
return -1;
}