Fix for bug 129364. Eliminate a window of time in which notifiers could fire when we hadn't set up the polling thread on the poll descriptors, which could cause lost notifications and FTP stalls. Also revert to PR_FAST_INTSON() from PR_INTSON(), which seems to fix a permanent stall issue on Mac OS X. r=wtc

This commit is contained in:
sfraser%netscape.com 2002-03-09 02:16:49 +00:00
Родитель daeee0147c
Коммит 188c1b0375
1 изменённых файлов: 30 добавлений и 27 удалений

Просмотреть файл

@ -1931,8 +1931,6 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
PRThread *thread = _PR_MD_CURRENT_THREAD();
PRInt32 ready;
intn is;
PRBool needsToWait = PR_FALSE;
if (npds > DESCRIPTOR_FLAGS_ARRAY_SIZE)
{
@ -1949,39 +1947,44 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
writeFlags = &ioFlags[npds];
}
if (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);
PrepareForAsyncCompletion(thread, 0);
SetDescPollThread(pds, npds, thread);
(void)CheckPollDescEndpoints(pds, npds, readFlags, writeFlags);
ready = CountReadyPollDescs(pds, npds);
if ((ready == 0) && (timeout != PR_INTERVAL_NO_WAIT))
{
PrepareForAsyncCompletion(thread, 0);
SetDescPollThread(pds, npds, thread);
needsToWait = PR_TRUE;
}
PR_Unlock(thread->md.asyncIOLock);
_PR_INTSON(is);
_PR_FAST_INTSON(is);
if (needsToWait)
{
ready = CountReadyPollDescs(pds, npds);
if (ready == 0) {
WaitOnThisThread(thread, timeout);
// since we may have been woken by a pollable event
// firing, we have to check both poll methods and
// endpoints.
// 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);
}
thread->io_pending = PR_FALSE;
SetDescPollThread(pds, npds, NULL);
}
else {
thread->io_pending = PR_FALSE;
(void)CheckPollDescMethods(pds, npds, readFlags, writeFlags);
(void)CheckPollDescEndpoints(pds, npds, readFlags, writeFlags);
ready = CountReadyPollDescs(pds, npds);
}
if (readFlags != readFlagsArray)