place: fix finalizaiton of place channels stuck in a GC'ed channel
Lack of ordering on finalization requires some care for explicit clean-up actions in a finalizer.
This commit is contained in:
parent
25c5f5e839
commit
a5f26013ab
|
@ -0,0 +1,15 @@
|
|||
#lang racket/base
|
||||
(require racket/place)
|
||||
|
||||
;; Check finalization of place channels that are
|
||||
;; abandoned in unreferenced place channels.
|
||||
(let loop ([n 0])
|
||||
(unless (= n 50000)
|
||||
(define-values (i o) (place-channel))
|
||||
(define-values (i2 o2) (place-channel))
|
||||
(place-channel-put i o2)
|
||||
(place-channel-put o i2)
|
||||
(loop (add1 n))))
|
||||
'ok
|
||||
|
||||
|
|
@ -2982,6 +2982,11 @@ Scheme_Place_Async_Channel *place_async_channel_create() {
|
|||
|
||||
static void async_channel_refcount(Scheme_Place_Async_Channel *ch, int for_send, int delta)
|
||||
{
|
||||
if (!ch->lock) {
|
||||
/* can happen via finalization, where the channel is already finalized
|
||||
m(due to the lack of ordering on finalization) */
|
||||
return;
|
||||
}
|
||||
mzrt_mutex_lock(ch->lock);
|
||||
if (for_send)
|
||||
ch->wr_ref += delta;
|
||||
|
|
Loading…
Reference in New Issue
Block a user