Skip to content

Commit efe39f3

Browse files
authored
Fix handling of negative numbers in ThreadPool.SetMin/MaxThreads (dotnet#24163)
* Fix handling of negative numbers in ThreadPool.SetMin/MaxThreads * Fix disabled test name
1 parent 447b655 commit efe39f3

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ internal static bool KeepDispatching(int startTickCount)
208208

209209
public static bool SetMaxThreads(int workerThreads, int completionPortThreads)
210210
{
211-
return SetMaxThreadsNative(workerThreads, completionPortThreads);
211+
return
212+
workerThreads >= 0 &&
213+
completionPortThreads >= 0 &&
214+
SetMaxThreadsNative(workerThreads, completionPortThreads);
212215
}
213216

214217
public static void GetMaxThreads(out int workerThreads, out int completionPortThreads)
@@ -218,7 +221,10 @@ public static void GetMaxThreads(out int workerThreads, out int completionPortTh
218221

219222
public static bool SetMinThreads(int workerThreads, int completionPortThreads)
220223
{
221-
return SetMinThreadsNative(workerThreads, completionPortThreads);
224+
return
225+
workerThreads >= 0 &&
226+
completionPortThreads >= 0 &&
227+
SetMinThreadsNative(workerThreads, completionPortThreads);
222228
}
223229

224230
public static void GetMinThreads(out int workerThreads, out int completionPortThreads)

tests/CoreFX/CoreFX.issues.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,20 @@
959959
]
960960
}
961961
},
962+
{
963+
"name": "System.Threading.ThreadPool.Tests",
964+
"enabled": true,
965+
"exclusions": {
966+
"namespaces": null,
967+
"classes": null,
968+
"methods": [
969+
{
970+
"name": "System.Threading.ThreadPools.Tests.ThreadPoolTests.SetMinMaxThreadsTest",
971+
"reason": "https://github.com/dotnet/corefx/issues/36885"
972+
}
973+
]
974+
}
975+
},
962976
{
963977
"name": "System.Memory.Tests",
964978
"enabled": true,

0 commit comments

Comments
 (0)