From 17157945bb417652840e94deba5bea4a2f1b3cb0 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 5 Feb 2011 16:33:02 -0700 Subject: [PATCH] fix scheduler's support for `ffi/unsafe/try-atomic' where problems with abort-without-dynamic-wind mode caused a spurious trigger of nack evts Merge to 5.1 (cherry picked from commit 3e38071dae88590befcb46ef953e123447af5e3f) --- src/racket/include/scheme.h | 5 ++++- src/racket/src/sema.c | 3 ++- src/racket/src/thread.c | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/racket/include/scheme.h b/src/racket/include/scheme.h index 58e50d815d..60d500d28c 100644 --- a/src/racket/include/scheme.h +++ b/src/racket/include/scheme.h @@ -1155,7 +1155,10 @@ typedef void (*Scheme_Kill_Action_Func)(void *); thread = NULL; \ if (scheme_setjmp(newbuf)) { \ scheme_pop_kill_action(); \ - func(data); \ + thread = scheme_get_current_thread(); \ + if (!thread->cjs.skip_dws) { \ + func(data); \ + } \ scheme_longjmp(*savebuf, 1); \ } else { # define END_ESCAPEABLE() \ diff --git a/src/racket/src/sema.c b/src/racket/src/sema.c index 37cab3e519..0953a3117e 100644 --- a/src/racket/src/sema.c +++ b/src/racket/src/sema.c @@ -654,7 +654,8 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci } else if (semas[i]->so.type == scheme_never_evt_type) { /* Never ready. */ } else if (semas[i]->so.type == scheme_channel_syncer_type) { - /* Probably no need to poll */ + if (((Scheme_Channel_Syncer *)semas[i])->picked) + break; } else if (try_channel(semas[i], syncing, i, NULL)) break; } diff --git a/src/racket/src/thread.c b/src/racket/src/thread.c index 85697facc9..988507af57 100644 --- a/src/racket/src/thread.c +++ b/src/racket/src/thread.c @@ -4051,6 +4051,9 @@ static void call_on_atomic_timeout(int must) Scheme_Object *blocker; Scheme_Ready_Fun block_check; Scheme_Needs_Wakeup_Fun block_needs_wakeup; + Scheme_Kill_Action_Func private_on_kill; + void *private_kill_data; + void **private_kill_next; /* Save any state that has to do with the thread blocking or sleeping, in case scheme_on_atomic_timeout() runs Racket code. */ @@ -4062,6 +4065,10 @@ static void call_on_atomic_timeout(int must) block_check = p->block_check; block_needs_wakeup = p->block_needs_wakeup; + private_on_kill = p->private_on_kill; + private_kill_data = p->private_kill_data; + private_kill_next = p->private_kill_next; + p->running = MZTHREAD_RUNNING; p->sleep_end = 0.0; p->block_descriptor = 0; @@ -4077,6 +4084,10 @@ static void call_on_atomic_timeout(int must) p->blocker = blocker; p->block_check = block_check; p->block_needs_wakeup = block_needs_wakeup; + + p->private_on_kill = private_on_kill; + p->private_kill_data = private_kill_data; + p->private_kill_next = private_kill_next; } static void find_next_thread(Scheme_Thread **return_arg) {