guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Ludovic Courtès
Date: Fri, 6 Oct 2023 06:35:09 -0400 (EDT)

branch: master
commit e159c74ca6f666a32eb9b778067e00941a4bfa36
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Oct 6 11:53:04 2023 +0200

    remote: Improve logging in ‘receive-logs’.
    
    * src/cuirass/remote.scm (receive-logs)[sockaddr->string]: New
    procedure.
    [read-log]: Add ‘address’ parameter and use it for logging.  Add clause
    for EOF.
---
 src/cuirass/remote.scm | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/cuirass/remote.scm b/src/cuirass/remote.scm
index 2e2b67f..f4ef49d 100644
--- a/src/cuirass/remote.scm
+++ b/src/cuirass/remote.scm
@@ -281,18 +281,25 @@ PRIVATE-KEY to sign narinfos."
     (string-append cache "/" hash ".log.gz")))
 
 (define (receive-logs port cache)
-  (define (read-log port)
-    (match (false-if-exception (read port))
-      (('log ('version 0)
-             ('derivation derivation))
-       (log-debug (G_ "reading build log for ~a") derivation)
-       (let ((file (log-path cache derivation)))
-         (call-with-output-file file
-           (lambda (output)
-             (dump-port port output)))))
-      (_
-       (log-error "invalid log received.")
-       #f)))
+  (define (sockaddr->string address)
+    (inet-ntop (sockaddr:fam address)
+               (sockaddr:addr address)))
+
+  (define (read-log port address)
+    (let ((address (sockaddr->string address)))
+      (match (false-if-exception (read port))
+        (('log ('version 0)
+               ('derivation derivation))
+         (log-debug (G_ "reading build log for ~a from ~a")
+                    derivation address)
+         (let ((file (log-path cache derivation)))
+           (call-with-output-file file
+             (lambda (output)
+               (dump-port port output)))))
+        ((? eof-object?)
+         (log-error "EOF while receiving log from ~a" address))
+        (_
+         (log-error "invalid log received from ~a" address)))))
 
   (define (wait-for-client port)
     (let ((sock (socket AF_INET
@@ -314,11 +321,10 @@ PRIVATE-KEY to sign narinfos."
     (catch 'system-error
       (lambda ()
         (log-debug "preparing to receive build log from ~a"
-                   (inet-ntop (sockaddr:fam address)
-                              (sockaddr:addr address)))
+                   (sockaddr->string address))
         (write '(log-server (version 0)) client)
         (force-output client)
-        (read-log client)
+        (read-log client address)
         (close-port client))
       (lambda args
         (close-port client)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]