[Asterisk-code-review] tests/test sorcery memory cache thrash: Improve termination ... (asterisk[master])

Joshua Colp asteriskteam at digium.com
Tue Feb 9 10:34:17 CST 2016


Joshua Colp has uploaded a new change for review.

  https://gerrit.asterisk.org/2218

Change subject: tests/test_sorcery_memory_cache_thrash: Improve termination process.
......................................................................

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 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
---
M tests/test_sorcery_memory_cache_thrash.c
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/18/2218/1

diff --git a/tests/test_sorcery_memory_cache_thrash.c b/tests/test_sorcery_memory_cache_thrash.c
index daf5234..d911e86 100644
--- a/tests/test_sorcery_memory_cache_thrash.c
+++ b/tests/test_sorcery_memory_cache_thrash.c
@@ -304,6 +304,15 @@
 		}
 
 		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);
 

-- 
To view, visit https://gerrit.asterisk.org/2218
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I04a53470b0ea4170b8819180b0bd7475f3642827
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list