[asterisk-commits] test time: Provide a timeout when waiting. (asterisk[certified/13.1])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 13 15:50:43 CST 2016


Mark Michelson has submitted this change and it was merged.

Change subject: test_time: Provide a timeout when waiting.
......................................................................


test_time: Provide a timeout when waiting.

The test_timezone_watch unit test is written to expect a
condition to be signaled when the inotify daemon thread runs.
There exists a small window where the test_timezone_watch
thread can signal the inotify daemon thread while it is not
reading on the underlying file descriptor. If this occurs
the test_timezone_watch thread will wait indefinitely for a
signal that will never arrive.

This change adds a timeout to the condition so it will return
regardless after a period of time.

Change-Id: Ifed981879df6de3d93acd3ee0a70f92546517390
(cherry picked from commit c8499b8d5adc805efadb91b483d9d987f62891ff)
---
M main/stdtime/localtime.c
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  Mark Michelson: Looks good to me, approved
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified



diff --git a/main/stdtime/localtime.c b/main/stdtime/localtime.c
index b2745d9..b12b54f 100644
--- a/main/stdtime/localtime.c
+++ b/main/stdtime/localtime.c
@@ -625,13 +625,16 @@
 
 void ast_localtime_wakeup_monitor(struct ast_test *info)
 {
+	struct timeval wait_now = ast_tvnow();
+	struct timespec wait_time = { .tv_sec = wait_now.tv_sec + 2, .tv_nsec = wait_now.tv_usec * 1000 };
+
 	if (inotify_thread != AST_PTHREADT_NULL) {
 		AST_LIST_LOCK(&zonelist);
 #ifdef TEST_FRAMEWORK
 		test = info;
 #endif
 		pthread_kill(inotify_thread, SIGURG);
-		ast_cond_wait(&initialization, &(&zonelist)->lock);
+		ast_cond_timedwait(&initialization, &(&zonelist)->lock, &wait_time);
 #ifdef TEST_FRAMEWORK
 		test = NULL;
 #endif

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifed981879df6de3d93acd3ee0a70f92546517390
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list