Bug 1135104 - increase send window on modern windows r=dragana

This commit is contained in:
Patrick McManus 2016-05-11 05:31:01 -04:00
Родитель fa35c9b317
Коммит f3e258d25a
3 изменённых файлов: 35 добавлений и 9 удалений

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

@ -4365,10 +4365,11 @@ pref("gfx.gralloc.fence-with-readpixels", false);
pref("stagefright.force-enabled", false);
pref("stagefright.disabled", false);
#ifdef XP_WIN
// The default TCP send window on Windows is too small, and autotuning only occurs on receive
pref("network.tcp.sendbuffer", 131072);
#endif
// sendbuffer of 0 means use OS default, sendbuffer unset means use
// gecko default which varies depending on windows version and is OS
// default on non windows
// pref("network.tcp.sendbuffer", 0);
// TCP Keepalive
pref("network.tcp.keepalive.enabled", true);
// Default idle time before first TCP keepalive probe; same time for interval

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

@ -27,6 +27,10 @@
#include "nsIFile.h"
#include "nsIWidget.h"
#if defined(XP_WIN)
#include "mozilla/WindowsVersion.h"
#endif
using namespace mozilla;
using namespace mozilla::net;
@ -1178,6 +1182,28 @@ nsSocketTransportService::DoPollIteration(TimeDuration *pollDuration)
return NS_OK;
}
void
nsSocketTransportService::UpdateSendBufferPref(nsIPrefBranch *pref)
{
int32_t bufferSize;
// If the pref is set, honor it. 0 means use OS defaults.
nsresult rv = pref->GetIntPref(SEND_BUFFER_PREF, &bufferSize);
if (NS_SUCCEEDED(rv)) {
mSendBufferSize = bufferSize;
return;
}
#if defined(XP_WIN)
// If the pref is not set but this is windows set it depending on windows version
if (!mozilla::IsWin2003OrLater()) { // windows xp
mSendBufferSize = 131072;
} else { // vista or later
mSendBufferSize = 131072 * 4;
}
#endif
}
nsresult
nsSocketTransportService::UpdatePrefs()
{
@ -1185,14 +1211,11 @@ nsSocketTransportService::UpdatePrefs()
nsCOMPtr<nsIPrefBranch> tmpPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (tmpPrefService) {
int32_t bufferSize;
nsresult rv = tmpPrefService->GetIntPref(SEND_BUFFER_PREF, &bufferSize);
if (NS_SUCCEEDED(rv) && bufferSize > 0)
mSendBufferSize = bufferSize;
UpdateSendBufferPref(tmpPrefService);
// Default TCP Keepalive Values.
int32_t keepaliveIdleTimeS;
rv = tmpPrefService->GetIntPref(KEEPALIVE_IDLE_TIME_PREF,
nsresult rv = tmpPrefService->GetIntPref(KEEPALIVE_IDLE_TIME_PREF,
&keepaliveIdleTimeS);
if (NS_SUCCEEDED(rv))
mKeepaliveIdleTimeS = clamped(keepaliveIdleTimeS,

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

@ -25,6 +25,7 @@
class nsASocketHandler;
struct PRPollDesc;
class nsIPrefBranch;
//-----------------------------------------------------------------------------
@ -210,6 +211,7 @@ private:
// Preference Monitor for SendBufferSize and Keepalive prefs.
nsresult UpdatePrefs();
void UpdateSendBufferPref(nsIPrefBranch *);
int32_t mSendBufferSize;
// Number of seconds of connection is idle before first keepalive ping.
int32_t mKeepaliveIdleTimeS;