[svn-commits] jrose: trunk r332760 - in /trunk: ./ configs/ include/asterisk/ main/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Aug 22 12:05:18 CDT 2011
Author: jrose
Date: Mon Aug 22 12:05:14 2011
New Revision: 332760
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=332760
Log:
Add option for logging congested calls as CONGESTION instead of NO_ANSWER in CDR
This patch adds a CDR option to cdr.conf that will allow CDR files to log calls ending
with congestion in a way that is unique from other unanswered calls.
(closes issue ASTERISK-14842)
Reported by: Alec Davis
Patches:
cdr_congestion.diff.txt (License #5546) patch uploaded by Alec Davis
Modified:
trunk/CHANGES
trunk/configs/cdr.conf.sample
trunk/include/asterisk/cdr.h
trunk/main/cdr.c
trunk/main/pbx.c
Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=332760&r1=332759&r2=332760
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Aug 22 12:05:14 2011
@@ -84,6 +84,7 @@
--------------------------
* The filter option in cdr_adaptive_odbc now supports negating the argument,
thus allowing records which do NOT match the specified filter.
+ * Added ability to log CONGESTION calls to CDR
CODECS
--------------------------
Modified: trunk/configs/cdr.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/cdr.conf.sample?view=diff&rev=332760&r1=332759&r2=332760
==============================================================================
--- trunk/configs/cdr.conf.sample (original)
+++ trunk/configs/cdr.conf.sample Mon Aug 22 12:05:14 2011
@@ -28,6 +28,11 @@
; output, as they have the B side channel as their source channel, and no destination
; channel.)
;unanswered = no
+
+; Define whether or not to log congested calls. Setting this to "yes" will
+; report each call that fails to complete due to congestion conditions. Default
+; is "no".
+;congestion = no
; Normally, CDR's are not closed out until after all extensions are finished
; executing. By enabling this option, the CDR will be ended before executing
Modified: trunk/include/asterisk/cdr.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/cdr.h?view=diff&rev=332760&r1=332759&r2=332760
==============================================================================
--- trunk/include/asterisk/cdr.h (original)
+++ trunk/include/asterisk/cdr.h Mon Aug 22 12:05:14 2011
@@ -58,6 +58,7 @@
AST_CDR_FAILED = (1 << 1),
AST_CDR_BUSY = (1 << 2),
AST_CDR_ANSWERED = (1 << 3),
+ AST_CDR_CONGESTION = (1 << 4),
};
/*!
@@ -133,6 +134,7 @@
};
int ast_cdr_isset_unanswered(void);
+int ast_cdr_isset_congestion(void);
void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur, int raw);
int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int recur);
int ast_cdr_serialize_variables(struct ast_cdr *cdr, struct ast_str **buf, char delim, char sep, int recur);
@@ -267,6 +269,15 @@
extern void ast_cdr_noanswer(struct ast_cdr *cdr);
/*!
+ * \brief A call was set to congestion
+ * \param cdr the cdr you wish to associate with the call
+ * Markst he channel disposition as "CONGESTION"
+ * Will skip CDR's in chain with ANS_LOCK bit set. (see
+ * forkCDR() application
+ */
+extern void ast_cdr_congestion(struct ast_cdr *cdr);
+
+/*!
* \brief Busy a call
* \param cdr the cdr you wish to associate with the call
* Marks the channel disposition as "BUSY"
Modified: trunk/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cdr.c?view=diff&rev=332760&r1=332759&r2=332760
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Mon Aug 22 12:05:14 2011
@@ -93,6 +93,9 @@
static int unanswered;
static const int UNANSWERED_DEFAULT = 0;
+static int congestion;
+static const int CONGESTION_DEFAULT = 0;
+
static int batchsize;
static const int BATCH_SIZE_DEFAULT = 100;
@@ -179,6 +182,11 @@
int ast_cdr_isset_unanswered(void)
{
return unanswered;
+}
+
+int ast_cdr_isset_congestion(void)
+{
+ return congestion;
}
struct ast_cdr *ast_cdr_dup_unique(struct ast_cdr *cdr)
@@ -776,6 +784,34 @@
}
}
+void ast_cdr_congestion(struct ast_cdr *cdr)
+{
+ char *chan;
+
+ ast_verb (1, "congestion value: %d\n INYOURFACE", congestion);
+
+
+ /* if congestion log is disabled, pass the buck to ast_cdr_failed */
+ if (!congestion) {
+ ast_cdr_failed(cdr);
+ }
+
+ while (cdr && congestion) {
+ if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
+ chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
+
+ if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED)) {
+ ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+ }
+
+ if (cdr->disposition < AST_CDR_CONGESTION) {
+ cdr->disposition = AST_CDR_CONGESTION;
+ }
+ }
+ cdr = cdr->next;
+ }
+}
+
/* everywhere ast_cdr_disposition is called, it will call ast_cdr_failed()
if ast_cdr_disposition returns a non-zero value */
@@ -791,6 +827,9 @@
break;
case AST_CAUSE_NO_ANSWER:
ast_cdr_noanswer(cdr);
+ break;
+ case AST_CAUSE_NORMAL_CIRCUIT_CONGESTION:
+ ast_cdr_congestion(cdr);
break;
case AST_CAUSE_NORMAL:
break;
@@ -961,6 +1000,8 @@
return "BUSY";
case AST_CDR_ANSWERED:
return "ANSWERED";
+ case AST_CDR_CONGESTION:
+ return "CONGESTION";
}
return "UNKNOWN";
}
@@ -1416,7 +1457,8 @@
ast_cli(a->fd, " Logging: %s\n", enabled ? "Enabled" : "Disabled");
ast_cli(a->fd, " Mode: %s\n", batchmode ? "Batch" : "Simple");
if (enabled) {
- ast_cli(a->fd, " Log unanswered calls: %s\n\n", unanswered ? "Yes" : "No");
+ ast_cli(a->fd, " Log unanswered calls: %s\n", unanswered ? "Yes" : "No");
+ ast_cli(a->fd, " Log congestion: %s\n\n", congestion ? "Yes" : "No");
if (batchmode) {
ast_cli(a->fd, "* Batch Mode Settings\n");
ast_cli(a->fd, " -------------------\n");
@@ -1477,6 +1519,7 @@
struct ast_config *config;
const char *enabled_value;
const char *unanswered_value;
+ const char *congestion_value;
const char *batched_value;
const char *scheduleronly_value;
const char *batchsafeshutdown_value;
@@ -1507,6 +1550,7 @@
enabled = ENABLED_DEFAULT;
batchmode = BATCHMODE_DEFAULT;
unanswered = UNANSWERED_DEFAULT;
+ congestion = CONGESTION_DEFAULT;
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
ast_mutex_unlock(&cdr_batch_lock);
@@ -1522,6 +1566,10 @@
}
if ((unanswered_value = ast_variable_retrieve(config, "general", "unanswered"))) {
unanswered = ast_true(unanswered_value);
+ }
+ if ((congestion_value = ast_variable_retrieve(config, "general", "congestion"))) {
+ ast_verb(1, "INTHEFACEPUNCH!\n");
+ congestion = ast_true(congestion_value);
}
if ((batched_value = ast_variable_retrieve(config, "general", "batch"))) {
batchmode = ast_true(batched_value);
Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=332760&r1=332759&r2=332760
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Mon Aug 22 12:05:14 2011
@@ -9323,11 +9323,16 @@
*/
static int pbx_builtin_congestion(struct ast_channel *chan, const char *data)
{
+ ast_verb(1, "pbx_builtin_congestion HITINTHEFACE!\n");
+ ast_verb(1, "AST_STATE = %d INTHEFACE\n", chan->_state);
ast_indicate(chan, AST_CONTROL_CONGESTION);
/* Don't change state of an UP channel, just indicate
congestion in audio */
- if (chan->_state != AST_STATE_UP)
+ if (chan->_state != AST_STATE_UP) {
ast_setstate(chan, AST_STATE_BUSY);
+ ast_verb(1, "ast_cdr_congestion INTHEFACE\n");
+ ast_cdr_congestion(chan->cdr);
+ }
wait_for_hangup(chan, data);
return -1;
}
More information about the svn-commits
mailing list