ntdll-Vista_Threadpool: Ensure condition min_workers <= max_workers holds all the time.

This commit is contained in:
Sebastian Lackner 2015-03-28 22:44:53 +01:00
parent 5e5cad6246
commit c9380eed86
2 changed files with 11 additions and 9 deletions

View File

@ -1,12 +1,12 @@
From 13635df17569be46833f21980ba22f2b4db85102 Mon Sep 17 00:00:00 2001
From 0fe9a4e96bdb45ca76e7abf0b73a69d24e1a3ce2 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 4 Mar 2015 00:16:20 +0100
Subject: ntdll: Implement TpSetPool[Min|Max]Threads.
Subject: ntdll: Implement TpSetPool[Min|Max]Threads. (v2)
---
dlls/ntdll/ntdll.spec | 2 ++
dlls/ntdll/threadpool.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
dlls/ntdll/threadpool.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index d9aafdd..88d915b 100644
@ -22,10 +22,10 @@ index d9aafdd..88d915b 100644
@ stdcall -ret64 VerSetConditionMask(int64 long long)
@ stdcall ZwAcceptConnectPort(ptr long ptr long long ptr) NtAcceptConnectPort
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index df92ef2..16d9209 100644
index cc5f8e9..cb2dcdd 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -1380,6 +1380,39 @@ VOID WINAPI TpReleasePool( TP_POOL *pool )
@@ -1387,6 +1387,41 @@ VOID WINAPI TpReleasePool( TP_POOL *pool )
}
/***********************************************************************
@ -39,7 +39,8 @@ index df92ef2..16d9209 100644
+ if (this)
+ {
+ RtlEnterCriticalSection( &this->cs );
+ this->max_workers = max(maximum, 1);
+ this->max_workers = max( maximum, 1 );
+ this->min_workers = min( this->min_workers, this->max_workers );
+ RtlLeaveCriticalSection( &this->cs );
+ }
+}
@ -55,7 +56,8 @@ index df92ef2..16d9209 100644
+ if (this)
+ {
+ RtlEnterCriticalSection( &this->cs );
+ this->min_workers = max(minimum, 1);
+ this->min_workers = max( minimum, 1 );
+ this->max_workers = max( this->min_workers, this->max_workers );
+ RtlLeaveCriticalSection( &this->cs );
+ }
+ return TRUE;

View File

@ -3284,7 +3284,7 @@ if test "$enable_ntdll_Vista_Threadpool" -eq 1; then
patch_apply ntdll-Vista_Threadpool/0020-kernel32-Forward-threadpool-wait-functions-to-ntdll.patch
(
echo '+ { "Sebastian Lackner", "ntdll: Implement TpSimpleTryPost and basic threadpool infrastructure.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Implement TpSetPool[Min|Max]Threads.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Implement TpSetPool[Min|Max]Threads.", 2 },';
echo '+ { "Sebastian Lackner", "ntdll: Implement threadpool cleanup group functions.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll/tests: Add tests for TpAllocCleanupGroup and related functions.", 1 },';
echo '+ { "Sebastian Lackner", "ntdll: Implement threadpool work item functions.", 1 },';