From 45a02b56f8740d8e39089867636a6f881ec511f2 Mon Sep 17 00:00:00 2001 From: Matej Ferencevic Date: Sun, 8 Oct 2017 12:12:21 +0200 Subject: [PATCH] Fixed bolt client endless loop when server dies. Reviewers: buda Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D879 --- src/communication/bolt/client.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/communication/bolt/client.hpp b/src/communication/bolt/client.hpp index a8d34617e..6cba7a2b9 100644 --- a/src/communication/bolt/client.hpp +++ b/src/communication/bolt/client.hpp @@ -131,7 +131,7 @@ class Client { std::vector> records; while (true) { if (!GetDataByChunk()) { - throw ClientInvalidDataException(); + throw ClientSocketException(); } if (!decoder_.ReadMessageHeader(&signature, &marker)) { throw ClientInvalidDataException(); @@ -198,7 +198,7 @@ class Client { while (buffer_.size() < len) { auto buff = buffer_.Allocate(); int ret = socket_.Read(buff.data, buff.len); - if (ret == -1) return false; + if (ret <= 0) return false; buffer_.Written(ret); } return true; @@ -213,7 +213,7 @@ class Client { } auto buff = buffer_.Allocate(); int ret = socket_.Read(buff.data, buff.len); - if (ret == -1) return false; + if (ret <= 0) return false; buffer_.Written(ret); } return true;