guix-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Clément Lassieur
Date: Fri, 27 Jul 2018 15:25:58 -0400 (EDT)

branch: master
commit 70d85c0c642be0b5aaca567857ba416a1f4cee8c
Author: Clément Lassieur <address@hidden>
Date:   Fri Jul 27 08:28:12 2018 +0200

    utils: Prevent critical section clients to talk to each other.
    
    * src/cuirass/utils.scm (make-critical-section): Put the modified message to
    the REPLY channel that was part of the initial message.
    (call-with-critical-section): Create a REPLY channel, add it to the sent
    message, get the modified message from that channel.
    
    Co-authored-by: Ludovic Courtès <address@hidden>
---
 src/cuirass/utils.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/cuirass/utils.scm b/src/cuirass/utils.scm
index 6629bc1..9e9ac36 100644
--- a/src/cuirass/utils.scm
+++ b/src/cuirass/utils.scm
@@ -106,16 +106,17 @@ dedicated fiber."
      (lambda ()
        (let loop ()
          (match (get-message channel)
-           ((? procedure? proc)
-            (put-message channel (apply proc args))))
+           (((? channel? reply) . (? procedure? proc))
+            (put-message reply (apply proc args))))
          (loop))))
     channel))
 
 (define (call-with-critical-section channel proc)
   "Call PROC in the critical section corresponding to CHANNEL.  Return the
 result of PROC."
-  (put-message channel proc)
-  (get-message channel))
+  (let ((reply (make-channel)))
+    (put-message channel (cons reply proc))
+    (get-message reply)))
 
 (define-syntax-rule (with-critical-section channel (vars ...) exp ...)
   "Evaluate EXP... in the critical section corresponding to CHANNEL.



reply via email to

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