if (in_flags_read & PR_POLL_READ) pd->out_flags |= PR_POLL_READ; if (in_flags_write & PR_POLL_READ) pd->out_flags |= PR_POLL_WRITE;
if (readReady) { if (in_flags_read & PR_POLL_READ) pd->out_flags |= PR_POLL_READ; if (in_flags_write & PR_POLL_READ) pd->out_flags |= PR_POLL_WRITE; } if (writeReady) { if (in_flags_read & PR_POLL_WRITE) pd->out_flags |= PR_POLL_READ; if (in_flags_write & PR_POLL_WRITE) pd->out_flags |= PR_POLL_WRITE; } if (exceptReady && (pd->in_flags & PR_POLL_EXCEPT)) { pd->out_flags |= PR_POLL_EXCEPT; } if (0 != pd->out_flags) ready++;
static PRInt32 CheckPollDescs(PRPollDesc *pds, PRIntn npds){    PRInt32 ready = 0;    PRPollDesc *pd, *epd;            for (pd = pds, epd = pd + npds; pd < epd; pd++)        {            PRInt16  in_flags_read = 0,  in_flags_write = 0;            PRInt16 out_flags_read = 0, out_flags_write = 0;            if (NULL == pd->fd || pd->in_flags == 0) continue;            if (pd->in_flags & PR_POLL_READ)            {                in_flags_read = (pd->fd->methods->poll)(                    pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read);            }            if (pd->in_flags & PR_POLL_WRITE)            {                in_flags_write = (pd->fd->methods->poll)(                    pd->fd, pd->in_flags & ~PR_POLL_READ, &out_flags_write);            }            if ((0 != (in_flags_read & out_flags_read))            || (0 != (in_flags_write & out_flags_write)))            {                ready += 1;  /* some layer has buffer input */                pd->out_flags = out_flags_read | out_flags_write;            }            else            {                PRFileDesc *bottomFD;                PRBool readReady, writeReady, exceptReady;                pd->out_flags = 0;  /* pre-condition */                bottomFD = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);                PR_ASSERT(NULL != bottomFD);                	            if (bottomFD && (_PR_FILEDESC_OPEN == bottomFD->secret->state))            {                    if (GetState(bottomFD, &readReady, &writeReady, &exceptReady))                    {                        if (readReady)                        {                            if (in_flags_read & PR_POLL_READ)                                pd->out_flags |= PR_POLL_READ;                            if (in_flags_write & PR_POLL_READ)                                pd->out_flags |= PR_POLL_WRITE;                        }                        if (writeReady)                        {                            if (in_flags_read & PR_POLL_WRITE)                                pd->out_flags |= PR_POLL_READ;                            if (in_flags_write & PR_POLL_WRITE)                                pd->out_flags |= PR_POLL_WRITE;                        }                        if (exceptReady && (pd->in_flags & PR_POLL_EXCEPT))                        {                            pd->out_flags |= PR_POLL_EXCEPT;                        }                        if (0 != pd->out_flags) ready++;                    }                }            else    /* bad state */                {                    ready += 1;  /* this will cause an abrupt return */                    pd->out_flags = PR_POLL_NVAL;  /* bogii */                }            }        }    return ready;}