]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
test_threadpool: Wait for each task to complete and fix memory leak. 52/2052/1
authorJoshua Colp <jcolp@digium.com>
Tue, 19 Jan 2016 23:15:50 +0000 (19:15 -0400)
committerJoshua Colp <jcolp@digium.com>
Tue, 19 Jan 2016 23:21:35 +0000 (17:21 -0600)
This change makes the thread_timeout_thrash unit test wait for
each task to complete. This fixes the problem where the test would
prematurely end when all threads were gone and a new one had to be
started to handle the last task. It also increases the thrasing as
it is now more likely for each task to encounter the above scenario.

This also fixes a memory leak where the data for each task was not
being freed.

ASTERISK-25611 #close

Change-Id: I5017d621a4dc911f509074c16229b86bff2fb3c6

tests/test_threadpool.c

index 42181a25cc9e264cdd9eac5955396dc272f15d3c..afb981be605738f15cb0f46d3c85d9214e2fd6b3 100644 (file)
@@ -636,6 +636,14 @@ AST_TEST_DEFINE(threadpool_thread_timeout_thrash)
                ast_mutex_unlock(&tld->lock);
 
                ast_threadpool_push(pool, simple_task, std);
+
+               res = wait_for_completion(test, std);
+
+               ast_free(std);
+
+               if (res == AST_TEST_FAIL) {
+                       goto end;
+               }
        }
 
        res = wait_until_thread_state(test, tld, 0, 0);