Closed
Bug 72965
Opened 24 years ago
Closed 24 years ago
PR_Poll can time out even when data is available
Categories
(NSPR :: NSPR, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: sfraser_bugs, Assigned: sfraser_bugs)
Details
Attachments
(1 file)
|
4.26 KB,
patch
|
Details | Diff | Splinter Review |
We have a race condition in the PR_Poll code now which can cause it to behave as
if no data is available on the socket, even when there is data. This causes
stalls in downloads for HTTP (see bug 60509) which are as long as the poll
timeout (35 seconds in Necko).
I've established using instrumentation that the problem occurs when the Notifier
fires before we've put the polling thread to sleep (a classic threaded I/O race
condition).
| Assignee | ||
Comment 1•24 years ago
|
||
There's another problem here as well, which is the way that we blindly wake the
polling thread from the Notifier routine (since this thread was set on the fd the
first time we polled that fd, and was left set). This has the effect that a
notification that comes in when the PR_Poll thread is not asleep write to wake a
thread on which io_pending is false, which seems wrong. Maybe PR_Poll should set
then clear the md.poll.thread members of each fd being polled each time around,
with the appropriate locks.
| Assignee | ||
Comment 2•24 years ago
|
||
| Assignee | ||
Comment 3•24 years ago
|
||
These changes fix PR_Poll on Mac thusly:
1. Factor out checking the fds into a new function CheckPollDescs()
2. Factor out setting/clearing the polling thread on those fds into
SetDescPollThread()
3. Be more careful about where we set the polling thread on the fds, ensuring
that we turn off interrupts and hold a lock around the code that sets up the
polling thread and checks for data on the fds. This fixes the race condition
that causes this bug.
4. We now clear the polling thread on the fds when coming out of PR_Poll, so that
the notifier doesn't attempt to wake the wrong thread when called when
we're not polling.
5. Implement a 0-timeout version that behaves like select().
Note that the macthr.c change is also in the patch in bug 60509.
Taking this bug for myself.
Reviews please.
Assignee: gordon → sfraser
Comment 4•24 years ago
|
||
r=larryh@netscape.com
To the best of my limited Mac ability, looks OK to me.
| Assignee | ||
Comment 5•24 years ago
|
||
I checked this in to the NSPR tip and the client branch.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•