aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2021-06-08 21:30:48 +0100
committerChristopher Baines <mail@cbaines.net>2021-06-08 21:30:48 +0100
commit3b1653c3735ae6e96612e219b6e9f88773634a10 (patch)
tree7c02b804c4313076629b9b7515c84bcab34c5ff0
parent4a474176aa7401fa6da1de84d2df5816e33f65b8 (diff)
downloadbuild-coordinator-3b1653c3735ae6e96612e219b6e9f88773634a10.tar
build-coordinator-3b1653c3735ae6e96612e219b6e9f88773634a10.tar.gz
Support reporting bytes sent with streaming HTTP requests
-rw-r--r--guix-build-coordinator/utils.scm11
1 files changed, 8 insertions, 3 deletions
diff --git a/guix-build-coordinator/utils.scm b/guix-build-coordinator/utils.scm
index c833183..bc18081 100644
--- a/guix-build-coordinator/utils.scm
+++ b/guix-build-coordinator/utils.scm
@@ -261,7 +261,8 @@ upcoming chunk."
gc-enable))
(define* (make-chunked-output-port* port #:key (keep-alive? #f)
- (buffering 1200))
+ (buffering 1200)
+ report-bytes-sent)
(define heap-allocated-limit
(expt 2 20)) ;; 1MiB
@@ -276,6 +277,8 @@ upcoming chunk."
(put-bytevector port bv)
(put-string port "\r\n")))
+ (when report-bytes-sent
+ (report-bytes-sent length))
(let* ((stats (gc-stats))
(initial-gc-times
(assq-ref stats 'gc-times)))
@@ -304,7 +307,8 @@ upcoming chunk."
ret))
(define* (call-with-streaming-http-request uri callback
- #:key (headers '()))
+ #:key (headers '())
+ report-bytes-sent)
(let* ((port (open-socket-for-uri uri))
(request
(build-request
@@ -330,7 +334,8 @@ upcoming chunk."
(make-chunked-output-port*
port
#:buffering (expt 2 12)
- #:keep-alive? #t)))
+ #:keep-alive? #t
+ #:report-bytes-sent report-bytes-sent)))
;; A SIGPIPE will kill Guile, so ignore it
(sigaction SIGPIPE