The current trunk still leaves threads in the ##sys#timeout-list when a
thread-join! joins successfully and the timeout is not reached.

No test case, take my word for it please.  I've seen them in the thread
listing and I've seen the joining thread getting unblocked by the left
over timeout when it did not expect to be unblocked at all.

Patch attached.

Best regards

/Jörg
Index: scheduler.scm
===================================================================
--- scheduler.scm	(Revision 12009)
+++ scheduler.scm	(Arbeitskopie)
@@ -36,7 +36,7 @@
 	##sys#update-thread-state-buffer ##sys#restore-thread-state-buffer
 	##sys#remove-from-ready-queue ##sys#unblock-threads-for-i/o ##sys#force-primordial
 	##sys#fdset-input-set ##sys#fdset-output-set ##sys#fdset-clear
-	##sys#fdset-select-timeout ##sys#fdset-restore ##sys#remove-from-timeout-list
+	##sys#fdset-select-timeout ##sys#fdset-restore
 	##sys#clear-i/o-state-for-thread!) 
   (foreign-declare #<<EOF
 #ifdef HAVE_ERRNO_H
Index: srfi-18.scm
===================================================================
--- srfi-18.scm	(Revision 12009)
+++ srfi-18.scm	(Arbeitskopie)
@@ -239,8 +239,13 @@
 	    ct 1
 	    (lambda ()
 	      (case (##sys#slot thread 3)
-		[(dead) (apply return (##sys#slot thread 2))]
+		[(dead)
+		 (if (not (##sys#slot thread 13) ) ; not unblocked by timeout
+		     (##sys#remove-from-timeout-list ct))
+		 (apply return (##sys#slot thread 2))]
 		[(terminated)
+		 (if (not (##sys#slot thread 13) ) ; not unblocked by timeout
+		     (##sys#remove-from-timeout-list ct))
 		 (return 
 		  (##sys#signal
 		   (##sys#make-structure 
@@ -392,8 +397,10 @@
 	     (cond [limit
 		    (##sys#setslot 
 		     ct 1
-		     (lambda () 
+		     (lambda ()
 		       (##sys#setslot cvar 2 (##sys#delq ct (##sys#slot cvar 2)))
+		       (if (not (##sys#slot ct 13) ) ; not unblocked by timeout
+			   (##sys#remove-from-timeout-list ct))
 		       (return #f) ) )
 		    (##sys#thread-block-for-timeout! ct limit) ]
 		   [else 
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to