aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-06-30 19:16:49 +0100
committerChristopher Baines <mail@cbaines.net>2023-06-30 19:16:49 +0100
commitff22f545b54be50f52b605a90ec038be0d33360d (patch)
tree79f1f3b38c515956d0c61f9f6591f652603efb58
parent836812dbff93f3c670903720d04129be60873e22 (diff)
downloadnar-herder-ff22f545b54be50f52b605a90ec038be0d33360d.tar
nar-herder-ff22f545b54be50f52b605a90ec038be0d33360d.tar.gz
Set low level timeouts for HTTP requests
To try to avoid things getting stuck.
-rw-r--r--nar-herder/cached-compression.scm12
-rw-r--r--nar-herder/mirror.scm10
-rw-r--r--nar-herder/storage.scm22
3 files changed, 36 insertions, 8 deletions
diff --git a/nar-herder/cached-compression.scm b/nar-herder/cached-compression.scm
index 9982387..328c7d1 100644
--- a/nar-herder/cached-compression.scm
+++ b/nar-herder/cached-compression.scm
@@ -467,9 +467,15 @@
(lambda ()
(call-with-values
(lambda ()
- (http-get uri
- #:decode-body? #f
- #:streaming? #t))
+ (let ((port
+ socket
+ (open-socket-for-uri* uri)))
+ (set-socket-timeout socket #:seconds 30)
+
+ (http-get uri
+ #:port port
+ #:decode-body? #f
+ #:streaming? #t)))
(lambda (response body)
(unless (= (response-code response)
200)
diff --git a/nar-herder/mirror.scm b/nar-herder/mirror.scm
index 1f0998e..41e1c05 100644
--- a/nar-herder/mirror.scm
+++ b/nar-herder/mirror.scm
@@ -19,6 +19,7 @@
(define-module (nar-herder mirror)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-43)
+ #:use-module (srfi srfi-71)
#:use-module (ice-9 match)
#:use-module (ice-9 threads)
#:use-module (ice-9 exceptions)
@@ -74,7 +75,14 @@
(lambda ()
(with-port-timeouts
(lambda ()
- (http-get uri #:decode-body? #f))))
+ (let ((port
+ socket
+ (open-socket-for-uri* uri)))
+ (set-socket-timeout socket #:seconds 30)
+
+ (http-get uri
+ #:port port
+ #:decode-body? #f)))))
#:times 3
#:delay 15))
(lambda (response body)
diff --git a/nar-herder/storage.scm b/nar-herder/storage.scm
index 5555176..70b300b 100644
--- a/nar-herder/storage.scm
+++ b/nar-herder/storage.scm
@@ -18,6 +18,7 @@
(define-module (nar-herder storage)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-71)
#:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (ice-9 threads)
@@ -268,7 +269,14 @@
(lambda ()
(with-port-timeouts
(lambda ()
- (http-get uri #:decode-body? #f))))
+ (let ((port
+ socket
+ (open-socket-for-uri* uri)))
+ (set-socket-timeout socket #:seconds 30)
+
+ (http-get uri
+ #:port port
+ #:decode-body? #f)))))
#:times 3
#:delay 5))
(lambda (response body)
@@ -384,9 +392,15 @@
(lambda ()
(call-with-values
(lambda ()
- (http-get uri
- #:decode-body? #f
- #:streaming? #t))
+ (let ((port
+ socket
+ (open-socket-for-uri* uri)))
+ (set-socket-timeout socket #:seconds 30)
+
+ (http-get uri
+ #:port port
+ #:decode-body? #f
+ #:streaming? #t)))
(lambda (response body)
(unless (= (response-code response)
200)