From: Patrick Cloke Date: Fri, 2 Oct 2015 18:55:49 +0000 (-0400) Subject: Be consistent in the usage of timeout in the remote backend's httpconnector. X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~8^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44bde05323f82e5ffef2e5f28b13d93576e7fa50;p=pdns Be consistent in the usage of timeout in the remote backend's httpconnector. The `timeout` configuration option for the remotebackend is provided in milliseconds in the httpconnector, this is immediately converted (and stored) as seconds. For all write operations, the `timeout` is used without modification, however the read operation in `recv_message` again divides the `timeout` by 1000. This is inconsistent with the usage of `time`, which returns seconds since the UNIX epoch. The bug created by this is that HTTP requests from the remotebackend must be responded to extremely quickly (practically instantaneously with the default 2 second timeout). After this change the same timeout is used appropriately for both read and write. --- diff --git a/modules/remotebackend/httpconnector.cc b/modules/remotebackend/httpconnector.cc index e809a1f25..d18f88f3b 100644 --- a/modules/remotebackend/httpconnector.cc +++ b/modules/remotebackend/httpconnector.cc @@ -401,7 +401,7 @@ int HTTPConnector::recv_message(rapidjson::Document &output) { try { t0 = time((time_t*)NULL); - while(arl.ready() == false && (labs(time((time_t*)NULL) - t0) <= timeout/1000)) { + while(arl.ready() == false && (labs(time((time_t*)NULL) - t0) <= timeout)) { rd = d_socket->readWithTimeout(buffer, sizeof(buffer), timeout); if (rd==0) throw NetworkError("EOF while reading");