2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/data-service.git synced 2023-12-14 03:23:03 +01:00

Avoid fiber deadlocks

Channels don't represent some channel on which messages travel, at least not a
very long one because it can't accommodate any messages. They simply represent
a direct exchange of the message between a sender and receiver. Because of
this, put-message blocks the fiber, and if all the threads on the other end
are waiting for replies to be received, then you have a deadlock.

To avoid this situation, spawn new fibers to send the messages. I think this
works at least, although I'm unsure how sensible it is.
This commit is contained in:
Christopher Baines 2020-10-04 10:18:53 +01:00
parent 55eaaaeeac
commit 96b65f16fb

View file

@ -99,7 +99,9 @@
(define (defer-to-thread-pool-channel thunk)
(make-thread-pool-channel!)
(let ((reply (make-channel)))
(put-message %thread-pool-channel (cons reply thunk))
(spawn-fiber
(lambda ()
(put-message %thread-pool-channel (cons reply thunk))))
reply))
(define (fetch-result-of-defered-thunk reply-channel)