taskprocessor: Warn on unused result from pushing task.

Add attribute_warn_unused_result to ast_taskprocessor_push,
ast_taskprocessor_push_local and ast_threadpool_push.  This will help
ensure we perform the necessary cleanup upon failure.

Change-Id: I7e4079bd7b21cfe52fb431ea79e41314520c3f6d
This commit is contained in:
Corey Farrell
2018-10-14 08:58:59 -04:00
parent 6296b5c7be
commit 01716f70e6
8 changed files with 161 additions and 57 deletions

View File

@@ -151,7 +151,10 @@ AST_TEST_DEFINE(default_taskprocessor)
return AST_TEST_FAIL;
}
ast_taskprocessor_push(tps, task, task_data);
if (ast_taskprocessor_push(tps, task, task_data)) {
ast_test_status_update(test, "Failed to queue task\n");
return AST_TEST_FAIL;
}
res = task_wait(task_data);
if (res != 0) {
@@ -240,7 +243,11 @@ AST_TEST_DEFINE(default_taskprocessor_load)
for (i = 0; i < NUM_TASKS; ++i) {
rand_data[i] = ast_random();
ast_taskprocessor_push(tps, load_task, &rand_data[i]);
if (ast_taskprocessor_push(tps, load_task, &rand_data[i])) {
ast_test_status_update(test, "Failed to queue task\n");
res = AST_TEST_FAIL;
goto test_end;
}
}
ast_mutex_lock(&load_task_results.lock);
@@ -438,14 +445,22 @@ AST_TEST_DEFINE(taskprocessor_listener)
goto test_exit;
}
ast_taskprocessor_push(tps, listener_test_task, NULL);
if (ast_taskprocessor_push(tps, listener_test_task, NULL)) {
ast_test_status_update(test, "Failed to queue task\n");
res = AST_TEST_FAIL;
goto test_exit;
}
if (check_stats(test, pvt, 1, 0, 1) < 0) {
res = AST_TEST_FAIL;
goto test_exit;
}
ast_taskprocessor_push(tps, listener_test_task, NULL);
if (ast_taskprocessor_push(tps, listener_test_task, NULL)) {
ast_test_status_update(test, "Failed to queue task\n");
res = AST_TEST_FAIL;
goto test_exit;
}
if (check_stats(test, pvt, 2, 0, 1) < 0) {
res = AST_TEST_FAIL;
@@ -710,7 +725,10 @@ AST_TEST_DEFINE(taskprocessor_push_local)
local_data = 0;
ast_taskprocessor_set_local(tps, &local_data);
ast_taskprocessor_push_local(tps, local_task_exe, task_data);
if (ast_taskprocessor_push_local(tps, local_task_exe, task_data)) {
ast_test_status_update(test, "Failed to queue task\n");
return AST_TEST_FAIL;
}
res = task_wait(task_data);
if (res != 0) {