[asterisk-commits] jrose: branch jrose/call_identifiers r360577 - in /team/jrose/call_identifier...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 27 09:53:41 CDT 2012
Author: jrose
Date: Tue Mar 27 09:53:37 2012
New Revision: 360577
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=360577
Log:
More iterative improvement, adds ability to disable logging of callids.
Modified:
team/jrose/call_identifiers/CHANGES
team/jrose/call_identifiers/apps/app_mixmonitor.c
team/jrose/call_identifiers/configs/logger.conf.sample
team/jrose/call_identifiers/include/asterisk/ccss.h
team/jrose/call_identifiers/include/asterisk/logger.h
team/jrose/call_identifiers/main/bridging.c
team/jrose/call_identifiers/main/ccss.c
team/jrose/call_identifiers/main/dial.c
team/jrose/call_identifiers/main/features.c
team/jrose/call_identifiers/main/logger.c
Modified: team/jrose/call_identifiers/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/CHANGES?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/CHANGES (original)
+++ team/jrose/call_identifiers/CHANGES Tue Mar 27 09:53:37 2012
@@ -23,6 +23,10 @@
modules that are loaded into Asterisk, since they should only be called once
in any single process. If desired, this feature can be disabled by supplying
the "--disable-asteriskssl" option to the configure script.
+ * Threads belonging to a particular call are now linked with callids which get
+ added to any log messages produced by those threads. Log messages can now be
+ easily identified as involved with a certain call by looking at their call id.
+ This feature can be disabled in logger.conf with the display_callids option.
CLI Changes
-------------------
Modified: team/jrose/call_identifiers/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/apps/app_mixmonitor.c?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/apps/app_mixmonitor.c (original)
+++ team/jrose/call_identifiers/apps/app_mixmonitor.c Tue Mar 27 09:53:37 2012
@@ -684,10 +684,8 @@
return;
}
- if ((mixmonitor->callid = ast_read_threadstorage_callid())) {
- ast_callid_ref(mixmonitor->callid);
- /* reference be released at mixmonitor destruction */
- }
+ /* reference be released at mixmonitor destruction */
+ mixmonitor->callid = ast_read_threadstorage_callid();
ast_pthread_create_detached_background(&thread, NULL, mixmonitor_thread, mixmonitor);
}
Modified: team/jrose/call_identifiers/configs/logger.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/configs/logger.conf.sample?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/configs/logger.conf.sample (original)
+++ team/jrose/call_identifiers/configs/logger.conf.sample Tue Mar 27 09:53:37 2012
@@ -18,6 +18,11 @@
;
;dateformat=%F %T ; ISO 8601 date format
;dateformat=%F %T.%3q ; with milliseconds
+;
+;
+; This makes Asterisk write callids to log messages
+; (defaults to yes)
+;use_callids = no
;
; This appends the hostname to the name of the log files.
;appendhostname = yes
Modified: team/jrose/call_identifiers/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/include/asterisk/ccss.h?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/include/asterisk/ccss.h (original)
+++ team/jrose/call_identifiers/include/asterisk/ccss.h Tue Mar 27 09:53:37 2012
@@ -873,11 +873,6 @@
* represents/communicates with
*/
char device_name[1];
- /*! If a thread is created for this cc_agent by another call
- * related thread, it will be attached to a callid.
- */
- struct ast_callid *callid;
-
};
enum ast_cc_agent_response_reason {
Modified: team/jrose/call_identifiers/include/asterisk/logger.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/include/asterisk/logger.h?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/include/asterisk/logger.h (original)
+++ team/jrose/call_identifiers/include/asterisk/logger.h Tue Mar 27 09:53:37 2012
@@ -246,11 +246,10 @@
/*!
* \brief extracts the callerid from the thread
*
- * \revtal ast_callid struct pointer containing the call_id related to the thread
+ * \revtal ast_callid reference to call_id related to the thread
* \retval NULL if no call_id is present in the thread
*
- * \note this reference is only guaranteed as valid as long as the thread it is pulled from is
- * alive unless its reference is bumped.
+ * This reference must be unreffed before it loses scope to prevent memory leaks.
*/
struct ast_callid *ast_read_threadstorage_callid(void);
Modified: team/jrose/call_identifiers/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/main/bridging.c?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/main/bridging.c (original)
+++ team/jrose/call_identifiers/main/bridging.c Tue Mar 27 09:53:37 2012
@@ -980,9 +980,8 @@
if (bridge_channel->bridge->thread == AST_PTHREADT_NULL && (bridge_channel->bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_THREAD)) {
bridge_channel->bridge->stop = 0;
- if ((bridge_channel->bridge->callid = ast_read_threadstorage_callid())) {
- ast_callid_ref(bridge_channel->bridge->callid);
- }
+ /* callid must be unreffed once it is no longer in use */
+ bridge_channel->bridge->callid = ast_read_threadstorage_callid();
ast_debug(1, "Starting a bridge thread for bridge %p\n", bridge_channel->bridge);
ao2_ref(bridge_channel->bridge, +1);
@@ -1173,9 +1172,8 @@
bridge_channel->features = features;
bridge_channel->allow_impart_hangup = allow_hangup;
- if ((bridge_channel->callid = ast_read_threadstorage_callid())) {
- ast_callid_ref(bridge_channel->callid);
- }
+ /* callid must be unreffed when it is no longer in use */
+ bridge_channel->callid = ast_read_threadstorage_callid();
/* Actually create the thread that will handle the channel */
if (ast_pthread_create(&bridge_channel->thread, NULL, bridge_channel_thread, bridge_channel)) {
Modified: team/jrose/call_identifiers/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/main/ccss.c?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/main/ccss.c (original)
+++ team/jrose/call_identifiers/main/ccss.c Tue Mar 27 09:53:37 2012
@@ -2410,9 +2410,6 @@
if (agent->callbacks) {
agent->callbacks->destructor(agent);
}
- if (agent->callid) {
- ast_callid_unref(agent->callid);
- }
ast_cc_config_params_destroy(agent->cc_params);
}
@@ -2689,10 +2686,6 @@
struct ast_format tmp_fmt;
struct ast_format_cap *tmp_cap = ast_format_cap_alloc_nolock();
- if (agent->callid) {
- ast_callid_threadassoc_add(agent->callid);
- }
-
if (!tmp_cap) {
return NULL;
}
@@ -2764,10 +2757,6 @@
*/
ast_cc_agent_caller_busy(agent->core_id, "Generic agent caller %s is busy", agent->device_name);
return 0;
- }
-
- if ((agent->callid = ast_read_threadstorage_callid())) {
- ast_callid_ref(agent->callid);
}
ast_pthread_create_detached_background(&clotho, NULL, generic_recall, agent);
Modified: team/jrose/call_identifiers/main/dial.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/main/dial.c?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/main/dial.c (original)
+++ team/jrose/call_identifiers/main/dial.c Tue Mar 27 09:53:37 2012
@@ -742,10 +742,8 @@
/* If we are running async spawn a thread and send it away... otherwise block here */
if (async) {
- if ((dial->callid = ast_read_threadstorage_callid())) {
- ast_callid_ref(dial->callid);
- /* reference be released at dial destruction */
- }
+ /* reference be released at dial destruction if it isn't NULL */
+ dial->callid = ast_read_threadstorage_callid();
dial->state = AST_DIAL_RESULT_TRYING;
/* Try to create a thread */
if (ast_pthread_create(&dial->thread, NULL, async_dial, dial)) {
Modified: team/jrose/call_identifiers/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/main/features.c?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/main/features.c (original)
+++ team/jrose/call_identifiers/main/features.c Tue Mar 27 09:53:37 2012
@@ -1000,10 +1000,8 @@
pthread_attr_t attr;
struct sched_param sched;
- if ((data->callid = ast_read_threadstorage_callid())) {
- ast_callid_ref(data->callid);
- /* Needs to be dereffed and set to null immediately after the thread has associated it */
- }
+ /* 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);
Modified: team/jrose/call_identifiers/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/call_identifiers/main/logger.c?view=diff&rev=360577&r1=360576&r2=360577
==============================================================================
--- team/jrose/call_identifiers/main/logger.c (original)
+++ team/jrose/call_identifiers/main/logger.c Tue Mar 27 09:53:37 2012
@@ -75,6 +75,7 @@
static int queuelog_init;
static int logger_initialized;
static volatile int next_unique_callid; /* Used to assign unique call_ids to calls */
+static int display_callids;
static void unique_callid_cleanup(void *data);
struct ast_callid {
@@ -338,6 +339,8 @@
const char *s;
struct ast_flags config_flags = { 0 };
+ display_callids = 1;
+
if (!(cfg = ast_config_load2(S_OR(altconf, "logger.conf"), "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
return;
}
@@ -391,6 +394,9 @@
hostname[0] = '\0';
} else
hostname[0] = '\0';
+ if ((s = ast_variable_retrieve(cfg, "general", "display_callids"))) {
+ display_callids = ast_true(s);
+ }
if ((s = ast_variable_retrieve(cfg, "general", "dateformat")))
ast_copy_string(dateformat, s, sizeof(dateformat));
else
@@ -1253,6 +1259,7 @@
struct ast_callid **callid;
callid = ast_threadstorage_get(&unique_callid, sizeof(struct ast_callid **));
if (callid && *callid) {
+ ast_callid_ref(*callid);
return *callid;
}
@@ -1351,9 +1358,8 @@
logmsg->type = LOGMSG_NORMAL;
}
- if (callid) {
- ast_callid_ref(callid);
- logmsg->callid = (callid);
+ if (display_callids && callid) {
+ logmsg->callid = ast_callid_ref(callid);
/* callid will be unreffed at logmsg destruction */
}
@@ -1394,6 +1400,10 @@
va_start(ap, fmt);
ast_log_full(level, file, line, function, callid, fmt, ap);
va_end(ap);
+
+ if (callid) {
+ ast_callid_unref(callid);
+ }
}
void ast_log_callid(int level, const char *file, int line, const char *function, struct ast_callid *callid, const char *fmt, ...)
More information about the asterisk-commits
mailing list