From 3fd0eb154ff267536378f4999ac86c8fee3d2d6a Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@gnu.org>
Date: Mon, 2 Nov 2020 11:05:50 +0100
Subject: [PATCH] Revert "Use a non-blocking socket for store communication."
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 387909454c835c994414aa740a2d33d288064158 that causes:

2020-11-02T11:05:08 fatal: uncaught exception 'wrong-type-arg' in 'build' fiber!
2020-11-02T11:05:08 exception arguments: ("struct-vtable" "Wrong type argument in position 1 (expecting struct): ~S" (#f) (#f))
In ice-9/boot-9.scm:
  1731:15 12 (with-exception-handler #<procedure 7fb1a93f9930 at ic鈥�> 鈥�)
  1736:10 11 (with-exception-handler _ _ #:unwind? _ # _)
    718:2 10 (call-with-prompt ("break") #<procedure 7fb1ab76f440 a鈥�> 鈥�)
    718:2  9 (call-with-prompt ("continue") #<procedure 7fb1ab77084鈥�> 鈥�)
In ice-9/eval.scm:
    619:8  8 (_ #(#(#<directory (guile-user) 7fb1ac680f00> #<var鈥�> 鈥�)))
In srfi/srfi-1.scm:
    634:9  7 (for-each #<procedure 7fb1a9525900 at cuirass/base.scm鈥�> 鈥�)
In ice-9/boot-9.scm:
  1731:15  6 (with-exception-handler #<procedure 7fb1a95a94e0 at ic鈥�> 鈥�)
  1669:16  5 (raise-exception _ #:continuable? _)
  1764:13  4 (_ #<&compound-exception components: (#<&assertion-fail鈥�>)
In cuirass/utils.scm:
    319:8  3 (_ _ . _)
In ice-9/boot-9.scm:
  1731:15  2 (with-exception-handler #<procedure 7fb1ab2e3720 at ic鈥�> 鈥�)
In cuirass/utils.scm:
   320:22  1 (_)
In unknown file:
           0 (make-stack #t)
ERROR: In procedure make-stack:
In procedure struct-vtable: Wrong type argument in position 1 (expecting struct): #f
---
 src/cuirass/base.scm | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm
index 7f4cc3ca..1966ad6d 100644
--- a/src/cuirass/base.scm
+++ b/src/cuirass/base.scm
@@ -36,9 +36,6 @@
   #:use-module ((guix config) #:select (%state-directory))
   #:use-module (git)
   #:use-module (ice-9 binary-ports)
-  #:use-module ((ice-9 suspendable-ports)
-                #:select (current-read-waiter
-                          current-write-waiter))
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:use-module (ice-9 popen)
@@ -82,12 +79,7 @@
   ;; currently closes in a 'dynamic-wind' handler, which means it would close
   ;; the store at each context switch.  Remove this when the real 'with-store'
   ;; has been fixed.
-  (let* ((store  (open-connection))
-         (socket (store-connection-socket store)))
-    ;; Mark SOCKET as non-blocking so Fibers can schedule the way it wants.
-    (let ((flags (fcntl socket F_GETFL)))
-      (fcntl socket F_SETFL (logior O_NONBLOCK flags)))
-
+  (let ((store (open-connection)))
     (unwind-protect
      ;; Always set #:keep-going? so we don't stop on the first build failure.
      ;; Set #:print-build-trace explicitly to make sure 'process-build-log'
@@ -430,12 +422,7 @@ Essentially this procedure inverts the inversion-of-control that
           (lambda ()
             (guard (c ((store-error? c)
                        (atomic-box-set! result c)))
-              (parameterize ((current-build-output-port output)
-
-                             ;; STORE's socket is O_NONBLOCK but since we're
-                             ;; not in a fiber, disable Fiber's handlers.
-                             (current-read-waiter #f)
-                             (current-write-waiter #f))
+              (parameterize ((current-build-output-port output))
                 (let ((x (build-derivations store lst)))
                   (atomic-box-set! result x))))
             (close-port output))
-- 
GitLab