fix 278144 make setTimeout on SocketTransports adjust the timeout immediately, r=bzbarsky, sr=darin

This commit is contained in:
bienvenu%nventure.com 2005-02-01 15:22:20 +00:00
Родитель e062449619
Коммит 0821373cc7
3 изменённых файлов: 12 добавлений и 3 удалений

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

@ -1398,7 +1398,11 @@ nsSocketTransport::OnSocketEvent(PRUint32 type, nsresult status, nsISupports *pa
LOG((" MSG_OUTPUT_PENDING\n"));
OnMsgOutputPending();
break;
case MSG_TIMEOUT_CHANGED:
LOG((" MSG_TIMEOUT_CHANGED\n"));
mPollTimeout = mTimeouts[(mState == STATE_TRANSFERRING)
? TIMEOUT_READ_WRITE : TIMEOUT_CONNECT];
break;
default:
LOG((" unhandled event!\n"));
}
@ -1788,6 +1792,7 @@ nsSocketTransport::SetTimeout(PRUint32 type, PRUint32 value)
NS_ENSURE_ARG_MAX(type, nsISocketTransport::TIMEOUT_READ_WRITE);
// truncate overly large timeout values.
mTimeouts[type] = (PRUint16) PR_MIN(value, PR_UINT16_MAX);
PostEvent(MSG_TIMEOUT_CHANGED);
return NS_OK;
}

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

@ -167,6 +167,7 @@ private:
MSG_ENSURE_CONNECT,
MSG_DNS_LOOKUP_COMPLETE,
MSG_RETRY_INIT_SOCKET,
MSG_TIMEOUT_CHANGED,
MSG_INPUT_CLOSED,
MSG_INPUT_PENDING,
MSG_OUTPUT_CLOSED,

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

@ -310,8 +310,11 @@ nsSocketTransportService::PollTimeout()
PRUint32 minR = PR_UINT16_MAX;
for (PRUint32 i=0; i<mActiveCount; ++i) {
const SocketContext &s = mActiveList[i];
PRUint32 r = s.mHandler->mPollTimeout - s.mElapsedTime;
NS_ASSERTION(r <= s.mHandler->mPollTimeout, "oops");
// mPollTimeout could be less than mElapsedTime if setTimeout
// was called with a value smaller than mElapsedTime.
PRUint32 r = (s.mElapsedTime < s.mHandler->mPollTimeout)
? s.mHandler->mPollTimeout - s.mElapsedTime
: 0;
if (r < minR)
minR = r;
}