diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2024-05-29 22:50:02 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2024-05-29 22:50:02 +0200 |
commit | c009c5f43ae0291d0ce0e44b54cd82d50bd3d72b (patch) | |
tree | e1c588fe73ab3d9453e4ccd16275f5712e575472 /include/network.php | |
parent | 9d56bb952e162dddd24d3bcdc50b2957ef0e0b97 (diff) | |
download | volse-hubzilla-c009c5f43ae0291d0ce0e44b54cd82d50bd3d72b.tar.gz volse-hubzilla-c009c5f43ae0291d0ce0e44b54cd82d50bd3d72b.tar.bz2 volse-hubzilla-c009c5f43ae0291d0ce0e44b54cd82d50bd3d72b.zip |
Fix default timeouts for z_(fetch|post)_url.
When fetching the default timouts from config, the result is converted
to an int via `intval()`, the result of that again is compared strictly
to `false`. Since 0 !== false, the default values will never be used,
and 0 (no timeout) is passed to curl.
This cause requests to hang indefinitely (or until they are killed) when
receiving actions that require a lookup or fetch to another site as part
of the request processing. (E.g webfinger, or fetching objects that we
received an announce action for.) This again cause the request never to
return a useful status to the site sending the action, and could cause
them to think the Hubzilla site is dead.
This patch fixes this by comparing the fetched value from config to 0
instead of false, making the defaults work again if the config is not
set (or set to 0).
Diffstat (limited to 'include/network.php')
-rw-r--r-- | include/network.php | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/network.php b/include/network.php index a7a11ff6e..1978eb868 100644 --- a/include/network.php +++ b/include/network.php @@ -116,7 +116,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { } else { $curl_time = intval(@Config::Get('system','curl_timeout')); - @curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60)); + @curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== 0) ? $curl_time : 60)); } if(x($opts,'connecttimeout') && intval($opts['connecttimeout'])) { @@ -124,7 +124,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { } else { $curl_contime = intval(@Config::Get('system','curl_connecttimeout')); - @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (($curl_contime !== false) ? $curl_contime : 30)); + @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (($curl_contime !== 0) ? $curl_contime : 30)); } if(x($opts,'http_auth')) { @@ -298,7 +298,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) { } else { $curl_time = intval(@Config::Get('system','curl_timeout')); - @curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60)); + @curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== 0) ? $curl_time : 60)); } if(x($opts,'http_auth')) { |