[svn-commits] dhubbard: branch 1.4 r84018 - in /branches/1.4: channels/ include/asterisk/ m...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Sep 27 18:12:25 CDT 2007
Author: dhubbard
Date: Thu Sep 27 18:12:25 2007
New Revision: 84018
URL: http://svn.digium.com/view/asterisk?view=rev&rev=84018
Log:
if an Agent is redirected, the base channel should actually be redirected. This was causing multiple issues, especially issue 7706 and BE-160
Modified:
branches/1.4/channels/chan_agent.c
branches/1.4/include/asterisk/channel.h
branches/1.4/main/manager.c
Modified: branches/1.4/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_agent.c?view=diff&rev=84018&r1=84017&r2=84018
==============================================================================
--- branches/1.4/channels/chan_agent.c (original)
+++ branches/1.4/channels/chan_agent.c Thu Sep 27 18:12:25 2007
@@ -251,6 +251,8 @@
static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
static void set_agentbycallerid(const char *callerid, const char *agent);
+static struct ast_channel* agent_get_base_channel(struct ast_channel *chan);
+static int agent_set_base_channel(struct ast_channel *chan, struct ast_channel *base);
/*! \brief Channel interface description for PBX integration */
static const struct ast_channel_tech agent_tech = {
@@ -273,6 +275,8 @@
.indicate = agent_indicate,
.fixup = agent_fixup,
.bridged_channel = agent_bridgedchannel,
+ .get_base_channel = agent_get_base_channel,
+ .set_base_channel = agent_set_base_channel,
};
/*!
@@ -724,6 +728,37 @@
snprintf(buf, sizeof(buf), "%s_%s", GETAGENTBYCALLERID, callerid);
pbx_builtin_setvar_helper(NULL, buf, agent);
+}
+
+struct ast_channel* agent_get_base_channel(struct ast_channel *chan)
+{
+ struct agent_pvt *p = NULL;
+ struct ast_channel *base = NULL;
+
+ if (!chan || !chan->tech_pvt) {
+ ast_log(LOG_ERROR, "whoa, you need a channel (0x%ld) with a tech_pvt (0x%ld) to get a base channel.\n", (long)chan, (chan)?(long)chan->tech_pvt:(long)NULL);
+ } else {
+ p = chan->tech_pvt;
+ base = p->chan;
+ }
+ return base;
+}
+
+int agent_set_base_channel(struct ast_channel *chan, struct ast_channel *base)
+{
+ struct agent_pvt *p = NULL;
+
+ if (!chan || !base) {
+ ast_log(LOG_ERROR, "whoa, you need a channel (0x%ld) and a base channel (0x%ld) for setting.\n", (long)chan, (long)base);
+ return -1;
+ }
+ p = chan->tech_pvt;
+ if (!p) {
+ ast_log(LOG_ERROR, "whoa, channel %s is missing his tech_pvt structure!!.\n", chan->name);
+ return -1;
+ }
+ p->chan = base;
+ return 0;
}
static int agent_hangup(struct ast_channel *ast)
Modified: branches/1.4/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/channel.h?view=diff&rev=84018&r1=84017&r2=84018
==============================================================================
--- branches/1.4/include/asterisk/channel.h (original)
+++ branches/1.4/include/asterisk/channel.h Thu Sep 27 18:12:25 2007
@@ -264,6 +264,12 @@
/*! \brief Provide additional write items for CHANNEL() dialplan function */
int (* func_channel_write)(struct ast_channel *chan, char *function, char *data, const char *value);
+
+ /*! \brief Retrieve base channel (agent and local) */
+ struct ast_channel* (* get_base_channel)(struct ast_channel *chan);
+
+ /*! \brief Set base channel (agent and local) */
+ int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base);
};
struct ast_channel_spy_list;
Modified: branches/1.4/main/manager.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/manager.c?view=diff&rev=84018&r1=84017&r2=84018
==============================================================================
--- branches/1.4/main/manager.c (original)
+++ branches/1.4/main/manager.c Thu Sep 27 18:12:25 2007
@@ -1550,7 +1550,7 @@
const char *exten = astman_get_header(m, "Exten");
const char *context = astman_get_header(m, "Context");
const char *priority = astman_get_header(m, "Priority");
- struct ast_channel *chan, *chan2 = NULL;
+ struct ast_channel *base, *chan, *chan2 = NULL;
int pi = 0;
int res;
@@ -1572,6 +1572,14 @@
astman_send_error(s, m, buf);
return 0;
}
+ if (chan->tech->get_base_channel) {
+ base = chan->tech->get_base_channel(chan);
+ if (base) {
+ ast_mutex_unlock(&chan->lock);
+ chan = base;
+ ast_mutex_lock(&chan->lock);
+ }
+ }
if (ast_check_hangup(chan)) {
astman_send_error(s, m, "Redirect failed, channel not up.\n");
ast_channel_unlock(chan);
@@ -1584,6 +1592,14 @@
ast_channel_unlock(chan);
ast_channel_unlock(chan2);
return 0;
+ }
+ if (chan2 && chan2->tech->get_base_channel) {
+ base = chan2->tech->get_base_channel(chan2);
+ if (base) {
+ ast_mutex_unlock(&chan2->lock);
+ chan2 = base;
+ ast_mutex_lock(&chan2->lock);
+ }
}
res = ast_async_goto(chan, context, exten, pi);
if (!res) {
More information about the svn-commits
mailing list