From af2f257dc7b63e1e887f2f8a36bc76de7aef72e4 Mon Sep 17 00:00:00 2001 From: Shane Bryldt Date: Tue, 28 Mar 2017 19:18:20 -0600 Subject: [PATCH] FS-10167: Added test_thread_pools to windows build, added BREAK condition to wait for objects to be added to the queue before the workers prematurely exit. Fixed a bug in thread pool creation that wasn't showing up under linux test. --- libs/libks/libks.sln | 10 ++ libs/libks/src/ks_thread_pool.c | 4 +- libs/libks/test/test_thread_pools.vcxproj | 201 ++++++++++++++++++++++ 3 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 libs/libks/test/test_thread_pools.vcxproj diff --git a/libs/libks/libks.sln b/libs/libks/libks.sln index 5ee469ca09..a5c692585c 100644 --- a/libs/libks/libks.sln +++ b/libs/libks/libks.sln @@ -21,6 +21,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testwebsock", "test\testweb EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testacl", "test\testacl.vcxproj", "{1E6DE729-F4D4-4455-B64C-73B31C17E12C}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_thread_pools", "test\test_thread_pools.vcxproj", "{8AFFECE6-2A0B-4D44-990C-6D3DD832A250}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download OPENSSL", "..\win32\Download OPENSSL.2015.vcxproj", "{D578E676-7EC8-4548-BD8B-845C635F14AD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openssl", "..\win32\openssl\openssl.2015.vcxproj", "{25BD39B1-C8BF-4676-A738-9CABD9C6BC79}" @@ -104,6 +106,14 @@ Global {90D1C15C-59B0-470F-B18A-DA355948C736}.Release|x64.Build.0 = Release|x64 {90D1C15C-59B0-470F-B18A-DA355948C736}.Release|x86.ActiveCfg = Release|Win32 {90D1C15C-59B0-470F-B18A-DA355948C736}.Release|x86.Build.0 = Release|Win32 + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250}.Debug|x64.ActiveCfg = Debug|x64 + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250}.Debug|x64.Build.0 = Debug|x64 + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250}.Debug|x86.ActiveCfg = Debug|Win32 + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250}.Debug|x86.Build.0 = Debug|Win32 + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250}.Release|x64.ActiveCfg = Release|x64 + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250}.Release|x64.Build.0 = Release|x64 + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250}.Release|x86.ActiveCfg = Release|Win32 + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250}.Release|x86.Build.0 = Release|Win32 {1E6DE729-F4D4-4455-B64C-73B31C17E12C}.Debug|x64.ActiveCfg = Debug|x64 {1E6DE729-F4D4-4455-B64C-73B31C17E12C}.Debug|x64.Build.0 = Debug|x64 {1E6DE729-F4D4-4455-B64C-73B31C17E12C}.Debug|x86.ActiveCfg = Debug|Win32 diff --git a/libs/libks/src/ks_thread_pool.c b/libs/libks/src/ks_thread_pool.c index 9840b47944..9c5be83236 100644 --- a/libs/libks/src/ks_thread_pool.c +++ b/libs/libks/src/ks_thread_pool.c @@ -135,7 +135,7 @@ static void *worker_thread(ks_thread_t *thread, void *data) */ check_queue(tp, KS_FALSE); - if (status == KS_STATUS_TIMEOUT) { + if (status == KS_STATUS_TIMEOUT || status == KS_STATUS_BREAK) { idle_sec++; if (idle_sec >= tp->idle_sec) { @@ -195,7 +195,7 @@ KS_DECLARE(ks_status_t) ks_thread_pool_create(ks_thread_pool_t **tp, uint32_t mi ks_pool_open(&pool); - *tp = (ks_thread_pool_t *) ks_pool_alloc(pool, sizeof(ks_thread_t)); + *tp = (ks_thread_pool_t *) ks_pool_alloc(pool, sizeof(ks_thread_pool_t)); (*tp)->min = min; (*tp)->max = max; diff --git a/libs/libks/test/test_thread_pools.vcxproj b/libs/libks/test/test_thread_pools.vcxproj new file mode 100644 index 0000000000..4d4af37be5 --- /dev/null +++ b/libs/libks/test/test_thread_pools.vcxproj @@ -0,0 +1,201 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {8AFFECE6-2A0B-4D44-990C-6D3DD832A250} + Win32Proj + test_thread_pools + 8.1 + + + + Application + true + v140_xp + Unicode + + + Application + false + v140_xp + true + Unicode + + + Application + true + v140_xp + Unicode + + + Application + false + v140_xp + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Platform)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include;$(IncludePath) + $(LibraryPath) + + + true + $(Platform)\$(Configuration)\$(ProjectName)\ + $(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include64;$(IncludePath) + $(LibraryPath) + + + false + $(Platform)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include;$(IncludePath) + $(LibraryPath) + + + false + $(Platform)\$(Configuration)\$(ProjectName)\ + $(SolutionDir);$(SolutionDir)\crypt;$(SolutionDir)\openssl\include64;$(IncludePath) + $(LibraryPath) + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)..\win32\openssl\include;$(SolutionDir)..\win32\openssl\include_x86;../src/include;. + 4090 + true + false + + + Console + true + %(AdditionalDependencies) + + + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)..\win32\openssl\include;$(SolutionDir)..\win32\openssl\include_x64;../src/include;. + 4090 + true + false + + + Console + true + %(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)..\win32\openssl\include;$(SolutionDir)..\win32\openssl\include_x86;../src/include;. + 4090 + true + + + Console + true + true + true + %(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir)..\win32\openssl\include;$(SolutionDir)..\win32\openssl\include_x64;../src/include;. + 4090 + true + + + Console + true + true + true + %(AdditionalDependencies) + + + + + {d331904d-a00a-4694-a5a3-fcff64ab5dbe} + + + {25bd39b1-c8bf-4676-a738-9cabd9c6bc79} + + + {b4b62169-5ad4-4559-8707-3d933ac5db39} + + + {70d178d8-1100-4152-86c0-809a91cff832} + + + + + + + + + + \ No newline at end of file