summaryrefslogtreecommitdiff
path: root/main/features.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2012-03-29 19:54:35 +0000
committerJonathan Rose <jrose@digium.com>2012-03-29 19:54:35 +0000
commitbf994f0e04696ba11ce0ec81df7880d61ef9c779 (patch)
tree280a6b0607ecb586b6e8f41bf41c2a559b6c5972 /main/features.c
parentdd9405db057da671c115619c9a5f8082ede2e134 (diff)
Introducing the log message unique call identifiers feature
Log messages will now display a call number that they are tied to (ordered for calls based on when they started). This feature is made to be minimally invasive without requiring changes to many of the existing log messages. These IDs won't show up for verbose messages on CLI (but they will in log files) This is currently in phase II of production, see more about this feature on the wiki -- https://wiki.asterisk.org/wiki/display/AST/Unique+Call-ID+Logging Review: https://reviewboard.asterisk.org/r/1823/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360785 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/features.c')
-rw-r--r--main/features.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/main/features.c b/main/features.c
index 71be7d3f7..d23bda4a1 100644
--- a/main/features.c
+++ b/main/features.c
@@ -844,6 +844,7 @@ struct ast_bridge_thread_obj
struct ast_bridge_config bconfig;
struct ast_channel *chan;
struct ast_channel *peer;
+ struct ast_callid *callid; /*<! callid pointer (Only used to bind thread) */
unsigned int return_to_pbx:1;
};
@@ -949,6 +950,12 @@ static void *bridge_call_thread(void *data)
struct ast_bridge_thread_obj *tobj = data;
int res;
+ if (tobj->callid) {
+ ast_callid_threadassoc_add(tobj->callid);
+ /* Need to deref and set to null since ast_bridge_thread_obj has no common destructor */
+ tobj->callid = ast_callid_unref(tobj->callid);
+ }
+
ast_channel_appl_set(tobj->chan, !tobj->return_to_pbx ? "Transferred Call" : "ManagerBridge");
ast_channel_data_set(tobj->chan, ast_channel_name(tobj->peer));
ast_channel_appl_set(tobj->peer, !tobj->return_to_pbx ? "Transferred Call" : "ManagerBridge");
@@ -987,15 +994,23 @@ static void *bridge_call_thread(void *data)
*
* Create thread and attributes, call bridge_call_thread
*/
-static void bridge_call_thread_launch(void *data)
+static void bridge_call_thread_launch(struct ast_bridge_thread_obj *data)
{
pthread_t thread;
pthread_attr_t attr;
struct sched_param sched;
+ /* This needs to be unreffed once it has been associated with the new thread. */
+ data->callid = ast_read_threadstorage_callid();
+
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- ast_pthread_create(&thread, &attr, bridge_call_thread, data);
+ if (ast_pthread_create(&thread, &attr, bridge_call_thread, data)) {
+ /* Failed to create thread. Ditch the reference to callid. */
+ ast_callid_unref(data->callid);
+ ast_log(LOG_ERROR, "Failed to create bridge_call_thread.\n");
+ return;
+ }
pthread_attr_destroy(&attr);
memset(&sched, 0, sizeof(sched));
pthread_setschedparam(thread, SCHED_RR, &sched);
@@ -8263,3 +8278,4 @@ int ast_features_init(void)
return res;
}
+