Bug 1107702 - Try to avoid internal memory exhaustion problems with the Windows api GetAdaptersInfo by making a priming call to the api during startup. r=jesup

This commit is contained in:
Jim Mathies 2016-01-07 13:57:42 -06:00
parent 42f9491eee
commit 7e813c23e3
3 changed files with 27 additions and 0 deletions

View File

@ -78,6 +78,9 @@
#endif
#if defined (XP_WIN)
#include "mozilla/WindowsVersion.h"
#include <winsock2.h>
#include <iphlpapi.h>
#include <tchar.h>
#endif
// GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
@ -1640,6 +1643,28 @@ MediaManager::GetNonE10sParent()
return mNonE10sParent;
}
/* static */ void
MediaManager::StartupInit()
{
#ifdef WIN32
if (IsVistaOrLater() && !IsWin8OrLater()) {
// Bug 1107702 - Older Windows fail in GetAdaptersInfo (and others) if the
// first(?) call occurs after the process size is over 2GB (kb/2588507).
// Attempt to 'prime' the pump by making a call at startup.
unsigned long out_buf_len = sizeof(IP_ADAPTER_INFO);
PIP_ADAPTER_INFO pAdapterInfo = (IP_ADAPTER_INFO *) moz_xmalloc(out_buf_len);
if (GetAdaptersInfo(pAdapterInfo, &out_buf_len) == ERROR_BUFFER_OVERFLOW) {
free(pAdapterInfo);
pAdapterInfo = (IP_ADAPTER_INFO *) moz_xmalloc(out_buf_len);
GetAdaptersInfo(pAdapterInfo, &out_buf_len);
}
if (pAdapterInfo) {
free(pAdapterInfo);
}
}
#endif
}
/* static */
void
MediaManager::PostTask(const tracked_objects::Location& from_here, Task* task)

View File

@ -415,6 +415,7 @@ public:
// from MediaManager thread.
static MediaManager* Get();
static MediaManager* GetIfExists();
static void StartupInit();
static void PostTask(const tracked_objects::Location& from_here, Task* task);
#ifdef DEBUG
static bool IsInMediaThread();

View File

@ -261,6 +261,7 @@ nsLayoutStatics::Initialize()
}
AsyncLatencyLogger::InitializeStatics();
MediaManager::StartupInit();
CubebUtils::InitLibrary();
nsContentSink::InitializeStatics();