mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
Stopped spamming of debug messages during attended transfer.
While autoservice is running and servicing a channel the callid is being stored and removed in the thread's local storage for each iteration of the thread loop. If debug was set to a sufficient level the log file would be spammed with callid thread local storage debug messages. Added a new function that checks to see if the callid to be stored is different than what is already contained (if anything). If it is different then store/replace and log, otherwise just leave as is. Also made it so all logging of debug messages pertaining to the callid thread storage outputs only when TEST_FRAMEWORK is defined. (issue ASTERISK-21014) (closes issue ASTERISK-21014) Report by: Rusty Newton Review: https://reviewboard.asterisk.org/r/2324/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381557 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -280,6 +280,15 @@ struct ast_callid *ast_read_threadstorage_callid(void);
|
|||||||
*/
|
*/
|
||||||
#define ast_callid_unref(c) ({ ao2_ref(c, -1); (NULL); })
|
#define ast_callid_unref(c) ({ ao2_ref(c, -1); (NULL); })
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets what is stored in the thread storage to the given
|
||||||
|
* callid if it does not match what is already there.
|
||||||
|
*
|
||||||
|
* \retval 0 - success
|
||||||
|
* \retval non-zero - failure
|
||||||
|
*/
|
||||||
|
int ast_callid_threadassoc_change(struct ast_callid *callid);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Adds a known callid to thread storage of the calling thread
|
* \brief Adds a known callid to thread storage of the calling thread
|
||||||
*
|
*
|
||||||
|
@@ -77,6 +77,7 @@ static int as_chan_list_state;
|
|||||||
|
|
||||||
static void *autoservice_run(void *ign)
|
static void *autoservice_run(void *ign)
|
||||||
{
|
{
|
||||||
|
struct ast_callid *callid = NULL;
|
||||||
struct ast_frame hangup_frame = {
|
struct ast_frame hangup_frame = {
|
||||||
.frametype = AST_FRAME_CONTROL,
|
.frametype = AST_FRAME_CONTROL,
|
||||||
.subclass.integer = AST_CONTROL_HANGUP,
|
.subclass.integer = AST_CONTROL_HANGUP,
|
||||||
@@ -90,7 +91,6 @@ static void *autoservice_run(void *ign)
|
|||||||
int i, x = 0, ms = 50;
|
int i, x = 0, ms = 50;
|
||||||
struct ast_frame *f = NULL;
|
struct ast_frame *f = NULL;
|
||||||
struct ast_frame *defer_frame = NULL;
|
struct ast_frame *defer_frame = NULL;
|
||||||
struct ast_callid *callid = NULL;
|
|
||||||
|
|
||||||
AST_LIST_LOCK(&aslist);
|
AST_LIST_LOCK(&aslist);
|
||||||
|
|
||||||
@@ -129,9 +129,8 @@ static void *autoservice_run(void *ign)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((callid = ast_channel_callid(chan))) {
|
callid = ast_channel_callid(chan);
|
||||||
ast_callid_threadassoc_add(callid);
|
ast_callid_threadassoc_change(callid);
|
||||||
}
|
|
||||||
|
|
||||||
f = ast_read(chan);
|
f = ast_read(chan);
|
||||||
|
|
||||||
@@ -173,11 +172,11 @@ static void *autoservice_run(void *ign)
|
|||||||
} else if (f) {
|
} else if (f) {
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (callid) {
|
if (callid) {
|
||||||
ast_callid_threadassoc_remove();
|
ast_callid_threadassoc_remove();
|
||||||
callid = ast_callid_unref(callid);
|
callid = ast_callid_unref(callid);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asthread = AST_PTHREADT_NULL;
|
asthread = AST_PTHREADT_NULL;
|
||||||
|
@@ -1317,7 +1317,9 @@ struct ast_callid *ast_create_callid(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
call->call_identifier = ast_atomic_fetchadd_int(&next_unique_callid, +1);
|
call->call_identifier = ast_atomic_fetchadd_int(&next_unique_callid, +1);
|
||||||
|
#ifdef TEST_FRAMEWORK
|
||||||
ast_debug(3, "CALL_ID [C-%08x] created by thread.\n", call->call_identifier);
|
ast_debug(3, "CALL_ID [C-%08x] created by thread.\n", call->call_identifier);
|
||||||
|
#endif
|
||||||
return call;
|
return call;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1334,6 +1336,36 @@ struct ast_callid *ast_read_threadstorage_callid(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ast_callid_threadassoc_change(struct ast_callid *callid)
|
||||||
|
{
|
||||||
|
struct ast_callid **id =
|
||||||
|
ast_threadstorage_get(&unique_callid, sizeof(struct ast_callid **));
|
||||||
|
|
||||||
|
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)->call_identifier);
|
||||||
|
#endif
|
||||||
|
*id = ast_callid_unref(*id);
|
||||||
|
*id = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(*id) && callid) {
|
||||||
|
/* callid will be unreffed at thread destruction */
|
||||||
|
ast_callid_ref(callid);
|
||||||
|
*id = callid;
|
||||||
|
#ifdef TEST_FRAMEWORK
|
||||||
|
ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", callid->call_identifier);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ast_callid_threadassoc_add(struct ast_callid *callid)
|
int ast_callid_threadassoc_add(struct ast_callid *callid)
|
||||||
{
|
{
|
||||||
struct ast_callid **pointing;
|
struct ast_callid **pointing;
|
||||||
@@ -1347,7 +1379,9 @@ int ast_callid_threadassoc_add(struct ast_callid *callid)
|
|||||||
/* callid will be unreffed at thread destruction */
|
/* callid will be unreffed at thread destruction */
|
||||||
ast_callid_ref(callid);
|
ast_callid_ref(callid);
|
||||||
*pointing = callid;
|
*pointing = callid;
|
||||||
|
#ifdef TEST_FRAMEWORK
|
||||||
ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", callid->call_identifier);
|
ast_debug(3, "CALL_ID [C-%08x] bound to thread.\n", callid->call_identifier);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Attempted to ast_callid_threadassoc_add on thread already associated with a callid.\n");
|
ast_log(LOG_WARNING, "Attempted to ast_callid_threadassoc_add on thread already associated with a callid.\n");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1369,7 +1403,9 @@ int ast_callid_threadassoc_remove(void)
|
|||||||
ast_log(LOG_ERROR, "Tried to clean callid thread storage with no callid in thread storage.\n");
|
ast_log(LOG_ERROR, "Tried to clean callid thread storage with no callid in thread storage.\n");
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef TEST_FRAMEWORK
|
||||||
ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", (*pointing)->call_identifier);
|
ast_debug(3, "CALL_ID [C-%08x] being removed from thread.\n", (*pointing)->call_identifier);
|
||||||
|
#endif
|
||||||
*pointing = ast_callid_unref(*pointing);
|
*pointing = ast_callid_unref(*pointing);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user