summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2002-10-25 12:41:00 +0000
committerwtc%netscape.com <devnull@localhost>2002-10-25 12:41:00 +0000
commit816a939626adc0c2517139741e97931cda91f9d8 (patch)
tree4cdaa65acef579f3971a7b6a65db3c4ef143b719
parent437aa2ecfe75fc43708e34daa5e72fe71791749e (diff)
downloadnspr-hg-816a939626adc0c2517139741e97931cda91f9d8.tar.gz
Bug 168831: fixed the bug that PR_Poll was ignoring out_flags reported byPHOENIX_0_4_RELEASE
the poll methods of I/O layers on the Mac. This patch was written by jgmyers and reviewed by sfraser and wtc. a=dbaron for NSPRPUB_PRE_4_2_CLIENT_BRANCH checkin.
-rw-r--r--pr/src/md/mac/macsockotpt.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/pr/src/md/mac/macsockotpt.c b/pr/src/md/mac/macsockotpt.c
index 42462740..6c54de4c 100644
--- a/pr/src/md/mac/macsockotpt.c
+++ b/pr/src/md/mac/macsockotpt.c
@@ -1776,6 +1776,8 @@ static PRInt32 CheckPollDescMethods(PRPollDesc *pds, PRIntn npds, PRInt16 *outRe
PRInt16 in_flags_read = 0, in_flags_write = 0;
PRInt16 out_flags_read = 0, out_flags_write = 0;
+ pd->out_flags = 0;
+
if (NULL == pd->fd || pd->in_flags == 0) continue;
if (pd->in_flags & PR_POLL_READ)
@@ -1823,14 +1825,17 @@ static PRInt32 CheckPollDescEndpoints(PRPollDesc *pds, PRIntn npds, const PRInt1
if (NULL == pd->fd || pd->in_flags == 0) continue;
+ if ((pd->in_flags & ~pd->out_flags) == 0) {
+ ready++;
+ continue;
+ }
+
bottomFD = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
/* bottomFD can be NULL for pollable sockets */
if (bottomFD)
{
if (_PR_FILEDESC_OPEN == bottomFD->secret->state)
{
- pd->out_flags = 0; /* pre-condition */
-
if (GetState(bottomFD, &readReady, &writeReady, &exceptReady))
{
if (readReady)
@@ -1851,8 +1856,8 @@ static PRInt32 CheckPollDescEndpoints(PRPollDesc *pds, PRIntn npds, const PRInt1
{
pd->out_flags |= PR_POLL_EXCEPT;
}
- if (0 != pd->out_flags) ready++;
}
+ if (0 != pd->out_flags) ready++;
}
else /* bad state */
{
@@ -1948,13 +1953,14 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
writeFlags = &ioFlags[npds];
}
- if (timeout != PR_INTERVAL_NO_WAIT) {
+ // we have to be outside the lock when calling this, since
+ // it can call arbitrary user code (including other socket
+ // entry points)
+ ready = CheckPollDescMethods(pds, npds, readFlags, writeFlags);
+
+ if (!ready && timeout != PR_INTERVAL_NO_WAIT) {
intn is;
- // we have to be outside the lock when calling this, since
- // it can call arbitrary user code (including other socket
- // entry points)
- (void)CheckPollDescMethods(pds, npds, readFlags, writeFlags);
_PR_INTSOFF(is);
PR_Lock(thread->md.asyncIOLock);
@@ -1975,17 +1981,14 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
// since we may have been woken by a pollable event firing,
// we have to check both poll methods and endpoints.
(void)CheckPollDescMethods(pds, npds, readFlags, writeFlags);
- (void)CheckPollDescEndpoints(pds, npds, readFlags, writeFlags);
- ready = CountReadyPollDescs(pds, npds);
+ ready = CheckPollDescEndpoints(pds, npds, readFlags, writeFlags);
}
thread->io_pending = PR_FALSE;
SetDescPollThread(pds, npds, NULL);
}
else {
- (void)CheckPollDescMethods(pds, npds, readFlags, writeFlags);
- (void)CheckPollDescEndpoints(pds, npds, readFlags, writeFlags);
- ready = CountReadyPollDescs(pds, npds);
+ ready = CheckPollDescEndpoints(pds, npds, readFlags, writeFlags);
}
if (readFlags != readFlagsArray)