raco setup: fix problem with processes-based build
The procsses-based build was technically broken with the addition of a "prefetch" thread (some time back) to improve parallelism, because the `write`-based implementation of messages did not protect again interleaving by different threads. The problem turns out to be easier to expose when running with RacketCS.
This commit is contained in:
parent
fd730a6772
commit
b2e4d51b1b
|
@ -398,11 +398,19 @@
|
||||||
(define orig-err (current-error-port))
|
(define orig-err (current-error-port))
|
||||||
(define orig-out (current-output-port))
|
(define orig-out (current-output-port))
|
||||||
(define orig-in (current-input-port))
|
(define orig-in (current-input-port))
|
||||||
|
(define send-lock (make-semaphore 1))
|
||||||
(define (raw-send msg)
|
(define (raw-send msg)
|
||||||
(cond
|
(cond
|
||||||
[ch (place-channel-put ch msg)]
|
[ch (place-channel-put ch msg)]
|
||||||
[else (write (convert-paths msg) orig-out)
|
[else
|
||||||
(flush-output orig-out)]))
|
(define c-msg (convert-paths msg))
|
||||||
|
;; Multiple threads might try to write (e.g., for prefetching),
|
||||||
|
;; so make sure the writes are not interleaved
|
||||||
|
(call-with-semaphore
|
||||||
|
send-lock
|
||||||
|
(lambda ()
|
||||||
|
(write c-msg orig-out)))
|
||||||
|
(flush-output orig-out)]))
|
||||||
(define (raw-recv)
|
(define (raw-recv)
|
||||||
(cond
|
(cond
|
||||||
[ch (place-channel-get ch)]
|
[ch (place-channel-get ch)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user