Commit fda1d4c4 authored by cls%seawood.org's avatar cls%seawood.org
Browse files

_MD_pr_poll should exit with error if select returns -1 and errno is not EINTR.

Bug #70808 r=darin
parent 721790a6
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
/* -*- 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 "License"); you may not use this file
@@ -600,8 +600,10 @@ _MD_pr_poll (PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)

			
			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)
@@ -610,6 +612,7 @@ _MD_pr_poll (PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
					n = 0;
				}
			    }
			}
			
		} while(n < 0 && errno == EINTR);
		
@@ -697,10 +700,13 @@ _MD_pr_poll (PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
				}
				
			}
		} 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;
}