From 2f2a7f977da3f0a6996a7d0a40434a0d39305dff Mon Sep 17 00:00:00 2001
From: dtc <dtc>
Date: Sat, 12 Aug 2000 15:05:24 +0000
Subject: [PATCH] Ensure that process-wait-until-fd-usable returns true unless
 there is a timeout; it had been incorrectly returning nil when the fd was
 immediately usable which caused trouble for CLX as noted by Fred Gilham.

---
 code/multi-proc.lisp | 52 ++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/code/multi-proc.lisp b/code/multi-proc.lisp
index 1ae61a597..3c165bab9 100644
--- a/code/multi-proc.lisp
+++ b/code/multi-proc.lisp
@@ -5,7 +5,7 @@
 ;;; the Public domain, and is provided 'as is'.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/multi-proc.lisp,v 1.37 1999/09/25 15:39:08 dtc Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/multi-proc.lisp,v 1.38 2000/08/12 15:05:24 dtc Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -1481,32 +1481,32 @@
 
 	(ecase direction
 	  (:input
-	   (unless (fd-usable-for-input)
-	     ;; Wait until input possible.
-	     (sys:with-fd-handler (fd :input
-				   #'(lambda (fd)
-				       (declare (ignore fd)
-						(optimize (speed 3)
-							  (safety 0)))
-				       (mp:process-yield)))
-	       (if timeout
-		   (mp:process-wait-with-timeout "Input Wait" timeout
-						 #'fd-usable-for-input)
-		   (mp:process-wait "Input Wait" #'fd-usable-for-input)))))
+	   (or (fd-usable-for-input)
+	       ;; Wait until input possible.
+	       (sys:with-fd-handler (fd :input
+					#'(lambda (fd)
+					    (declare (ignore fd)
+						     (optimize (speed 3)
+							       (safety 0)))
+					    (mp:process-yield)))
+		 (if timeout
+		     (mp:process-wait-with-timeout "Input Wait" timeout
+						   #'fd-usable-for-input)
+		     (mp:process-wait "Input Wait" #'fd-usable-for-input)))))
 	  (:output
-	   (unless (fd-usable-for-output)
-	     ;; Wait until output possible.
-	     (sys:with-fd-handler (fd :output
-				   #'(lambda (fd)
-				       (declare (ignore fd)
-						(optimize (speed 3)
-							  (safety 0)))
-				       (mp:process-yield)))
-	       (if timeout
-		   (mp:process-wait-with-timeout "Output Wait" timeout
-						 #'fd-usable-for-output)
-		   (mp:process-wait "Output Wait"
-				    #'fd-usable-for-output)))))))))
+	   (or (fd-usable-for-output)
+	       ;; Wait until output possible.
+	       (sys:with-fd-handler (fd :output
+					#'(lambda (fd)
+					    (declare (ignore fd)
+						     (optimize (speed 3)
+							       (safety 0)))
+					    (mp:process-yield)))
+		 (if timeout
+		     (mp:process-wait-with-timeout "Output Wait" timeout
+						   #'fd-usable-for-output)
+		     (mp:process-wait "Output Wait"
+				      #'fd-usable-for-output)))))))))
 
 
 ;;; Sleep  --  Public
-- 
GitLab