From 24f62b51e277f996c5cbdcbff820580b7a424a68 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Tue, 13 Jan 2015 12:30:11 +0200 Subject: [PATCH] Check timeout since it seems that readWithTimeout not always works --- modules/remotebackend/httpconnector.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/remotebackend/httpconnector.cc b/modules/remotebackend/httpconnector.cc index 21e5e3741f..9befb8bef9 100644 --- a/modules/remotebackend/httpconnector.cc +++ b/modules/remotebackend/httpconnector.cc @@ -382,11 +382,13 @@ int HTTPConnector::recv_message(rapidjson::Document &output) { char buffer[4096]; int rd = -1; bool fail = false; + time_t t0; arl.initialize(&resp); try { - while(arl.ready() == false) { + t0 = time((time_t*)NULL); + while(arl.ready() == false && (labs(time((time_t*)NULL) - t0) <= timeout/1000)) { rd = d_socket->readWithTimeout(buffer, sizeof(buffer), timeout); if (rd<0) { delete d_socket; @@ -397,6 +399,13 @@ int HTTPConnector::recv_message(rapidjson::Document &output) { buffer[rd] = 0; arl.feed(std::string(buffer, rd)); } + // timeout occured. + if (arl.ready() == false) { + L<