fix ffi retain of callbacks
The FFI's weak table of callback procedures (to map Racket procedures
to FFI callback objects) suffered from the classic key-in-value
problem.
Closes PR 12228, probably
Merge to 5.2
(cherry picked from commit 8bd81f4806
)
This commit is contained in:
parent
fd03fb8575
commit
6fe0b33625
|
@ -446,7 +446,7 @@
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(and x
|
(and x
|
||||||
(let ([cb (ffi-callback (wrap x) itypes otype abi atomic? async-apply)])
|
(let ([cb (ffi-callback (wrap x) itypes otype abi atomic? async-apply)])
|
||||||
(cond [(eq? keep #t) (hash-set! held-callbacks x cb)]
|
(cond [(eq? keep #t) (hash-set! held-callbacks x (make-ephemeron x cb))]
|
||||||
[(box? keep)
|
[(box? keep)
|
||||||
(let ([x (unbox keep)])
|
(let ([x (unbox keep)])
|
||||||
(set-box! keep
|
(set-box! keep
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
(define (can-try-atomic?) (and (freezer-box) (not (in-try-atomic?))))
|
(define (can-try-atomic?) (and (freezer-box) (not (in-try-atomic?))))
|
||||||
|
|
||||||
;; prevent GC of handler while it's installed:
|
;; prevent GC of handler while it's installed:
|
||||||
(define saved-ptrs (make-hash))
|
(define saved-ptrs (make-hasheq))
|
||||||
|
|
||||||
(define (try-atomic thunk default
|
(define (try-atomic thunk default
|
||||||
#:should-give-up? [should-give-up?
|
#:should-give-up? [should-give-up?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user