Author: mmichelson
Date: Thu Mar  5 16:23:41 2015
New Revision: 432510

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=432510
Log:
Change async test to use ast_cond_timedwait()

This way, if there is some issue, the test will eventually
time out, rather than waiting forever.


Modified:
    team/group/dns/tests/test_dns.c

Modified: team/group/dns/tests/test_dns.c
URL: 
http://svnview.digium.com/svn/asterisk/team/group/dns/tests/test_dns.c?view=diff&rev=432510&r1=432509&r2=432510
==============================================================================
--- team/group/dns/tests/test_dns.c (original)
+++ team/group/dns/tests/test_dns.c Thu Mar  5 16:23:41 2015
@@ -750,6 +750,7 @@
        RAII_VAR(struct async_resolution_data *, async_data, NULL, 
ao2_cleanup); 
        RAII_VAR(struct ast_dns_query *, query, NULL, ao2_cleanup);
        enum ast_test_result_state res = AST_TEST_PASS;
+       struct timespec timeout;
 
        switch (cmd) {
        case TEST_INIT:
@@ -799,11 +800,21 @@
                goto cleanup;
        }
 
+       clock_gettime(CLOCK_REALTIME, &timeout);
+       timeout.tv_sec += 10;
        ast_mutex_lock(&async_data->lock);
        while (!async_data->complete) {
-               ast_cond_wait(&async_data->cond, &async_data->lock);
+               if (ast_cond_timedwait(&async_data->cond, &async_data->lock, 
&timeout) == ETIMEDOUT) {
+                       break;
+               }
        }
        ast_mutex_unlock(&async_data->lock);
+
+       if (!async_data->complete) {
+               ast_test_status_update(test, "Asynchronous resolution timed 
out\n");
+               res = AST_TEST_FAIL;
+               goto cleanup;
+       }
 
        if (!test_resolver_data.resolution_complete) {
                ast_test_status_update(test, "Asynchronous resolution completed 
early?\n");


-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to