You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2019/05/14 10:15:57 UTC
[thrift] branch master updated: THRIFT-4845: Stop ignoring small
timeouts
This is an automated email from the ASF dual-hosted git repository.
jking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new 79c2337 THRIFT-4845: Stop ignoring small timeouts
79c2337 is described below
commit 79c23377057f5bbb2d52097eb13073db2d69db8c
Author: Jeremy Mikkola <jm...@thumbtack.com>
AuthorDate: Thu Apr 4 18:03:32 2019 -0700
THRIFT-4845: Stop ignoring small timeouts
Client: php
CURLOPT_TIMEOUT requires a long [0], so it seems that small values
like 0.2 are being rounded to 0, resulting in a lack of any timeout.
This change uses CURLOPT_TIMEOUT_MS, which the PHP documentation
says was "added in cURL 7.16.2. Available since PHP 5.2.3."
[0] https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html
---
lib/php/lib/Transport/TCurlClient.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/php/lib/Transport/TCurlClient.php b/lib/php/lib/Transport/TCurlClient.php
index 482b43b..2060d34 100644
--- a/lib/php/lib/Transport/TCurlClient.php
+++ b/lib/php/lib/Transport/TCurlClient.php
@@ -230,7 +230,12 @@ class TCurlClient extends TTransport
curl_setopt(self::$curlHandle, CURLOPT_HTTPHEADER, $headers);
if ($this->timeout_ > 0) {
- curl_setopt(self::$curlHandle, CURLOPT_TIMEOUT, $this->timeout_);
+ if ($this->timeout_ < 1.0) {
+ // Timestamps smaller than 1 second are ignored when CURLOPT_TIMEOUT is used
+ curl_setopt(self::$curlHandle, CURLOPT_TIMEOUT_MS, 1000 * $this->timeout_);
+ } else {
+ curl_setopt(self::$curlHandle, CURLOPT_TIMEOUT, $this->timeout_);
+ }
}
curl_setopt(self::$curlHandle, CURLOPT_POSTFIELDS, $this->request_);
$this->request_ = '';