https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5a5ba1ad107d1af37241d…
commit 5a5ba1ad107d1af37241d444c567abc6f7cb6eb3
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Wed Apr 15 12:09:49 2020 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Wed Apr 22 12:37:26 2020 +0200
[SHSVCS] Don't call UnregisterWait from within the wait callback.
Doing this causes deadlocks, the process runs out of worker threads and
the system runs out of memory by allocating too many I/O completion ports
when using ntdll.dll from Windows.
---
base/services/shsvcs/thmserver.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/base/services/shsvcs/thmserver.c b/base/services/shsvcs/thmserver.c
index c4169446f44..a374079f9f8 100644
--- a/base/services/shsvcs/thmserver.c
+++ b/base/services/shsvcs/thmserver.c
@@ -76,7 +76,6 @@ CALLBACK
ThemeStopCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
{
CloseHandle(hServiceProcess);
- UnregisterWait(hThemeStopWaitObject);
UnregisterWait(hThemeServiceWaitObject);
ThemeWatchForStart();
@@ -92,7 +91,10 @@ ThemeServiceDiedCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
ResetEvent(hStartEvent);
ResetEvent(hStopEvent);
- ThemeStopCallback(lpParameter, TimerOrWaitFired);
+ CloseHandle(hServiceProcess);
+ UnregisterWait(hThemeStopWaitObject);
+ ThemeWatchForStart();
+ ThemeHooksRemove();
}
static
@@ -100,12 +102,10 @@ VOID
CALLBACK
ThemeStartCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
{
- UnregisterWait(hThemeStartWaitObject);
-
hServiceProcess = GetThemeServiceProcessHandle();
- RegisterWaitForSingleObject(&hThemeStopWaitObject, hStopEvent, ThemeStopCallback,
NULL, INFINITE, WT_EXECUTEDEFAULT);
- RegisterWaitForSingleObject(&hThemeServiceWaitObject, hServiceProcess,
ThemeServiceDiedCallback, NULL, INFINITE, WT_EXECUTEDEFAULT);
+ RegisterWaitForSingleObject(&hThemeStopWaitObject, hStopEvent, ThemeStopCallback,
NULL, INFINITE, WT_EXECUTEONLYONCE);
+ RegisterWaitForSingleObject(&hThemeServiceWaitObject, hServiceProcess,
ThemeServiceDiedCallback, NULL, INFINITE, WT_EXECUTEONLYONCE);
ThemeHooksInstall();
}
@@ -117,7 +117,7 @@ ThemeWatchForStart(VOID)
hStartEvent = CreateEventW(NULL, TRUE, FALSE, L"Global\\ThemeStartEvent");
hStopEvent = CreateEventW(NULL, TRUE, FALSE, L"Global\\ThemeStopEvent");
- RegisterWaitForSingleObject(&hThemeStartWaitObject, hStartEvent,
ThemeStartCallback, NULL, INFINITE, WT_EXECUTEDEFAULT);
+ RegisterWaitForSingleObject(&hThemeStartWaitObject, hStartEvent,
ThemeStartCallback, NULL, INFINITE, WT_EXECUTEONLYONCE);
return TRUE;
}