1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 06:20:23 +02:00

futures: Fix potential deadlock.

* module/ice-9/futures.scm (process-futures): Fix potential deadlock,
  whereby %FUTURES-MUTEX would be acquired *after* FUTURE's mutex.
This commit is contained in:
Ludovic Courtès 2010-12-16 17:37:02 +01:00
parent 70249b9857
commit 691a1c3c06

View file

@ -101,7 +101,8 @@ touched."
(() (loop))
((future _ ...)
(lock-mutex (future-mutex future))
(or (future-done? future)
(or (and (future-done? future)
(unlock-mutex (future-mutex future)))
(begin
;; Do the actual work.
(unregister-future! future)
@ -115,9 +116,9 @@ touched."
(lock-mutex (future-mutex future))
(or (future-done? future) ; lost the race?
(process-future! future))
(unlock-mutex (future-mutex future))
(lock-mutex %futures-mutex)))
(unlock-mutex (future-mutex future))
(loop)))))
(define (touch future)