diff --git a/netwerk/base/public/nsISocketTransport.idl b/netwerk/base/public/nsISocketTransport.idl index 7556cd428d8e..ba8a8b0544b8 100644 --- a/netwerk/base/public/nsISocketTransport.idl +++ b/netwerk/base/public/nsISocketTransport.idl @@ -94,7 +94,9 @@ interface nsISocketTransport : nsITransport boolean isAlive(); /** - * Socket timeouts in seconds. + * Socket timeouts in seconds. To specify no timeout, pass PR_UINT32_MAX + * as aValue to setTimeout. The implementation may truncate timeout values + * to a smaller range of values (e.g., 0 to 0xFFFF). */ unsigned long getTimeout(in unsigned long aType); void setTimeout(in unsigned long aType, in unsigned long aValue); diff --git a/netwerk/base/src/nsServerSocket.cpp b/netwerk/base/src/nsServerSocket.cpp index c33711a7f666..c56cd721a8d8 100644 --- a/netwerk/base/src/nsServerSocket.cpp +++ b/netwerk/base/src/nsServerSocket.cpp @@ -219,11 +219,7 @@ nsServerSocket::OnSocketReady(PRFileDesc *fd, PRInt16 outFlags) { NS_ASSERTION(NS_SUCCEEDED(mCondition), "oops"); NS_ASSERTION(mFD == fd, "wrong file descriptor"); - - // If our poll timeout (of 2^16 seconds!) is reached, just go back to - // polling on the listening socket. - if (outFlags == -1) - return; + NS_ASSERTION(outFlags != -1, "unexpected timeout condition reached"); if (outFlags & (PR_POLL_ERR | PR_POLL_HUP | PR_POLL_NVAL)) { diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp index 0877257421cd..957e9d64a4c0 100644 --- a/netwerk/base/src/nsSocketTransport2.cpp +++ b/netwerk/base/src/nsSocketTransport2.cpp @@ -72,14 +72,6 @@ //----------------------------------------------------------------------------- -// Large default timeouts approximate behavior of no timeout. (It's better to -// let the servers or host operating system time us out.) These timeout values -// are given in seconds. -#define DEFAULT_TIMEOUT_CONNECT (10 * 60) -#define DEFAULT_TIMEOUT_READ_WRITE (10 * 60) - -//----------------------------------------------------------------------------- - static NS_DEFINE_CID(kSocketProviderServiceCID, NS_SOCKETPROVIDERSERVICE_CID); static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID); @@ -704,8 +696,8 @@ nsSocketTransport::nsSocketTransport() NS_ADDREF(gSocketTransportService); - mTimeouts[TIMEOUT_CONNECT] = DEFAULT_TIMEOUT_CONNECT; - mTimeouts[TIMEOUT_READ_WRITE] = DEFAULT_TIMEOUT_READ_WRITE; + mTimeouts[TIMEOUT_CONNECT] = PR_UINT16_MAX; // no timeout + mTimeouts[TIMEOUT_READ_WRITE] = PR_UINT16_MAX; // no timeout } nsSocketTransport::~nsSocketTransport() diff --git a/netwerk/base/src/nsSocketTransportService2.cpp b/netwerk/base/src/nsSocketTransportService2.cpp index 42fc720b8056..43f5663b2eab 100644 --- a/netwerk/base/src/nsSocketTransportService2.cpp +++ b/netwerk/base/src/nsSocketTransportService2.cpp @@ -568,7 +568,8 @@ nsSocketTransportService::Run() s.mElapsedTime = 0; s.mHandler->OnSocketReady(desc.fd, desc.out_flags); } - else { + // check for timeout errors unless disabled... + else if (s.mHandler->mPollTimeout != PR_UINT16_MAX) { // update elapsed time counter if (NS_UNLIKELY(pollInterval > (PR_UINT16_MAX - s.mElapsedTime))) s.mElapsedTime = PR_UINT16_MAX; diff --git a/netwerk/base/src/nsSocketTransportService2.h b/netwerk/base/src/nsSocketTransportService2.h index e62f572398c1..6aa8e5bd3169 100644 --- a/netwerk/base/src/nsSocketTransportService2.h +++ b/netwerk/base/src/nsSocketTransportService2.h @@ -95,6 +95,10 @@ public: // spent waiting for activity on this socket. if this timeout is reached, // then OnSocketReady will be called with outFlags = -1. // + // the default value for this member is PR_UINT16_MAX, which disables the + // timeout error checking. (i.e., a timeout value of PR_UINT16_MAX is + // never reached.) + // PRUint16 mPollTimeout; //