From 1602fcf012e8771485df590e994d8d0462480cab Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 19 Nov 2012 19:07:32 +0100 Subject: [PATCH] Remote: read now retry when it did not get all the expected data --- src/remote.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/remote.cc b/src/remote.cc index 8d5a6592..2fb71223 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -89,12 +89,17 @@ void write(Message& msg, const DisplayBuffer& display_buffer) void read(int socket, char* buffer, size_t size) { - int res = ::read(socket, buffer, size); - if (res == 0) - throw peer_disconnected{}; - if (res == -1) - throw socket_error{}; - assert(res == size); + while (size) + { + int res = ::read(socket, buffer, size); + if (res == 0) + throw peer_disconnected{}; + if (res < 0) + throw socket_error{}; + + buffer += res; + size -= res; + } } template