Commit 634a50b2 authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

[policy] Boost thread priority while loading netapi32.dll

On issue 1082862 I noticed that the function IsDomainJoined() is holding
the library loader lock from a background thread while a number of other
threads are trying to load libraries and have gotten stuck.

This macro temporarily boosts the priority of the background thread in
order to prevent this kind of jank.

Bug: 973868
Change-Id: Ife748cc7d42fa50525e6ddc5edf4ef95d23f10d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2203234
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Pavol Marko <pmarko@chromium.org>
Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769900}
parent d3bf70b2
......@@ -33,6 +33,7 @@
#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/threading/scoped_thread_priority.h"
#include "base/values.h"
#include "base/win/shlwapi.h" // For PathIsUNC()
#include "base/win/win_util.h"
......@@ -216,6 +217,10 @@ bool IsDomainJoined() {
// Use an absolute path to load the DLL to avoid DLL preloading attacks.
base::FilePath path;
if (base::PathService::Get(base::DIR_SYSTEM, &path)) {
// Mitigate the issues caused by loading DLLs on a background thread
// (http://crbug/973868).
SCOPED_MAY_LOAD_LIBRARY_AT_BACKGROUND_PRIORITY_REPEATEDLY();
HINSTANCE net_api_library = ::LoadLibraryEx(
path.Append(FILE_PATH_LITERAL("netapi32.dll")).value().c_str(), nullptr,
LOAD_WITH_ALTERED_SEARCH_PATH);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment