From 7996450cfd3890ac34c89975beea0355ffb2dcbc Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Fri, 4 May 2012 13:58:14 -0700 Subject: [PATCH] Guard against other threads unwinding block-on-io-descriptor. This only arises when another thread uses within-continuation to unwind block-on-io-descriptor. Such an unwinding can leave the console-thread waiting for nothing. With no other io-registrations nor runnable threads, the runtime busy-waits. --- src/runtime/thread.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/runtime/thread.scm b/src/runtime/thread.scm index 5dd6f48f5..6c8ab6195 100644 --- a/src/runtime/thread.scm +++ b/src/runtime/thread.scm @@ -524,9 +524,14 @@ USA. (%suspend-current-thread) result) (lambda () - (%deregister-io-thread-event registration-2) - (%deregister-io-thread-event registration-1) + (%maybe-deregister-io-thread-event registration-2) + (%maybe-deregister-io-thread-event registration-1) (%maybe-toggle-thread-timer))))))) + +(define (%maybe-deregister-io-thread-event tentry) + ;; Ensure that another thread does not unwind our registration. + (if (eq? (current-thread) (tentry/thread tentry)) + (delete-tentry! tentry))) (define (permanently-register-io-thread-event descriptor mode thread event) (register-io-thread-event-1 descriptor mode thread event -- 2.25.1