[Asterisk-code-review] app dial: remove pending CONNECTED LINE updates before initi... (asterisk[13])
Alexei Gradinari
asteriskteam at digium.com
Fri Jul 20 15:14:13 CDT 2018
Alexei Gradinari has uploaded this change for review. ( https://gerrit.asterisk.org/9558
Change subject: app_dial: remove pending CONNECTED LINE updates before initialize calls
......................................................................
app_dial: remove pending CONNECTED LINE updates before initialize calls
Alice calls Bob.
Alice does an attended transfer to Charlie.
The Caller ID is modified to some ID using either CALLERID function
or Dial options 'o([x])' on outgoing context before Dial Charlie's endpoint.
But the From: header contains "Alice" on INVITE to Charlie,
and not what is set before.
The app Dial initially correctly sets CONNECTED LINE on outgoing channels
as CALLERID of the originating channel.
But then the app Dial reads pending CONNECTED LINE update on the originating
channel and sets CONNECTED LINE on outgoing channels with this data.
The processed pending CONNECTED LINE update already sets CALLERID
on originating channel, so all pending CONNECTED LINE updates
have to be ignored and removed before initialize outgoing calls.
ASTERISK-27980 #close
Change-Id: I346652661949b6611c23e431ede0dbea1be3017a
---
M apps/app_dial.c
M apps/app_followme.c
M apps/app_queue.c
M include/asterisk/channel.h
M main/channel.c
5 files changed, 49 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/58/9558/1
diff --git a/apps/app_dial.c b/apps/app_dial.c
index ea7ddd1..b1a9e46 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -2234,6 +2234,10 @@
pbx_builtin_setvar_helper(chan, "DIALEDTIME", "");
ast_channel_stage_snapshot_done(chan);
max_forwards = ast_max_forwards_get(chan);
+
+ /* Remove all pending CONNECTED LINE updates */
+ ast_remove_queue_connected_line_frames(chan);
+
ast_channel_unlock(chan);
if (max_forwards <= 0) {
diff --git a/apps/app_followme.c b/apps/app_followme.c
index 43b95e7..c557138 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -1332,6 +1332,8 @@
ast_channel_lock(chan);
max_forwards = ast_max_forwards_get(chan);
+ /* Remove all pending CONNECTED LINE updates */
+ ast_remove_queue_connected_line_frames(chan);
ast_channel_unlock(chan);
if (max_forwards <= 0) {
diff --git a/apps/app_queue.c b/apps/app_queue.c
index f783ac9..fea03e0 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -7918,6 +7918,8 @@
ast_channel_lock(chan);
max_forwards = ast_max_forwards_get(chan);
+ /* Remove all pending CONNECTED LINE updates */
+ ast_remove_queue_connected_line_frames(chan);
ast_channel_unlock(chan);
if (max_forwards <= 0) {
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index d709159..143230f 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -1948,6 +1948,18 @@
*/
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);
+/*!
+ * \brief remove all control CONNECTED LINE frames from channel's pending read queue.
+ * \since 13.23.0
+ *
+ * \param chan channel to remove frames
+ *
+ * \note this function assumes chan is locked
+ *
+ * \retval number of frames removed
+ */
+int ast_remove_queue_connected_line_frames(struct ast_channel *chan);
+
/*!
* \brief Reads a frame
diff --git a/main/channel.c b/main/channel.c
index ca50d46..9d18ffd 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -4414,6 +4414,35 @@
return __ast_read(chan, 0);
}
+/*!
+ * \brief remove all control CONNECTED LINE frames from channel's pending read queue.
+ * \since 13.23.0
+ *
+ * \param chan channel to remove frames
+ *
+ * \note this function assumes chan is locked
+ *
+ * \retval number of frames removed
+ */
+int ast_remove_queue_connected_line_frames(struct ast_channel *chan)
+{
+ int cnt = 0;
+ struct ast_frame *f;
+
+ if (chan && !AST_LIST_EMPTY(ast_channel_readq(chan))) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(ast_channel_readq(chan), f, frame_list) {
+ if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer==AST_CONTROL_CONNECTED_LINE) {
+ AST_LIST_REMOVE_CURRENT(frame_list);
+ ast_frfree(f);
+ cnt++;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ }
+
+ return cnt;
+}
+
struct ast_frame *ast_read_noaudio(struct ast_channel *chan)
{
return __ast_read(chan, 1);
--
To view, visit https://gerrit.asterisk.org/9558
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I346652661949b6611c23e431ede0dbea1be3017a
Gerrit-Change-Number: 9558
Gerrit-PatchSet: 1
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180720/e044a849/attachment.html>
More information about the asterisk-code-review
mailing list