fix parallel raco setup
failure on dependency cycles
The failure should be an individual module failure, instead of terminating `raco setup`.
This commit is contained in:
parent
50db01bf2c
commit
1cffde1df8
|
@ -36,15 +36,21 @@
|
||||||
(define depends (make-hash))
|
(define depends (make-hash))
|
||||||
(define/public (lock fn wrkr)
|
(define/public (lock fn wrkr)
|
||||||
(let ([v (hash-ref locks fn #f)])
|
(let ([v (hash-ref locks fn #f)])
|
||||||
(hash-set! locks fn
|
(hash-set!
|
||||||
(if v
|
locks fn
|
||||||
(match v [(list w waitlst)
|
(match v
|
||||||
|
[(list w waitlst)
|
||||||
(hash-set! depends wrkr (cons w fn))
|
(hash-set! depends wrkr (cons w fn))
|
||||||
(check-cycles wrkr (hash) null)
|
(let ([fns (check-cycles wrkr (hash) null)])
|
||||||
(list w (append waitlst (list wrkr)))])
|
(cond
|
||||||
(begin
|
[fns
|
||||||
|
(wrkr/send wrkr (list 'cycle (cons fn fns)))
|
||||||
|
v]
|
||||||
|
[else
|
||||||
|
(list w (append waitlst (list wrkr)))]))]
|
||||||
|
[else
|
||||||
(wrkr/send wrkr (list 'locked))
|
(wrkr/send wrkr (list 'locked))
|
||||||
(list wrkr null))))
|
(list wrkr null)]))
|
||||||
(not v)))
|
(not v)))
|
||||||
(define/public (unlock fn)
|
(define/public (unlock fn)
|
||||||
(match (hash-ref locks fn)
|
(match (hash-ref locks fn)
|
||||||
|
@ -55,13 +61,11 @@
|
||||||
(hash-remove! locks fn)]))
|
(hash-remove! locks fn)]))
|
||||||
(define/private (check-cycles w seen fns)
|
(define/private (check-cycles w seen fns)
|
||||||
(cond
|
(cond
|
||||||
[(hash-ref seen w #f)
|
[(hash-ref seen w #f) fns]
|
||||||
(error 'setup "dependency cycle: ~s"
|
|
||||||
(cons (car fns) (reverse fns)))]
|
|
||||||
[(hash-ref depends w #f)
|
[(hash-ref depends w #f)
|
||||||
=> (lambda (d)
|
=> (lambda (d)
|
||||||
(check-cycles (car d) (hash-set seen w #t) (cons (cdr d) fns)))]
|
(check-cycles (car d) (hash-set seen w #t) (cons (cdr d) fns)))]
|
||||||
[else (void)]))
|
[else #f]))
|
||||||
(super-new)))
|
(super-new)))
|
||||||
|
|
||||||
(define/class/generics lock-manager%
|
(define/class/generics lock-manager%
|
||||||
|
@ -293,6 +297,8 @@
|
||||||
(DEBUG_COMM (eprintf "REQUESTING LOCK ~a ~a ~a\n" worker-id name _full-file))
|
(DEBUG_COMM (eprintf "REQUESTING LOCK ~a ~a ~a\n" worker-id name _full-file))
|
||||||
(match (send/recv (list (list 'LOCK (path->bytes fn)) "" ""))
|
(match (send/recv (list (list 'LOCK (path->bytes fn)) "" ""))
|
||||||
[(list 'locked) #t]
|
[(list 'locked) #t]
|
||||||
|
[(list 'cycle fns)
|
||||||
|
(error 'setup "dependency cycle: ~s" fns)]
|
||||||
[(list 'compiled) #f]
|
[(list 'compiled) #f]
|
||||||
[(list 'DIE) (worker/die 1)]
|
[(list 'DIE) (worker/die 1)]
|
||||||
[x (send/error (format "DIDNT MATCH B ~v\n" x))]
|
[x (send/error (format "DIDNT MATCH B ~v\n" x))]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user