From a08a6b4904e50db3e62985a477c2f64f22f0dc60 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Thu, 17 Dec 2020 14:31:16 +0100 Subject: [PATCH] fix custodian-managed-list: omit custodian-boxes --- .../tests/racket/subprocess.rktl | 9 ++++++++ racket/src/cs/schemified/thread.scm | 22 ++++++++++++++++++- racket/src/thread/custodian.rkt | 4 +++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/pkgs/racket-test-core/tests/racket/subprocess.rktl b/pkgs/racket-test-core/tests/racket/subprocess.rktl index 0d399c87b7..04a8f7bd9b 100644 --- a/pkgs/racket-test-core/tests/racket/subprocess.rktl +++ b/pkgs/racket-test-core/tests/racket/subprocess.rktl @@ -432,6 +432,15 @@ (test #f pair? (member sp (custodian-managed-list c2 c))) (custodian-shutdown-all c)) +;; Check custodian-boxes are omitted by custodian-managed-list: +(let* ([c (make-custodian)] + [c2 (make-custodian c)]) + (define cb (make-custodian-box c2 'value)) + (test '() custodian-managed-list c2 c) + (test 'value custodian-box-value cb) + (custodian-shutdown-all c2) + (test #f custodian-box-value cb)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; process groups ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/racket/src/cs/schemified/thread.scm b/racket/src/cs/schemified/thread.scm index 1802f0af0c..43a182d5d5 100644 --- a/racket/src/cs/schemified/thread.scm +++ b/racket/src/cs/schemified/thread.scm @@ -5732,7 +5732,27 @@ c_0 "second custodian" super-c_0)) - (hash-keys (custodian-children c_0))))))) + (reverse$1 + (let ((ht_0 (custodian-children c_0))) + (begin + (letrec* + ((for-loop_0 + (|#%name| + for-loop + (lambda (fold-var_0 i_0) + (begin + (if i_0 + (let ((v_0 (hash-iterate-key ht_0 i_0))) + (let ((fold-var_1 + (if (not (1/custodian-box? v_0)) + (let ((fold-var_1 (cons v_0 fold-var_0))) + (values fold-var_1)) + fold-var_0))) + (for-loop_0 + fold-var_1 + (hash-iterate-next ht_0 i_0)))) + fold-var_0)))))) + (for-loop_0 null (hash-iterate-first ht_0))))))))))) (define 1/custodian-memory-accounting-available? (|#%name| custodian-memory-accounting-available? (lambda () (begin #t)))) (define 1/custodian-require-memory diff --git a/racket/src/thread/custodian.rkt b/racket/src/thread/custodian.rkt index d8d69fd540..5aa269522d 100644 --- a/racket/src/thread/custodian.rkt +++ b/racket/src/thread/custodian.rkt @@ -381,7 +381,9 @@ (raise-arguments-error who "the second custodian does not manage the first custodian" "first custodian" c "second custodian" super-c)) - (hash-keys (custodian-children c))) + (for/list ([v (in-hash-keys (custodian-children c))] + #:when (not (custodian-box? v))) + v)) (define (custodian-memory-accounting-available?) #t)