diff options
author | Christopher Baines <mail@cbaines.net> | 2023-05-09 18:13:19 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-05-09 18:14:57 +0100 |
commit | 9eefed5669d8137f6ba787b5790b147d62b4a0ac (patch) | |
tree | 6f86c067695b83e13aa8fb9cc17ffd279c90c5e5 /guix-build-coordinator/agent-messaging | |
parent | 76912c8a56af1841628fbf7cf07de6985aa65ee3 (diff) | |
download | build-coordinator-9eefed5669d8137f6ba787b5790b147d62b4a0ac.tar build-coordinator-9eefed5669d8137f6ba787b5790b147d62b4a0ac.tar.gz |
More port forcing
I think NGinx might time out reading the response headers for streaming
requests, since the headers probably don't fill the buffer. So force output at
that point.
Also, address the issue with forcing output to the chunked port.
Diffstat (limited to 'guix-build-coordinator/agent-messaging')
-rw-r--r-- | guix-build-coordinator/agent-messaging/http/server.scm | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm index dd54c41..2ef8500 100644 --- a/guix-build-coordinator/agent-messaging/http/server.scm +++ b/guix-build-coordinator/agent-messaging/http/server.scm @@ -108,6 +108,7 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." (forward-invocation)))))) (define* (progress-reporter/hash size log-port + force-output-to-log-port #:key (progress-interval (make-time time-duration 0 20))) (define total 0) @@ -117,7 +118,7 @@ INTERVAL (a time-duration object), otherwise does nothing and returns #f." (format #f "~a~%" transferred)) (display message log-port) ;should be atomic - (force-output log-port)) + (force-output-to-log-port)) (progress-reporter (start (lambda () @@ -639,10 +640,22 @@ port. Also, the port used can be changed by passing the --port option.\n" #:code 200 #:headers '((content-type . (text/plain)))) (lambda (response-port) + ;; Make sure NGinx gets the response headers + (force-output (request-port request)) + ;; Compute the hash of the file (let* ((reporter (progress-reporter/hash (stat:size (stat tmp-output-file-name)) - response-port)) + response-port + (lambda () + (force-output response-port) + ;; TODO because the chunked output port + ;; doesn't call force-output on the + ;; underlying port, do that here. We + ;; want this event to be sent now, + ;; rather than when some buffer fills + ;; up. + (force-output (request-port request))))) (hash (call-with-worker-thread chunked-request-channel @@ -720,10 +733,22 @@ port. Also, the port used can be changed by passing the --port option.\n" #:code 200 #:headers '((content-type . (text/plain)))) (lambda (response-port) + ;; Make sure NGinx gets the response headers + (force-output (request-port request)) + ;; Compute the hash of the file (let* ((reporter (progress-reporter/hash (stat:size (stat tmp-output-file-name)) - response-port)) + response-port + (lambda () + (force-output response-port) + ;; TODO because the chunked output port + ;; doesn't call force-output on the + ;; underlying port, do that here. We + ;; want this event to be sent now, + ;; rather than when some buffer fills + ;; up. + (force-output (request-port request))))) (hash (call-with-worker-thread chunked-request-channel |