Filter out illegal actions in our action ConsTrees
This commit is contained in:
parent
6c89d9bd9d
commit
2e7aa6ee1f
24
os2.rkt
24
os2.rkt
|
@ -402,9 +402,31 @@
|
|||
(struct-copy process old-process
|
||||
[state new-state]))]))
|
||||
|
||||
(define (preaction? a)
|
||||
(or (add-role? a)
|
||||
(delete-role? a)
|
||||
(send-message? a)
|
||||
(spawn? a)
|
||||
(kill? a)))
|
||||
|
||||
(define (action? a)
|
||||
(or (preaction? a)
|
||||
(and (at-meta-level? a)
|
||||
(preaction? (at-meta-level-preaction a)))))
|
||||
|
||||
(define (valid-action? pid a)
|
||||
(cond
|
||||
[(action? a)]
|
||||
[(eq? a #f) #f] ;; skip falses in action ConsTrees
|
||||
[(void? a) #f] ;; skip voids in action ConsTrees
|
||||
[else (log-warning (format "Illegal action ~v from pid ~v" a pid))
|
||||
#f]))
|
||||
|
||||
(define (enqueue-actions state pid actions)
|
||||
(struct-copy vm state
|
||||
[pending-actions (append (reverse (for/list ([a (flatten actions)]) (cons pid a)))
|
||||
[pending-actions (append (reverse (for/list ([a (flatten actions)]
|
||||
#:when (valid-action? pid a))
|
||||
(cons pid a)))
|
||||
(vm-pending-actions state))]))
|
||||
|
||||
(define (((wrap-trapk pid trapk) . args) state)
|
||||
|
|
Loading…
Reference in New Issue