diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-02-26T14·58+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-02-26T14·58+0100 |
commit | 00d761016a33ff9aa0ea162402d0d846dd1927cb (patch) | |
tree | 8eada3c4e02ddce0522db9cf4ec8dc4f35539aa7 /scripts/download-from-binary-cache.pl.in | |
parent | d761009e3ccdcdd7b150b26f7f35eecf8f2fb59c (diff) |
Respect $NIX_CONNECT_TIMEOUT properly
We were 1) using CURLOPT_TIMEOUT instead of CURLOPT_CONNECTTIMEOUT; 2) not passing it to the curl child process. Issue #93.
Diffstat (limited to 'scripts/download-from-binary-cache.pl.in')
-rw-r--r-- | scripts/download-from-binary-cache.pl.in | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/download-from-binary-cache.pl.in b/scripts/download-from-binary-cache.pl.in index 63abfb9179ba..4f7ff12e8f17 100644 --- a/scripts/download-from-binary-cache.pl.in +++ b/scripts/download-from-binary-cache.pl.in @@ -44,6 +44,8 @@ my $userName = getpwuid($<) || $ENV{"USER"} or die "cannot figure out user name" my $requireSignedBinaryCaches = ($Nix::Config::config{"signed-binary-caches"} // "0") ne "0"; +my $curlConnectTimeout = int($ENV{"NIX_CONNECT_TIMEOUT"} // 0); + sub addRequest { my ($storePath, $url, $head) = @_; @@ -62,7 +64,7 @@ sub addRequest { $curl->setopt(CURLOPT_USERAGENT, "Nix/$Nix::Config::version"); $curl->setopt(CURLOPT_NOBODY, 1) if $head; $curl->setopt(CURLOPT_FAILONERROR, 1); - $curl->setopt(CURLOPT_TIMEOUT, int($ENV{"NIX_CONNECT_TIMEOUT"} // 0)); + $curl->setopt(CURLOPT_CONNECTTIMEOUT, $curlConnectTimeout); if ($activeRequests >= $maxParallelRequests) { $scheduled{$curlId} = 1; @@ -535,7 +537,7 @@ sub downloadBinary { die if $requireSignedBinaryCaches && !defined $info->{signedBy}; print STDERR "\n*** Downloading ‘$url’ ", ($requireSignedBinaryCaches ? "(signed by ‘$info->{signedBy}’) " : ""), "to ‘$storePath’...\n"; checkURL $url; - if (system("$Nix::Config::curl --fail --location --insecure '$url' $decompressor | $Nix::Config::binDir/nix-store --restore $destPath") != 0) { + if (system("$Nix::Config::curl --fail --location --insecure --connect-timeout $curlConnectTimeout '$url' $decompressor | $Nix::Config::binDir/nix-store --restore $destPath") != 0) { warn "download of `$url' failed" . ($! ? ": $!" : "") . "\n"; next; } |