From 3b1653c3735ae6e96612e219b6e9f88773634a10 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 8 Jun 2021 21:30:48 +0100 Subject: Support reporting bytes sent with streaming HTTP requests --- guix-build-coordinator/utils.scm | 11 ++++++++--- 1 file 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 -- cgit v1.2.3