From efe39f35933d89bb8f82472333810fddb78480b2 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Tue, 23 Apr 2019 10:18:46 -0400 Subject: [PATCH] Fix handling of negative numbers in ThreadPool.SetMin/MaxThreads (#24163) * Fix handling of negative numbers in ThreadPool.SetMin/MaxThreads * Fix disabled test name --- .../src/System/Threading/ThreadPool.CoreCLR.cs | 10 ++++++++-- tests/CoreFX/CoreFX.issues.json | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs index 76eb2db..723867b 100644 --- a/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs @@ -208,7 +208,10 @@ namespace System.Threading public static bool SetMaxThreads(int workerThreads, int completionPortThreads) { - return SetMaxThreadsNative(workerThreads, completionPortThreads); + return + workerThreads >= 0 && + completionPortThreads >= 0 && + SetMaxThreadsNative(workerThreads, completionPortThreads); } public static void GetMaxThreads(out int workerThreads, out int completionPortThreads) @@ -218,7 +221,10 @@ namespace System.Threading public static bool SetMinThreads(int workerThreads, int completionPortThreads) { - return SetMinThreadsNative(workerThreads, completionPortThreads); + return + workerThreads >= 0 && + completionPortThreads >= 0 && + SetMinThreadsNative(workerThreads, completionPortThreads); } public static void GetMinThreads(out int workerThreads, out int completionPortThreads) diff --git a/tests/CoreFX/CoreFX.issues.json b/tests/CoreFX/CoreFX.issues.json index 7613beb..3a3a17b 100644 --- a/tests/CoreFX/CoreFX.issues.json +++ b/tests/CoreFX/CoreFX.issues.json @@ -960,6 +960,20 @@ } }, { + "name": "System.Threading.ThreadPool.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Threading.ThreadPools.Tests.ThreadPoolTests.SetMinMaxThreadsTest", + "reason": "https://github.com/dotnet/corefx/issues/36885" + } + ] + } + }, + { "name": "System.Memory.Tests", "enabled": true, "exclusions": { -- 2.7.4