Commit 676b50fe authored by Kershaw Chang's avatar Kershaw Chang Committed by Richard Pospesel
Browse files

Bug 1767920 - Increase thread stack size on windows (for ESR 102), r=#necko, a=dmeehan

parent be6e2ad7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -9896,6 +9896,11 @@
  value: true
  mirror: always

- name: network.allow_large_stack_size_for_socket_thread
  type: RelaxedAtomicBool
  value: true
  mirror: always

#---------------------------------------------------------------------------
# Prefs starting with "nglayout."
#---------------------------------------------------------------------------
+17 −2
Original line number Diff line number Diff line
@@ -716,6 +716,21 @@ void nsSocketTransportService::UpdatePrefs(const char* aPref, void* aSelf) {
  static_cast<nsSocketTransportService*>(aSelf)->UpdatePrefs();
}

static uint32_t GetThreadStackSize() {
#ifdef XP_WIN
  if (!StaticPrefs::network_allow_large_stack_size_for_socket_thread()) {
    return nsIThreadManager::DEFAULT_STACK_SIZE;
  }

  const uint32_t kWindowsThreadStackSize = 512 * 1024;
  // We can remove this custom stack size when DEFAULT_STACK_SIZE is increased.
  static_assert(kWindowsThreadStackSize > nsIThreadManager::DEFAULT_STACK_SIZE);
  return kWindowsThreadStackSize;
#else
  return nsIThreadManager::DEFAULT_STACK_SIZE;
#endif
}

// called from main thread only
NS_IMETHODIMP
nsSocketTransportService::Init() {
@@ -733,8 +748,8 @@ nsSocketTransportService::Init() {
  }

  nsCOMPtr<nsIThread> thread;
  nsresult rv =
      NS_NewNamedThread("Socket Thread", getter_AddRefs(thread), this);
  nsresult rv = NS_NewNamedThread("Socket Thread", getter_AddRefs(thread), this,
                                  GetThreadStackSize());
  NS_ENSURE_SUCCESS(rv, rv);

  {