From 3ad6f814110c732fe7fe4cfaa00f56721008cbf2 Mon Sep 17 00:00:00 2001 From: Divya Sampath Kumar Date: Thu, 21 Sep 2023 09:59:26 -0700 Subject: [PATCH] Threadpool context for WebRTC (#1810) * Threadpool context for WebRTC * Disable for windows * Include directory to shared library for windows * Remove context object, use envs to allow configuring threadpool * Include README changes * Get back threadpool context This reverts commit 23070567312595da555d1688cf21c335105543f7. * Move thread sleep to unit tests * Revert sleep from test to main file * Remove threadpool usage from signaling * Rebased off develop * Add locks around threadpool calls --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 14 +- README.md | 9 +- samples/Common.c | 2 - samples/Samples.h | 4 - .../kinesis/video/webrtcclient/Include.h | 28 +++- src/source/Include_i.h | 1 + src/source/PeerConnection/PeerConnection.c | 9 +- src/source/Signaling/LwsApiCalls.c | 3 +- src/source/Signaling/Signaling.c | 10 -- src/source/Signaling/Signaling.h | 4 - src/source/Threadpool/ThreadPoolContext.c | 94 +++++++++++ src/source/Threadpool/ThreadpoolContext.h | 31 ++++ tst/SignalingApiFunctionalityTest.cpp | 146 ++---------------- tst/WebRTCClientTestFixture.cpp | 2 + tst/WebRTCClientTestFixture.h | 2 - 16 files changed, 194 insertions(+), 167 deletions(-) create mode 100644 src/source/Threadpool/ThreadPoolContext.c create mode 100644 src/source/Threadpool/ThreadpoolContext.h diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6de96ba0b..9e55e51c37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -482,7 +482,7 @@ jobs: - name: Run tests shell: powershell run: | - $env:Path += ';C:\webrtc\open-source\bin;C:\tools\pthreads-w32-2-9-1-release\Pre-built.2\dll\x64' + $env:Path += ';C:\webrtc\open-source\bin;C:\tools\pthreads-w32-2-9-1-release\Pre-built.2\dll\x64;C:\webrtc\build' & "C:\webrtc\build\tst\webrtc_client_test.exe" --gtest_filter="-DataChannelFunctionalityTest.*:IceApiTest.*:IceFunctionalityTest.*:PeerConnectionFunctionalityTest.*:SignalingApiFunctionalityTest.*:TurnConnectionFunctionalityTest.*:RtpFunctionalityTest.marshallUnmarshallH264Data:RtpFunctionalityTest.packingUnpackingVerifySameH264Frame:RtcpFunctionalityTest.onRtcpPacketCompound:RtcpFunctionalityTest.twcc3" # windows-msvc-mbedtls: # runs-on: windows-2022 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bdf9dcf5b..5da2ec0b0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,7 +332,6 @@ file(GLOB WEBRTC_SIGNALING_CLIENT_SOURCE_FILES "src/source/Signaling/*.c") include_directories(${OPEN_SRC_INCLUDE_DIRS}) include_directories(${OPEN_SRC_INSTALL_PREFIX}/include) include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/include) -include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/ice) add_library(kvsWebrtcClient ${LINKAGE} ${WEBRTC_CLIENT_SOURCE_FILES} ${DATACHANNEL_SRC}) @@ -340,6 +339,14 @@ if(USE_MBEDTLS) target_compile_definitions(kvsWebrtcClient PRIVATE LWS_WITH_MBEDTLS) endif() +# The library **MUST** have a shared linkage. This library is used by both WebRtc client an +#signaling client. +if(ENABLE_KVS_THREADPOOL) + file(GLOB THREADPOOL_SOURCE_FILES "src/source/Threadpool/ThreadPoolContext.c") + add_library(kvsWebRtcThreadpool SHARED ${THREADPOOL_SOURCE_FILES}) + target_link_libraries(kvsWebRtcThreadpool PRIVATE kvspicUtils) +endif() + target_link_libraries( kvsWebrtcClient PRIVATE kvspicUtils @@ -360,6 +367,11 @@ if(USE_MBEDTLS) target_compile_definitions(kvsWebrtcSignalingClient PRIVATE LWS_WITH_MBEDTLS) endif() +if(ENABLE_KVS_THREADPOOL) + target_link_libraries(kvsWebrtcClient PRIVATE kvsWebRtcThreadpool) + target_link_libraries(kvsWebrtcSignalingClient PRIVATE kvsWebRtcThreadpool) +endif() + target_link_libraries( kvsWebrtcSignalingClient PUBLIC diff --git a/README.md b/README.md index 81f11f54c5..5bbf3586e3 100644 --- a/README.md +++ b/README.md @@ -358,9 +358,12 @@ When building on MacOS M1, if the build fails while trying to build OpenSSL or W To build on a 32-bit Raspbian GNU/Linux 11 on 64-bit hardware, the OpenSSL library must be manually configured. This is due to the OpenSSL autoconfiguration script detecting 64-bit hardware and emitting 64-bit ARM assembly instructions which are not allowed in 32-bit executables. A 32-bit ARM version of OpenSSL can be configured by setting 32-bit ARM platform: `cmake .. -DBUILD_OPENSSL_PLATFORM=linux-armv4` -### Threadpool for Signaling Channel messages -The threadpool is enabled by default, and starts with 3 threads that it can increase up to 5 if all 3 are actively in use. To change these values to better match the resources of your use case -please edit samples/Samples.h defines `KVS_SIGNALING_THREADPOOL_MIN` and `KVS_SIGNALING_THREADPOOL_MAX`. You can also disable the threadpool to instead create and detach each thread to handle signaling messages by disabling the flag `-DENABLE_KVS_THREADPOOL` while building with cmake. +### Threadpool for the SDK +The threadpool is enabled by default, and starts with 5 threads that it can increase up to 10 if all are actively in use. To change these values to better match the resources of your use case you can set the environment variables to do so: +1. `export AWS_KVS_WEBRTC_THREADPOOL_MIN_THREADS=` +2. `export AWS_KVS_WEBRTC_THREADPOOL_MAX_THREADS=` + +To disable threadpool, run `cmake .. -DENABLE_KVS_THREADPOOL=OFF` ## Documentation All Public APIs are documented in our [Include.h](https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/master/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h), we also generate a [Doxygen](https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-c/) each commit for easier navigation. diff --git a/samples/Common.c b/samples/Common.c index 97898a13da..2380054e76 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -838,8 +838,6 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE pSampleConfiguration->clientInfo.loggingLevel = logLevel; pSampleConfiguration->clientInfo.cacheFilePath = NULL; // Use the default path pSampleConfiguration->clientInfo.signalingClientCreationMaxRetryAttempts = CREATE_SIGNALING_CLIENT_RETRY_ATTEMPTS_SENTINEL_VALUE; - pSampleConfiguration->clientInfo.signalingMessagesMinimumThreads = KVS_SIGNALING_THREADPOOL_MIN; - pSampleConfiguration->clientInfo.signalingMessagesMaximumThreads = KVS_SIGNALING_THREADPOOL_MAX; pSampleConfiguration->iceCandidatePairStatsTimerId = MAX_UINT32; pSampleConfiguration->pregenerateCertTimerId = MAX_UINT32; pSampleConfiguration->signalingClientMetrics.version = SIGNALING_CLIENT_METRICS_CURRENT_VERSION; diff --git a/samples/Samples.h b/samples/Samples.h index ba0ba9e56a..1bb705b800 100644 --- a/samples/Samples.h +++ b/samples/Samples.h @@ -52,10 +52,6 @@ extern "C" { #define MASTER_DATA_CHANNEL_MESSAGE "This message is from the KVS Master" #define VIEWER_DATA_CHANNEL_MESSAGE "This message is from the KVS Viewer" -// Signaling client threadpool for handling messages -#define KVS_SIGNALING_THREADPOOL_MIN 3 -#define KVS_SIGNALING_THREADPOOL_MAX 5 - /* Uncomment the following line in order to enable IoT credentials checks in the provided samples */ // #define IOT_CORE_ENABLE_CREDENTIALS 1 diff --git a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h index 0df3022f5d..c07f3b0bed 100644 --- a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h +++ b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h @@ -631,6 +631,26 @@ extern "C" { */ #define SIGNALING_CONNECT_TIMEOUT (5 * HUNDREDS_OF_NANOS_IN_A_SECOND) +/** + * Default minimum number of threads in the threadpool for the SDK + */ +#define THREADPOOL_MIN_THREADS 3 + +/** + * Default maximum number of threads in the threadpool for the SDK + */ +#define THREADPOOL_MAX_THREADS 10 + +/** + * Env to set minimum number of threads in the threadpool for the KVS SDK + */ +#define WEBRTC_THREADPOOL_MIN_THREADS_ENV_VAR (PCHAR) "AWS_KVS_WEBRTC_THREADPOOL_MIN_THREADS" + +/** + * Env to set maximum number of threads in the threadpool for the SDK + */ +#define WEBRTC_THREADPOOL_MAX_THREADS_ENV_VAR (PCHAR) "AWS_KVS_WEBRTC_THREADPOOL_MAX_THREADS" + #ifdef _WIN32 /** * Default timeout for sending data @@ -1249,10 +1269,10 @@ typedef struct { //!< being used this value can be NULL or point to an EMPTY_STRING. KvsRetryStrategyCallbacks signalingRetryStrategyCallbacks; //!< Retry strategy callbacks used while creating signaling client INT32 signalingClientCreationMaxRetryAttempts; //!< Max attempts to create signaling client before returning error to the caller - UINT32 stateMachineRetryCountReadOnly; //!< Retry count of state machine. Note that this **MUST NOT** be modified by the user. It is a read only - //!< field - UINT32 signalingMessagesMinimumThreads; - UINT32 signalingMessagesMaximumThreads; + UINT32 stateMachineRetryCountReadOnly; //!< Retry count of state machine. Note that this **MUST NOT** be modified by the user. It is a read only + //!< field + UINT32 signalingMessagesMinimumThreads; //!< Unused field post v1.8.1 + UINT32 signalingMessagesMaximumThreads; //!< Unused field post v1.8.1 } SignalingClientInfo, *PSignalingClientInfo; /** diff --git a/src/source/Include_i.h b/src/source/Include_i.h index d767ed668a..98c4897a98 100644 --- a/src/source/Include_i.h +++ b/src/source/Include_i.h @@ -118,6 +118,7 @@ STATUS generateJSONSafeString(PCHAR, UINT32); //////////////////////////////////////////////////// // Project internal includes //////////////////////////////////////////////////// +#include "Threadpool/ThreadpoolContext.h" #include "Crypto/IOBuffer.h" #include "Crypto/Crypto.h" #include "Crypto/Dtls.h" diff --git a/src/source/PeerConnection/PeerConnection.c b/src/source/PeerConnection/PeerConnection.c index 5da590b125..c5bd505f24 100644 --- a/src/source/PeerConnection/PeerConnection.c +++ b/src/source/PeerConnection/PeerConnection.c @@ -1427,7 +1427,10 @@ STATUS initKvsWebRtc(VOID) #ifdef ENABLE_DATA_CHANNEL CHK_STATUS(initSctpSession()); #endif - +#ifdef ENABLE_KVS_THREADPOOL + DLOGI("KVS WebRtc library using thread pool"); + CHK_STATUS(createThreadPoolContext()); +#endif ATOMIC_STORE_BOOL(&gKvsWebRtcInitialized, TRUE); CleanUp: @@ -1449,6 +1452,10 @@ STATUS deinitKvsWebRtc(VOID) srtp_shutdown(); ATOMIC_STORE_BOOL(&gKvsWebRtcInitialized, FALSE); +#ifdef ENABLE_KVS_THREADPOOL + DLOGI("Destroying KVS Webrtc library threadpool"); + destroyThreadPoolContext(); +#endif CleanUp: diff --git a/src/source/Signaling/LwsApiCalls.c b/src/source/Signaling/LwsApiCalls.c index aa9dca51db..7ece2167ea 100644 --- a/src/source/Signaling/LwsApiCalls.c +++ b/src/source/Signaling/LwsApiCalls.c @@ -2012,7 +2012,8 @@ STATUS receiveLwsMessage(PSignalingClient pSignalingClient, PCHAR pMessage, UINT } #ifdef ENABLE_KVS_THREADPOOL - CHK_STATUS(threadpoolPush(pSignalingClient->pThreadpool, receiveLwsMessageWrapper, (PVOID) pSignalingMessageWrapper)); + // This would fail if threadpool was not created + CHK_STATUS(threadpoolContextPush(receiveLwsMessageWrapper, pSignalingMessageWrapper)); #else // Issue the callback on a separate thread CHK_STATUS(THREAD_CREATE(&receivedTid, receiveLwsMessageWrapper, (PVOID) pSignalingMessageWrapper)); diff --git a/src/source/Signaling/Signaling.c b/src/source/Signaling/Signaling.c index eae6bed9f7..458b44be05 100644 --- a/src/source/Signaling/Signaling.c +++ b/src/source/Signaling/Signaling.c @@ -37,12 +37,6 @@ STATUS createSignalingSync(PSignalingClientInfoInternal pClientInfo, PChannelInf CHK_STATUS(createValidateChannelInfo(pChannelInfo, &pSignalingClient->pChannelInfo)); CHK_STATUS(validateSignalingCallbacks(pSignalingClient, pCallbacks)); CHK_STATUS(validateSignalingClientInfo(pSignalingClient, pClientInfo)); -#ifdef ENABLE_KVS_THREADPOOL - DLOGD("Going to crate the threadpool for signaling"); - CHK_STATUS(threadpoolCreate(&pSignalingClient->pThreadpool, pClientInfo->signalingClientInfo.signalingMessagesMinimumThreads, - pClientInfo->signalingClientInfo.signalingMessagesMaximumThreads)); - DLOGD("Successfully created the threadpool for signaling"); -#endif pSignalingClient->version = SIGNALING_CLIENT_CURRENT_VERSION; // Set invalid call times @@ -227,10 +221,6 @@ STATUS freeSignaling(PSignalingClient* ppSignalingClient) hashTableFree(pSignalingClient->diagnostics.pEndpointToClockSkewHashMap); -#ifdef ENABLE_KVS_THREADPOOL - threadpoolFree(pSignalingClient->pThreadpool); -#endif - if (IS_VALID_MUTEX_VALUE(pSignalingClient->connectedLock)) { MUTEX_FREE(pSignalingClient->connectedLock); } diff --git a/src/source/Signaling/Signaling.h b/src/source/Signaling/Signaling.h index 4ba1c09cf7..500eec44ac 100644 --- a/src/source/Signaling/Signaling.h +++ b/src/source/Signaling/Signaling.h @@ -338,10 +338,6 @@ typedef struct { UINT64 getIceConfigTime; UINT64 deleteTime; UINT64 connectTime; - -#ifdef ENABLE_KVS_THREADPOOL - PThreadpool pThreadpool; -#endif UINT64 offerTime; } SignalingClient, *PSignalingClient; diff --git a/src/source/Threadpool/ThreadPoolContext.c b/src/source/Threadpool/ThreadPoolContext.c new file mode 100644 index 0000000000..203a174f92 --- /dev/null +++ b/src/source/Threadpool/ThreadPoolContext.c @@ -0,0 +1,94 @@ +#define LOG_CLASS "ThreadPoolContext" +#include "../Include_i.h" + +// Function to get access to the Singleton instance +PThreadPoolContext getThreadContextInstance() +{ + static ThreadPoolContext t = {.pThreadpool = NULL, .isInitialized = FALSE, .threadpoolContextLock = INVALID_MUTEX_VALUE}; + return &t; +} + +STATUS createThreadPoolContext() +{ + STATUS retStatus = STATUS_SUCCESS; + BOOL locked = FALSE; + PCHAR pMinThreads, pMaxThreads; + UINT32 minThreads, maxThreads; + PThreadPoolContext pThreadPoolContext = getThreadContextInstance(); + + if (!IS_VALID_MUTEX_VALUE(pThreadPoolContext->threadpoolContextLock)) { + pThreadPoolContext->threadpoolContextLock = MUTEX_CREATE(FALSE); + } + + if (NULL == (pMinThreads = GETENV(WEBRTC_THREADPOOL_MIN_THREADS_ENV_VAR)) || STATUS_SUCCESS != STRTOUI32(pMinThreads, NULL, 10, &minThreads)) { + minThreads = THREADPOOL_MIN_THREADS; + } + if (NULL == (pMaxThreads = GETENV(WEBRTC_THREADPOOL_MAX_THREADS_ENV_VAR)) || STATUS_SUCCESS != STRTOUI32(pMaxThreads, NULL, 10, &maxThreads)) { + maxThreads = THREADPOOL_MAX_THREADS; + } + + // Protecting this section to ensure we are not pushing threads / destroying the pool + // when it is being created. + MUTEX_LOCK(pThreadPoolContext->threadpoolContextLock); + locked = TRUE; + CHK_WARN(!pThreadPoolContext->isInitialized, retStatus, "Threadpool already set up. Nothing to do"); + CHK_ERR(pThreadPoolContext->pThreadpool == NULL, STATUS_NULL_ARG, "Threadpool object is to be set up"); + CHK_STATUS(threadpoolCreate(&pThreadPoolContext->pThreadpool, minThreads, maxThreads)); + pThreadPoolContext->isInitialized = TRUE; +CleanUp: + if (locked) { + MUTEX_UNLOCK(pThreadPoolContext->threadpoolContextLock); + } + return retStatus; +} + +STATUS threadpoolContextPush(startRoutine fn, PVOID customData) +{ + STATUS retStatus = STATUS_SUCCESS; + BOOL locked = FALSE; + PThreadPoolContext pThreadPoolContext = getThreadContextInstance(); + + // Protecting this section to ensure we are destroying the pool + // when it is being used. + MUTEX_LOCK(pThreadPoolContext->threadpoolContextLock); + locked = TRUE; + CHK_ERR(pThreadPoolContext->isInitialized, STATUS_INVALID_OPERATION, "Threadpool not initialized yet"); + CHK_ERR(pThreadPoolContext->pThreadpool != NULL, STATUS_NULL_ARG, "Threadpool object is NULL"); + CHK_STATUS(threadpoolPush(pThreadPoolContext->pThreadpool, fn, customData)); +CleanUp: + if (locked) { + MUTEX_UNLOCK(pThreadPoolContext->threadpoolContextLock); + } + return retStatus; +} + +STATUS destroyThreadPoolContext() +{ + STATUS retStatus = STATUS_SUCCESS; + BOOL locked = FALSE; + PThreadPoolContext pThreadPoolContext = getThreadContextInstance(); + + // Ensure we do not destroy the pool if threads are still being pushed + MUTEX_LOCK(pThreadPoolContext->threadpoolContextLock); + locked = TRUE; + CHK_WARN(pThreadPoolContext->isInitialized, STATUS_INVALID_OPERATION, "Threadpool not initialized yet, nothing to destroy"); + CHK_WARN(pThreadPoolContext->pThreadpool != NULL, STATUS_NULL_ARG, "Destroying threadpool without setting up"); + threadpoolFree(pThreadPoolContext->pThreadpool); + + // All members of the static instance **MUST** be reset after destruction to allow for + // the static object to be re-created after destruction (more relevant for unit tests) + pThreadPoolContext->pThreadpool = NULL; + pThreadPoolContext->isInitialized = FALSE; +CleanUp: + if (locked) { + MUTEX_UNLOCK(pThreadPoolContext->threadpoolContextLock); + } + if (IS_VALID_MUTEX_VALUE(pThreadPoolContext->threadpoolContextLock)) { + MUTEX_FREE(pThreadPoolContext->threadpoolContextLock); + + // Important to reset, specifically in case of unit tests where initKvsWebRtc() and + // deinitKvsWebRtc() is invoked before and after every test suite + pThreadPoolContext->threadpoolContextLock = INVALID_MUTEX_VALUE; + } + return retStatus; +}; \ No newline at end of file diff --git a/src/source/Threadpool/ThreadpoolContext.h b/src/source/Threadpool/ThreadpoolContext.h new file mode 100644 index 0000000000..adc45800c2 --- /dev/null +++ b/src/source/Threadpool/ThreadpoolContext.h @@ -0,0 +1,31 @@ +/******************************************* +Main internal include file +*******************************************/ +#ifndef __KINESIS_VIDEO_WEBRTC_CLIENT_THREADPOOLCONTEXT__ +#define __KINESIS_VIDEO_WEBRTC_CLIENT_THREADPOOLCONTEXT__ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +//////////////////////////////////////////////////// +// Project include files +//////////////////////////////////////////////////// + +typedef struct { + PThreadpool pThreadpool; + BOOL isInitialized; + MUTEX threadpoolContextLock; +} ThreadPoolContext, *PThreadPoolContext; + +PUBLIC_API STATUS createThreadPoolContext(); +PUBLIC_API STATUS getThreadPoolContext(PThreadPoolContext); +PUBLIC_API STATUS threadpoolContextPush(startRoutine, PVOID); +PUBLIC_API STATUS destroyThreadPoolContext(); + +#ifdef __cplusplus +} +#endif +#endif /* __KINESIS_VIDEO_WEBRTC_CLIENT_THREADPOOLCONTEXT__ */ diff --git a/tst/SignalingApiFunctionalityTest.cpp b/tst/SignalingApiFunctionalityTest.cpp index 6fb3d873fb..9990f5a361 100644 --- a/tst/SignalingApiFunctionalityTest.cpp +++ b/tst/SignalingApiFunctionalityTest.cpp @@ -239,8 +239,6 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateConnectFree) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -270,8 +268,6 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateConnectFree) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, basicCreateWithRetries) @@ -293,8 +289,6 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateWithRetries) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 3; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -303,8 +297,6 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateWithRetries) EXPECT_EQ(STATUS_NULL_ARG, createSignalingClientSync(&clientInfo, NULL, &signalingClientCallbacks, (PAwsCredentialProvider) mTestCredentialProvider, &signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, mockMaster) @@ -337,8 +329,6 @@ TEST_F(SignalingApiFunctionalityTest, mockMaster) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -446,8 +436,6 @@ TEST_F(SignalingApiFunctionalityTest, mockMaster) // Free again EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); EXPECT_FALSE(IS_VALID_SIGNALING_CLIENT_HANDLE(signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, mockViewer) @@ -481,8 +469,6 @@ TEST_F(SignalingApiFunctionalityTest, mockViewer) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_VIEWER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -564,8 +550,6 @@ TEST_F(SignalingApiFunctionalityTest, mockViewer) // Free again EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); EXPECT_FALSE(IS_VALID_SIGNALING_CLIENT_HANDLE(signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) @@ -591,8 +575,6 @@ TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -785,8 +767,6 @@ TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_VIEWER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -837,8 +817,6 @@ TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceReconnectEmulation) @@ -861,8 +839,6 @@ TEST_F(SignalingApiFunctionalityTest, iceReconnectEmulation) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -926,8 +902,6 @@ TEST_F(SignalingApiFunctionalityTest, iceReconnectEmulation) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariations) @@ -953,8 +927,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -1193,8 +1165,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) @@ -1220,8 +1190,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -1462,8 +1430,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpiration) @@ -1489,8 +1455,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpi clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -1587,8 +1551,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpi EXPECT_EQ(STATUS_SIGNALING_ICE_CONFIG_REFRESH_FAILED, errStatus); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpiration) @@ -1614,8 +1576,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpirat clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -1715,8 +1675,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpirat EXPECT_EQ(STATUS_SIGNALING_ICE_CONFIG_REFRESH_FAILED, errStatus); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaultInjectionRecovered) @@ -1742,8 +1700,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.getIceConfigPreHookFn = getIceConfigPreHook; @@ -1834,8 +1790,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultInjectionRecovered) @@ -1861,8 +1815,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.getIceConfigPreHookFn = getIceConfigPreHook; @@ -1955,8 +1907,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaultInjectionNotRecovered) @@ -1982,8 +1932,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.getIceConfigPreHookFn = getIceConfigPreHook; @@ -2072,8 +2020,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultInjectionNot1669) @@ -2099,8 +2045,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.getIceConfigPreHookFn = getIceConfigPreHook; @@ -2192,8 +2136,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadAuth) @@ -2219,8 +2161,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadA clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2315,8 +2255,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadA deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithBadAuth) @@ -2343,8 +2281,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithBadAuth clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2442,8 +2378,6 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithBadAuth deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, goAwayEmulation) @@ -2466,8 +2400,6 @@ TEST_F(SignalingApiFunctionalityTest, goAwayEmulation) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -2530,8 +2462,6 @@ TEST_F(SignalingApiFunctionalityTest, goAwayEmulation) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, unknownMessageTypeEmulation) @@ -2554,8 +2484,6 @@ TEST_F(SignalingApiFunctionalityTest, unknownMessageTypeEmulation) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - clientInfo.signalingMessagesMinimumThreads = 3; - clientInfo.signalingMessagesMaximumThreads = 5; clientInfo.signalingClientCreationMaxRetryAttempts = 0; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfo); @@ -2622,8 +2550,6 @@ TEST_F(SignalingApiFunctionalityTest, unknownMessageTypeEmulation) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, connectTimeoutEmulation) @@ -2650,8 +2576,6 @@ TEST_F(SignalingApiFunctionalityTest, connectTimeoutEmulation) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.connectTimeout = 1 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2747,8 +2671,6 @@ TEST_F(SignalingApiFunctionalityTest, connectTimeoutEmulation) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, channelInfoArnSkipDescribe) @@ -2773,8 +2695,6 @@ TEST_F(SignalingApiFunctionalityTest, channelInfoArnSkipDescribe) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.connectTimeout = 0; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -2883,8 +2803,6 @@ TEST_F(SignalingApiFunctionalityTest, channelInfoArnSkipDescribe) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedWithArn) @@ -2909,8 +2827,6 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedWithArn) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.connectTimeout = 0; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -3019,8 +2935,6 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedWithArn) EXPECT_EQ(STATUS_SUCCESS, signalingClientDeleteSync(signalingHandle)); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) @@ -3044,8 +2958,6 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.connectTimeout = 0; setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -3134,8 +3046,6 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, signalingClientDisconnectSyncVariations) @@ -3180,8 +3090,6 @@ TEST_F(SignalingApiFunctionalityTest, signalingClientDisconnectSyncVariations) EXPECT_EQ(STATUS_SUCCESS, signalingClientSendMessageSync(mSignalingClientHandle, &message)); deinitializeSignalingClient(); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) @@ -3205,8 +3113,6 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.connectPreHookFn = connectPreHook; @@ -3318,8 +3224,6 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, fileCachingTest) @@ -3347,8 +3251,6 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingTest) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfoInternal.hookCustomData = (UINT64) this; clientInfoInternal.connectPreHookFn = connectPreHook; @@ -3373,7 +3275,7 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingTest) FREMOVE(DEFAULT_CACHE_FILE_PATH); for (i = 0; i < totalChannelCount; ++i) { - SPRINTF(signalingChannelName, "%s%u", TEST_SIGNALING_CHANNEL_NAME, i); + SNPRINTF(signalingChannelName, SIZEOF(signalingChannelName), "%s%u", TEST_SIGNALING_CHANNEL_NAME, i); channelInfo.pChannelName = signalingChannelName; EXPECT_EQ(STATUS_SUCCESS, createSignalingSync(&clientInfoInternal, &channelInfo, &signalingClientCallbacks, (PAwsCredentialProvider) mTestCredentialProvider, @@ -3388,7 +3290,7 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingTest) getEndpointCountNoCache = getEndpointCount; for (i = 0; i < totalChannelCount; ++i) { - SPRINTF(signalingChannelName, "%s%u", TEST_SIGNALING_CHANNEL_NAME, i); + SNPRINTF(signalingChannelName, SIZEOF(signalingChannelName), "%s%u", TEST_SIGNALING_CHANNEL_NAME, i); channelInfo.pChannelName = signalingChannelName; channelInfo.pChannelArn = NULL; EXPECT_EQ(STATUS_SUCCESS, @@ -3425,8 +3327,6 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingTest) /* describeCount and getEndpointCount should only increase by 2 because they are cached for all channels except one and we iterate twice*/ EXPECT_TRUE(describeCount > describeCountNoCache && (describeCount - describeCountNoCache) == 2); EXPECT_TRUE(getEndpointCount > getEndpointCountNoCache && (getEndpointCount - 2*getEndpointCountNoCache) == 2); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateCache) @@ -3457,8 +3357,6 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateCache) testEntry.creationTsEpochSeconds = GETTIME() / HUNDREDS_OF_NANOS_IN_A_SECOND; /* update first cache entry*/ EXPECT_EQ(STATUS_SUCCESS, signalingCacheSaveToFile(&testEntry, DEFAULT_CACHE_FILE_PATH)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateMultiChannelCache) @@ -3492,11 +3390,11 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateMultiChannelCache) MEMSET(testChannel, 0, MAX_CHANNEL_NAME_LEN+1); append = rand()%TEST_CHANNEL_COUNT; - SPRINTF(testWssEndpoint, "%s%d", "testWssEndpoint", append); - SPRINTF(testHttpsEndpoint, "%s%d", "testHttpsEndpoint", append); - SPRINTF(testRegion, "%s%d", "testRegion", append); - SPRINTF(testChannelArn, "%s%d", "testChannelArn", append); - SPRINTF(testChannel, "%s%d", "testChannel", append); + SNPRINTF(testWssEndpoint, SIZEOF(testWssEndpoint), "%s%d", "testWssEndpoint", append); + SNPRINTF(testHttpsEndpoint, SIZEOF(testHttpsEndpoint),"%s%d", "testHttpsEndpoint", append); + SNPRINTF(testRegion, SIZEOF(testRegion),"%s%d", "testRegion", append); + SNPRINTF(testChannelArn, SIZEOF(testChannelArn),"%s%d", "testChannelArn", append); + SNPRINTF(testChannel, SIZEOF(testChannel),"%s%d", "testChannel", append); STRCPY(testEntry.wssEndpoint, testWssEndpoint); STRCPY(testEntry.httpsEndpoint, testHttpsEndpoint); @@ -3530,8 +3428,6 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateMultiChannelCache) MEMFREE(fileBuffer); FREMOVE(DEFAULT_CACHE_FILE_PATH); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateFullMultiChannelCache) @@ -3560,11 +3456,11 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateFullMultiChannelCache) MEMSET(testChannel, 0, MAX_CHANNEL_NAME_LEN+1); append = i; - SPRINTF(testWssEndpoint, "%s%d", "testWssEndpoint", append); - SPRINTF(testHttpsEndpoint, "%s%d", "testHttpsEndpoint", append); - SPRINTF(testRegion, "%s%d", "testRegion", append); - SPRINTF(testChannelArn, "%s%d", "testChannelArn", append); - SPRINTF(testChannel, "%s%d", "testChannel", append); + SNPRINTF(testWssEndpoint, SIZEOF(testWssEndpoint), "%s%d", "testWssEndpoint", append); + SNPRINTF(testHttpsEndpoint, SIZEOF(testHttpsEndpoint), "%s%d", "testHttpsEndpoint", append); + SNPRINTF(testRegion, SIZEOF(testRegion), "%s%d", "testRegion", append); + SNPRINTF(testChannelArn, SIZEOF(testChannelArn), "%s%d", "testChannelArn", append); + SNPRINTF(testChannel, SIZEOF(testChannel), "%s%d", "testChannel", append); STRCPY(testEntry.wssEndpoint, testWssEndpoint); STRCPY(testEntry.httpsEndpoint, testHttpsEndpoint); @@ -3585,8 +3481,6 @@ TEST_F(SignalingApiFunctionalityTest, fileCachingUpdateFullMultiChannelCache) EXPECT_EQ(0, STRCMP(testEntry.channelName, testChannel)); FREMOVE(DEFAULT_CACHE_FILE_PATH); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer) @@ -3612,8 +3506,6 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); setupSignalingStateMachineRetryStrategyCallbacks(&clientInfoInternal); @@ -3775,8 +3667,6 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_SlowClockSkew) @@ -3802,8 +3692,6 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_SlowClockSkew) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); @@ -3968,8 +3856,6 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_SlowClockSkew) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } @@ -3996,8 +3882,6 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew) clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); @@ -4162,8 +4046,6 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew_VerifyOffsetRemovedWhenClockFixed) @@ -4192,8 +4074,6 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew_Veri clientInfoInternal.signalingClientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfoInternal.signalingClientInfo.loggingLevel = mLogLevel; - clientInfoInternal.signalingClientInfo.signalingMessagesMinimumThreads = 3; - clientInfoInternal.signalingClientInfo.signalingMessagesMaximumThreads = 5; STRCPY(clientInfoInternal.signalingClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); @@ -4383,8 +4263,6 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew_Veri deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); - //wait for threads of threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index d041db728e..5ad7763251 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -113,6 +113,8 @@ void WebRtcClientTestBase::TearDown() DLOGI("\nTearing down test: %s\n", GetTestName()); deinitKvsWebRtc(); + // Need this sleep for threads in threadpool to close + THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); freeStaticCredentialProvider(&mTestCredentialProvider); diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index f165bf869b..229b7dd439 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -95,8 +95,6 @@ class WebRtcClientTestBase : public ::testing::Test { mClientInfo.signalingRetryStrategyCallbacks.freeRetryStrategyFn = freeRetryStrategyFn; mClientInfo.signalingRetryStrategyCallbacks.executeRetryStrategyFn = executeRetryStrategyFn; mClientInfo.signalingClientCreationMaxRetryAttempts = 0; - mClientInfo.signalingMessagesMinimumThreads = 3; - mClientInfo.signalingMessagesMaximumThreads = 5; MEMSET(&mChannelInfo, 0x00, SIZEOF(mChannelInfo)); mChannelInfo.version = CHANNEL_INFO_CURRENT_VERSION;