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.

Back-port of commit a5f26013ab.
This commit is contained in:
Matthew Flatt 2013-07-25 08:47:28 -06:00 committed by Ryan Culpepper
parent 129c5ed210
commit 055512590f

View File

@ -2957,6 +2957,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
(due to the lack of ordering on finalization) */
return;
}
mzrt_mutex_lock(ch->lock);
if (for_send)
ch->wr_ref += delta;