[asterisk-commits] moy: branch moy/mfcr2-1.4 r182163 - /team/moy/mfcr2-1.4/channels/chan_dahdi.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Mar 14 21:26:56 CDT 2009
Author: moy
Date: Sat Mar 14 21:26:51 2009
New Revision: 182163
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=182163
Log:
Set MFCR2_CATEGORY when creating the PBX channel to avoid race condition bug
Modified:
team/moy/mfcr2-1.4/channels/chan_dahdi.c
Modified: team/moy/mfcr2-1.4/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/moy/mfcr2-1.4/channels/chan_dahdi.c?view=diff&rev=182163&r1=182162&r2=182163
==============================================================================
--- team/moy/mfcr2-1.4/channels/chan_dahdi.c (original)
+++ team/moy/mfcr2-1.4/channels/chan_dahdi.c Sat Mar 14 21:26:51 2009
@@ -1096,11 +1096,10 @@
c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, DAHDI_LAW_ALAW, 0);
if (c) {
dahdi_r2_update_monitor_count(p->mfcr2, 0);
- pbx_builtin_setvar_helper(c, "MFCR2_CATEGORY", openr2_proto_get_category_string(p->mfcr2_recvd_category));
/* Don't disable reading since we still need to generate MF tone to accept
the call or reject it and detect the tone off condition of the other end */
} else {
- ast_log(LOG_WARNING, "Unable to start PBX on chan %d\n", p->channel);
+ ast_log(LOG_ERROR, "Unable to create PBX channel on chan %d\n", p->channel);
openr2_chan_disconnect_call(r2chan, OR2_CAUSE_OUT_OF_ORDER);
}
} else if (p->mfcr2_charge_calls) {
@@ -1147,9 +1146,8 @@
dahdi_r2_update_monitor_count(p->mfcr2, 0);
/* chan_dahdi will take care of reading from now on, tell the library to forget about it */
openr2_chan_disable_read(r2chan);
- pbx_builtin_setvar_helper(c, "MFCR2_CATEGORY", openr2_proto_get_category_string(p->mfcr2_recvd_category));
} else {
- ast_log(LOG_WARNING, "Unable to start PBX on chan %d\n", p->channel);
+ ast_log(LOG_ERROR, "Unable to create PBX channel on chan %d\n", p->channel);
openr2_chan_disconnect_call(r2chan, OR2_CAUSE_OUT_OF_ORDER);
return;
}
@@ -1263,24 +1261,24 @@
{
switch (level) {
case OR2_LOG_NOTICE:
- ast_log(LOG_NOTICE, logmessage);
+ ast_log(LOG_NOTICE, "%s", logmessage);
break;
case OR2_LOG_WARNING:
- ast_log(LOG_WARNING, logmessage);
+ ast_log(LOG_WARNING, "%s", logmessage);
break;
case OR2_LOG_ERROR:
- ast_log(LOG_ERROR, logmessage);
+ ast_log(LOG_ERROR, "%s", logmessage);
break;
case OR2_LOG_STACK_TRACE:
case OR2_LOG_MF_TRACE:
case OR2_LOG_CAS_TRACE:
case OR2_LOG_DEBUG:
case OR2_LOG_EX_DEBUG:
- ast_log(LOG_DEBUG, logmessage);
+ ast_log(LOG_DEBUG, "%s", logmessage);
break;
default:
ast_log(LOG_WARNING, "We should handle logging level %d here.\n", level);
- ast_log(LOG_DEBUG, logmessage);
+ ast_log(LOG_NOTICE, "%s", logmessage);
break;
}
}
@@ -1295,6 +1293,8 @@
ast_log(LOG_NOTICE, "Far end unblocked on chan %d\n", openr2_chan_get_number(r2chan));
}
+static void dahdi_r2_on_context_log(openr2_context_t *r2context, openr2_log_level_t level, const char *fmt, va_list ap)
+ __attribute__((format (printf, 3, 0)));
static void dahdi_r2_on_context_log(openr2_context_t *r2context, openr2_log_level_t level, const char *fmt, va_list ap)
{
char logmsg[256];
@@ -1304,6 +1304,8 @@
dahdi_r2_write_log(level, completemsg);
}
+static void dahdi_r2_on_chan_log(openr2_chan_t *r2chan, openr2_log_level_t level, const char *fmt, va_list ap)
+ __attribute__((format (printf, 3, 0)));
static void dahdi_r2_on_chan_log(openr2_chan_t *r2chan, openr2_log_level_t level, const char *fmt, va_list ap)
{
char logmsg[256];
@@ -1366,7 +1368,8 @@
.on_protocol_error = dahdi_r2_on_protocol_error,
.on_line_blocked = dahdi_r2_on_line_blocked,
.on_line_idle = dahdi_r2_on_line_idle,
- .on_context_log = dahdi_r2_on_context_log,
+ /* cast seems to be needed to get rid of the annoying warning regarding format attribute */
+ .on_context_log = (openr2_handle_context_logging_func)dahdi_r2_on_context_log,
.on_dnis_digit_received = dahdi_r2_on_dnis_digit_received,
.on_ani_digit_received = dahdi_r2_on_ani_digit_received,
/* so far we do nothing with billing pulses */
@@ -6170,6 +6173,9 @@
/* Assume calls are not idle calls unless we're told differently */
i->isidlecall = 0;
i->alreadyhungup = 0;
+#endif
+#ifdef HAVE_OPENR2
+ pbx_builtin_setvar_helper(tmp, "MFCR2_CATEGORY", openr2_proto_get_category_string(i->mfcr2_recvd_category));
#endif
/* clear the fake event in case we posted one before we had ast_channel */
i->fake_event = 0;
@@ -8261,7 +8267,8 @@
return NULL;
}
openr2_chan_set_client_data(tmp->r2chan, tmp);
- openr2_chan_set_logging_func(tmp->r2chan, dahdi_r2_on_chan_log);
+ /* cast seems to be needed to get rid of the annoying warning regarding format attribute */
+ openr2_chan_set_logging_func(tmp->r2chan, (openr2_logging_func_t)dahdi_r2_on_chan_log);
openr2_chan_set_log_level(tmp->r2chan, mfcr2_cur_loglevel);
if (mfcr2_cur_call_files) {
openr2_chan_enable_call_files(tmp->r2chan);
More information about the asterisk-commits
mailing list