mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Backout 73512caf4647 (bug 692260) for Ts regression.
This commit is contained in:
parent
b9769b6f68
commit
3c4b80c685
@ -881,62 +881,8 @@ nsSocketTransportService::DiscoverMaxCount()
|
||||
PRInt32 version =
|
||||
(osInfo.dwMajorVersion & 0xff) << 8 |
|
||||
(osInfo.dwMinorVersion & 0xff);
|
||||
if (version >= 0x501) { /* xp or later */
|
||||
if (version >= 0x501) /* xp or later */
|
||||
gMaxCount = SOCKET_LIMIT_TARGET;
|
||||
|
||||
// Allocate and test a PR_Poll up to the gMaxCount number of unconnected
|
||||
// sockets. See bug 692260 - windows should be able to handle 1000 sockets
|
||||
// in select() without a problem, but LSPs have been known to balk at lower
|
||||
// numbers. (64 in the bug).
|
||||
|
||||
// Allocate
|
||||
struct PRPollDesc pfd[SOCKET_LIMIT_TARGET];
|
||||
PRUint32 numAllocated = 0;
|
||||
|
||||
for (PRUint32 index = 0 ; index < gMaxCount; ++index) {
|
||||
pfd[index].in_flags = PR_POLL_READ | PR_POLL_WRITE | PR_POLL_EXCEPT;
|
||||
pfd[index].out_flags = 0;
|
||||
pfd[index].fd = PR_OpenTCPSocket(PR_AF_INET);
|
||||
if (!pfd[index].fd) {
|
||||
SOCKET_LOG(("Socket Limit Test index %d failed\n", index));
|
||||
if (index < SOCKET_LIMIT_MIN)
|
||||
gMaxCount = SOCKET_LIMIT_MIN;
|
||||
else
|
||||
gMaxCount = index;
|
||||
break;
|
||||
}
|
||||
++numAllocated;
|
||||
}
|
||||
|
||||
// Test
|
||||
NS_ABORT_IF_FALSE(SOCKET_LIMIT_MIN >= 32U,
|
||||
"#defined socket_limit_min risks underflow");
|
||||
while (gMaxCount <= numAllocated) {
|
||||
PRInt32 rv = PR_Poll(pfd, gMaxCount, PR_MillisecondsToInterval(0));
|
||||
|
||||
SOCKET_LOG(("Socket Limit Test poll() size=%d rv=%d\n",
|
||||
gMaxCount, rv));
|
||||
|
||||
if (rv >= 0)
|
||||
break;
|
||||
|
||||
SOCKET_LOG(("Socket Limit Test poll confirmationSize=%d rv=%d error=%d\n",
|
||||
gMaxCount, rv, PR_GetError()));
|
||||
|
||||
gMaxCount -= 32;
|
||||
if (gMaxCount <= SOCKET_LIMIT_MIN) {
|
||||
gMaxCount = SOCKET_LIMIT_MIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Free
|
||||
for (PRUint32 index = 0 ; index < numAllocated; ++index)
|
||||
if (pfd[index].fd)
|
||||
PR_Close(pfd[index].fd);
|
||||
|
||||
SOCKET_LOG(("Socket Limit Test max was confirmed at %d\n", gMaxCount));
|
||||
}
|
||||
}
|
||||
#else
|
||||
// other platforms are harder to test - so leave at safe legacy value
|
||||
|
@ -839,17 +839,9 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_CallOnce(&nsSocketTransportService::gMaxCountInitOnce,
|
||||
nsSocketTransportService::DiscoverMaxCount);
|
||||
// Don't use the full max count because sockets can be held in
|
||||
// the persistent connection pool for a long time and that could
|
||||
// starve other users.
|
||||
|
||||
PRUint32 maxCount = nsSocketTransportService::gMaxCount;
|
||||
if (maxCount <= 8)
|
||||
maxCount = 1;
|
||||
else
|
||||
maxCount -= 8;
|
||||
mMaxConnections = (PRUint16) NS_CLAMP((PRUint32)val, 1, maxCount);
|
||||
|
||||
mMaxConnections =
|
||||
(PRUint16) NS_CLAMP((PRUint32)val, 1,
|
||||
nsSocketTransportService::gMaxCount);
|
||||
if (mConnMgr)
|
||||
mConnMgr->UpdateParam(nsHttpConnectionMgr::MAX_CONNECTIONS,
|
||||
mMaxConnections);
|
||||
|
Loading…
Reference in New Issue
Block a user