From 5cc569dc733c3d606be5180b43c6e8566009b4a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Sat, 8 Mar 2014 21:23:12 +0100
Subject: [PATCH] offload: Prevent locked files from being GC'd.

* guix/scripts/offload.scm (%slots): New variable.
  (choose-build-machine): Add SLOT to '%slots'.
---
 guix/scripts/offload.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm
index 2d2dbe36c5b..e1da31af5d3 100644
--- a/guix/scripts/offload.scm
+++ b/guix/scripts/offload.scm
@@ -383,6 +383,10 @@ (define (release-build-slot slot)
   "Release SLOT, a build slot as returned as by 'acquire-build-slot'."
   (close-port slot))
 
+(define %slots
+  ;; List of acquired build slots (open ports).
+  '())
+
 (define (choose-build-machine requirements machines)
   "Return the best machine among MACHINES fulfilling REQUIREMENTS, or #f."
 
@@ -418,7 +422,10 @@ (define (undecorate pred)
 
          ;; Return the best machine unless it's already overloaded.
          (if (< (machine-load best) 2.)
-             best
+             (begin
+               ;; Prevent SLOT from being GC'd.
+               (set! %slots (cons slot %slots))
+               best)
              (begin
                (release-build-slot slot)
                #f)))
-- 
GitLab