summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2016-02-09 09:11:36 -0400
committerJoshua Colp <jcolp@digium.com>2016-02-09 11:24:51 -0600
commita7c8d4cd6b1db086c9efaa48ace361f8894fe767 (patch)
tree6d1e1247eafc0c7708691b52a5d36cdf3c7afa63 /tests
parent78fa818c1bdcbb5c0bcd5c651e14c7f607ac4997 (diff)
tests/test_sorcery_memory_cache_thrash: Improve termination process.
When terminating the threads thrashing a sorcery memory cache each would be told to stop and then we would wait on them. During at least one thrashing test this was problematic due to the specific usage pattern in use. It would take some time for termination of the thread to occur. This would occur due to contention between the threads retrieving and the threads updating the cache. As the retrieving threads are given priority it may be some time before the updating threads are able to proceed. This change makes it so all threads are told to stop and then each are joined to ensure they stop. This way all the threads should stop at around the same time instead of waiting for one to stop, the next to stop, then the next, and so on. As a result of this the execution time for each thrash test is much closer to their expected value than previously seen as well. Change-Id: I04a53470b0ea4170b8819180b0bd7475f3642827
Diffstat (limited to 'tests')
-rw-r--r--tests/test_sorcery_memory_cache_thrash.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_sorcery_memory_cache_thrash.c b/tests/test_sorcery_memory_cache_thrash.c
index 2d18317a3..c0d25feb3 100644
--- a/tests/test_sorcery_memory_cache_thrash.c
+++ b/tests/test_sorcery_memory_cache_thrash.c
@@ -302,6 +302,15 @@ static void sorcery_memory_cache_thrash_stop(struct sorcery_memory_cache_thrash
}
thread->stop = 1;
+ }
+
+ for (idx = 0; idx < AST_VECTOR_SIZE(&thrash->threads); ++idx) {
+ struct sorcery_memory_cache_thrash_thread *thread;
+
+ thread = AST_VECTOR_GET(&thrash->threads, idx);
+ if (thread->thread == AST_PTHREADT_NULL) {
+ continue;
+ }
pthread_join(thread->thread, NULL);