Open Bug 658138 Opened 11 years ago Updated 7 years ago

PR_Poll does not call poll method when PR_POLL_EXCEPT is requested without PR_POLL_READ or PR_POLL_WRITE

Categories

(NSPR :: NSPR, defect)

defect
Not set
normal

Tracking

(Not tracked)

People

(Reporter: mcmanus, Assigned: wtc)

Details

a PR_poll of a ssl socket using in_flags of (PR_POLL_READ | PR_POLL_EXCEPT) will generate PR_POLL_EXCEPT (or maybe PR_POLL_ERR - I forget) if PK11LoggedOut or AlreadyShutDown is satisified..

but a PR_poll of the same socket using just PR_POLL_EXCEPT returns no conditions.

as PR_POLL_READ is just a test of whether there is data available to to be read, it shouldn't impact this. I am pretty certain that PR_POLL_WRITE could be substituted for PR_POLL_READ.

found during bug 654201 - which has inserted an extraneous PR_POLL_READ check into the code to workaround this.
35 ERROR TEST-UNEXPECTED-FAIL | /tests/security/ssl/stricttransportsecurity/test_sts_privatebrowsing.html | Test timed out.

in the absence of PR_POLL_READ in nsSocketTransport::IsAlive() this test fails often - more often on linux and os x (though not all the time).. it is in mochitest-5
This is due to the following code in the (platform-specific) implementations of PR_Poll:

            if (pd->in_flags & PR_POLL_READ)
            {
                in_flags_read = (pd->fd->methods->poll)(
                    pd->fd, (PRInt16)(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, (PRInt16)(pd->in_flags & ~PR_POLL_READ),
                    &out_flags_write);
            }

If neither PR_POLL_READ or PR_POLL_WRITE is passed, then the poll method never gets called. Some poll methods (such as the one in PSM) return errors that are generated by non-network-related issues, and we (Mozilla) at one point tried to use PR_Poll to detect these errors.

Perhaps if neither PR_POLL_READ or PR_POLL_WRITE are passed in in_flags, but in_flags is nonzero, then we should call the poll method with in_flags.
Assignee: nobody → wtc
Component: Networking → NSPR
OS: Linux → All
Product: Core → NSPR
QA Contact: networking → nspr
Hardware: x86_64 → All
Summary: PR_Poll of ssl socket requires READ or WRITE to detect PK11LoggedOut / AlreadyShutDown → PR_Poll does not call poll method when PR_POLL_EXCEPT is requested without PR_POLL_READ or PR_POLL_WRITE
Version: unspecified → 4.9
You need to log in before you can comment on or make changes to this bug.