From c91338e3c41e640da8911befc8f14e595449d9ca Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 8 Feb 2017 15:17:35 +0100 Subject: Fix channel CAS logic * fibers/channels.scm (put-operation, get-operation): Fix bogus CAS that could cause us to spin in an allocation loop. --- fibers/channels.scm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fibers/channels.scm b/fibers/channels.scm index 9f946da..aabf2db 100644 --- a/fibers/channels.scm +++ b/fibers/channels.scm @@ -69,7 +69,7 @@ with a receiver fiber to send @var{message} over @var{channel}." ;; Try to update getq. Return the new getq value in ;; any case. (let ((q (atomic-box-compare-and-swap! getq-box getq getq*))) - (if (eq? q getq) getq* getq))) + (if (eq? q getq) getq* q))) ;; Return #f if the getq was empty. (and getq* (match item @@ -124,7 +124,7 @@ with a receiver fiber to send @var{message} over @var{channel}." ;; Try to update getq. Return the new getq value in ;; any case. (let ((q (atomic-box-compare-and-swap! getq-box getq getq*))) - (if (eq? q getq) getq* getq))) + (if (eq? q getq) getq* q))) ;; We only have to service the getq if it is non-empty. (when getq* (match item @@ -186,7 +186,7 @@ with a sender fiber to receive one value from @var{channel}." ;; Try to update putq. Return the new putq value in ;; any case. (let ((q (atomic-box-compare-and-swap! putq-box putq putq*))) - (if (eq? q putq) putq* putq))) + (if (eq? q putq) putq* q))) ;; Return #f if the putq was empty. (and putq* (match item @@ -239,7 +239,7 @@ with a sender fiber to receive one value from @var{channel}." ;; Try to update putq. Return the new putq value in ;; any case. (let ((q (atomic-box-compare-and-swap! putq-box putq putq*))) - (if (eq? q putq) putq* putq))) + (if (eq? q putq) putq* q))) ;; We only have to service the putq if it is non-empty. (when putq* (match item -- cgit v1.3