Skip to content
Snippets Groups Projects
Commit 9ef0eb64 authored by zuul's avatar zuul Committed by Gerrit Code Review
Browse files

Merge "logger: Simplify ast_callid handling code."

parents 57b29f3b 923edf25
Branches
Tags
No related merge requests found
......@@ -1764,13 +1764,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)
......@@ -1780,7 +1774,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)
......@@ -1788,23 +1781,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;
}
......@@ -1814,21 +1794,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;
}
......@@ -1837,21 +1813,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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment