diff options
author | Corey Farrell <git@cfware.com> | 2016-08-16 16:21:33 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2016-09-20 18:25:16 -0500 |
commit | 923edf2596243362badeec369b27bfcbff5efe62 (patch) | |
tree | 0eaeda7c565bff397d074e1633de746955670a42 /main/logger.c | |
parent | 0df2373434c5eb4c13c3d9d2ec97770e17e14474 (diff) |
logger: Simplify ast_callid handling code.
Routines responsible for managing ast_callid's are overly complicated.
This is left-over code from when ast_callid was an AO2 object. Now that
it is an integer the code can be reduced.
ast_callid handler code no longer prints it's own error message upon failure
to allocate threadstorage as ast_calloc would have already printed a
message. Debug messages that were printed when TEST_FRAMEWORK was
enabled have been also been removed.
Change-Id: I65a768a78dc6cf3cfa071e97f33ce3dce280258e
Diffstat (limited to 'main/logger.c')
-rw-r--r-- | main/logger.c | 51 |
1 files changed, 11 insertions, 40 deletions
diff --git a/main/logger.c b/main/logger.c index 9a16dcf13..c11118242 100644 --- a/main/logger.c +++ b/main/logger.c @@ -1762,13 +1762,7 @@ void ast_callid_strnprint(char *buffer, size_t buffer_size, ast_callid callid) ast_callid ast_create_callid(void) { - ast_callid call; - - call = ast_atomic_fetchadd_int(&next_unique_callid, +1); -#ifdef TEST_FRAMEWORK - ast_debug(3, "CALL_ID [C-%08x] created by thread.\n", call); -#endif - return call; + return ast_atomic_fetchadd_int(&next_unique_callid, +1); } ast_callid ast_read_threadstorage_callid(void) @@ -1778,7 +1772,6 @@ ast_callid ast_read_threadstorage_callid(void) callid = ast_threadstorage_get(&unique_callid, sizeof(*callid)); return callid ? *callid : 0; - } int ast_callid_threadassoc_change(ast_callid callid) @@ -1786,23 +1779,10 @@ int ast_callid_threadassoc_change(ast_callid callid) ast_callid *id = ast_threadstorage_get(&unique_callid, sizeof(*id)); if (!id) { - ast_log(LOG_ERROR, "Failed to allocate thread storage.\n"); return -1; } - if (*id && (*id != callid)) { -#ifdef TEST_FRAMEWORK - ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", *id); -#endif - *id = 0; - } - - if (!(*id) && callid) { - *id = callid; -#ifdef TEST_FRAMEWORK - ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", callid); -#endif - } + *id = callid; return 0; } @@ -1812,21 +1792,17 @@ int ast_callid_threadassoc_add(ast_callid callid) ast_callid *pointing; pointing = ast_threadstorage_get(&unique_callid, sizeof(*pointing)); - if (!(pointing)) { - ast_log(LOG_ERROR, "Failed to allocate thread storage.\n"); + if (!pointing) { return -1; } - if (!(*pointing)) { - *pointing = callid; -#ifdef TEST_FRAMEWORK - ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", callid); -#endif - } else { - ast_log(LOG_WARNING, "Attempted to ast_callid_threadassoc_add on thread already associated with a callid.\n"); + if (*pointing) { + ast_log(LOG_ERROR, "ast_callid_threadassoc_add(C-%08x) on thread " + "already associated with callid [C-%08x].\n", callid, *pointing); return 1; } + *pointing = callid; return 0; } @@ -1835,21 +1811,16 @@ int ast_callid_threadassoc_remove(void) ast_callid *pointing; pointing = ast_threadstorage_get(&unique_callid, sizeof(*pointing)); - if (!(pointing)) { - ast_log(LOG_ERROR, "Failed to allocate thread storage.\n"); + if (!pointing) { return -1; } - if (!(*pointing)) { - ast_log(LOG_ERROR, "Tried to clean callid thread storage with no callid in thread storage.\n"); - return -1; - } else { -#ifdef TEST_FRAMEWORK - ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", *pointing); -#endif + if (*pointing) { *pointing = 0; return 0; } + + return -1; } int ast_callid_threadstorage_auto(ast_callid *callid) |