mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 14:50:19 +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:
parent
70249b9857
commit
691a1c3c06
1 changed files with 3 additions and 2 deletions
|
@ -101,7 +101,8 @@ touched."
|
||||||
(() (loop))
|
(() (loop))
|
||||||
((future _ ...)
|
((future _ ...)
|
||||||
(lock-mutex (future-mutex future))
|
(lock-mutex (future-mutex future))
|
||||||
(or (future-done? future)
|
(or (and (future-done? future)
|
||||||
|
(unlock-mutex (future-mutex future)))
|
||||||
(begin
|
(begin
|
||||||
;; Do the actual work.
|
;; Do the actual work.
|
||||||
(unregister-future! future)
|
(unregister-future! future)
|
||||||
|
@ -115,9 +116,9 @@ touched."
|
||||||
(lock-mutex (future-mutex future))
|
(lock-mutex (future-mutex future))
|
||||||
(or (future-done? future) ; lost the race?
|
(or (future-done? future) ; lost the race?
|
||||||
(process-future! future))
|
(process-future! future))
|
||||||
|
(unlock-mutex (future-mutex future))
|
||||||
|
|
||||||
(lock-mutex %futures-mutex)))
|
(lock-mutex %futures-mutex)))
|
||||||
(unlock-mutex (future-mutex future))
|
|
||||||
(loop)))))
|
(loop)))))
|
||||||
|
|
||||||
(define (touch future)
|
(define (touch future)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue