If we are re-awakened waiting on a thread-join! but without timing out,

try to join again to make sure it's really dead.
This commit is contained in:
Alex Shinn 2012-10-13 23:51:55 +09:00
parent b5046925f7
commit 3d161d4d2f

View file

@ -22,6 +22,7 @@
(define (thread-join! thread . o) (define (thread-join! thread . o)
(let ((timeout (and (pair? o) (car o)))) (let ((timeout (and (pair? o) (car o))))
(let lp ()
(cond (cond
((%thread-join! thread (timeout->seconds timeout)) ((%thread-join! thread (timeout->seconds timeout))
(thread-result thread)) (thread-result thread))
@ -33,7 +34,7 @@
(cadr o) (cadr o)
(error "timed out waiting for thread" thread))) (error "timed out waiting for thread" thread)))
(else (else
(thread-result thread))))))) (lp))))))))
(define (thread-terminate! thread) (define (thread-terminate! thread)
(if (%thread-terminate! thread) ;; need to yield if terminating ourself (if (%thread-terminate! thread) ;; need to yield if terminating ourself