diff options
author | Mark Michelson <mmichelson@digium.com> | 2012-12-10 15:55:56 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2012-12-10 15:55:56 +0000 |
commit | 957cb0742b8fff0be33b5b4035f9df81a2636bd6 (patch) | |
tree | 4d1fea9720b5cc3c90b1f05d6009b284184b8301 /tests/test_threadpool.c | |
parent | 81afbcca2ca7977bc3d64e0a1338011804e175dc (diff) |
Improve timedwaits in tests to actually behave like they should.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377654 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_threadpool.c')
-rw-r--r-- | tests/test_threadpool.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/test_threadpool.c b/tests/test_threadpool.c index 5de516839..8e8342d1f 100644 --- a/tests/test_threadpool.c +++ b/tests/test_threadpool.c @@ -157,7 +157,9 @@ static void wait_for_task_pushed(struct ast_threadpool_listener *listener) SCOPED_MUTEX(lock, &tld->lock); while (!tld->task_pushed) { - ast_cond_timedwait(&tld->cond, lock, &end); + if (ast_cond_timedwait(&tld->cond, lock, &end) == ETIMEDOUT) { + break; + } } } @@ -172,7 +174,9 @@ static enum ast_test_result_state wait_for_completion(struct ast_test *test, str SCOPED_MUTEX(lock, &std->lock); while (!std->task_executed) { - ast_cond_timedwait(&std->cond, lock, &end); + if (ast_cond_timedwait(&std->cond, lock, &end) == ETIMEDOUT) { + break; + } } if (!std->task_executed) { @@ -193,7 +197,9 @@ static enum ast_test_result_state wait_for_empty_notice(struct ast_test *test, s SCOPED_MUTEX(lock, &tld->lock); while (!tld->empty_notice) { - ast_cond_timedwait(&tld->cond, lock, &end); + if (ast_cond_timedwait(&tld->cond, lock, &end) == ETIMEDOUT) { + break; + } } if (!tld->empty_notice) { @@ -840,7 +846,9 @@ static enum ast_test_result_state wait_for_complex_completion(struct complex_tas SCOPED_MUTEX(lock, &ctd->lock); while (!ctd->task_executed) { - ast_cond_timedwait(&ctd->done_cond, lock, &end); + if (ast_cond_timedwait(&ctd->done_cond, lock, &end) == ETIMEDOUT) { + break; + } } if (!ctd->task_executed) { |