From: Aki Tuomi Date: Tue, 13 Jan 2015 10:30:11 +0000 (+0200) Subject: Check timeout since it seems that readWithTimeout not always works X-Git-Tag: rec-3.7.0-rc1~28^2~2^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=24f62b51e277f996c5cbdcbff820580b7a424a68;p=thirdparty%2Fpdns.git Check timeout since it seems that readWithTimeout not always works --- 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<