_MD_pr_poll should exit with error if select returns -1 and errno is not EINTR. NSPRPUB_CLIENT_BRANCH
authorcls%seawood.org
Tue, 14 Aug 2001 00:59:49 +0000
branchNSPRPUB_CLIENT_BRANCH
changeset 2014 f77c2c58493a
parent 2011 f1aed729288d
push idunknown
push userunknown
push dateunknown
bugs70808
_MD_pr_poll should exit with error if select returns -1 and errno is not EINTR. Bug #70808 r=darin
pr/src/md/beos/bfile.c
--- a/pr/src/md/beos/bfile.c
+++ b/pr/src/md/beos/bfile.c
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 8; c-basic-offset: 8 -*- */
 /*
  * The contents of this file are subject to the Mozilla Public License
  * Version 1.1 (the "MPL"); you may not use this file except in
  * compliance with the MPL.  You may obtain a copy of the MPL at
  * http:// www.mozilla.org/MPL/
  *
  * Software distributed under the MPL is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
@@ -560,25 +560,28 @@ PRInt32
 			  /*printf("POLL: timeout = %ld\n", (long) PR_IntervalToMicroseconds(timeout));*/
 	      	  tv.tv_sec = PR_IntervalToSeconds(timeout);
 	      	  tv.tv_usec = PR_IntervalToMicroseconds(timeout) % PR_USEC_PER_SEC;
 	       	  tvp = &tv;
 			}
 
 			
 			n = select(maxfd + 1, &rd, &wr, 0, tvp);
-			/*printf("POLL: maxfd = %d, select returns %d\n", maxfd, n);*/
-		    if ((n <= 0) && (timeout != PR_INTERVAL_NO_TIMEOUT))
+			/*printf("POLL: maxfd = %d, select returns %d, errno = %d %s\n", maxfd, n, errno, strerror(errno));*/
+			if (n == 0 || (n < 0 && errno == EINTR))
 			{
+			    if (timeout != PR_INTERVAL_NO_TIMEOUT)
+			    {
 				timeout -= PR_IntervalNow() - start;
 				if(timeout <= 0)
 				{
 					/* timed out */
 					n = 0;
 				}
+			    }
 			}
 			
 		} while(n < 0 && errno == EINTR);
 		
 		if(n > 0)
 		{
 			epd = pds + npds;
 			for(pd = pds; pd < epd; pd++)
@@ -657,20 +660,23 @@ PRInt32
 						PR_Unlock( _connectLock );
 					}
 				} else {
 		        	pd->out_flags = 0;
                     continue;
 				}
 				
 			}
+		} else if (n < 0) {
+			/* hit error that's not EINTR. */
+			rc = -1;
 		}
 	}
 
-	/*printf("POLL: exiting _MD_pr_poll\n");*/
+	/*printf("POLL: exiting _MD_pr_poll with %d\n", rc);*/
 	return rc;
 }
 
 /*
  * File locking.
  */
 
 PRStatus