From: Matt Birkholz Date: Fri, 4 May 2012 20:58:14 +0000 (-0700) Subject: Guard against other threads unwinding block-on-io-descriptor. X-Git-Tag: release-9.2.0~247^2~17 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=7996450cfd3890ac34c89975beea0355ffb2dcbc;p=mit-scheme.git 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. --- 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