[Home]

Summary:ASTERISK-26464: Pickup() semantics changed between 1.4 and 1.8
Reporter:Walter Doekes (wdoekes)Labels:
Date Opened:2016-10-13 06:08:42Date Closed:2016-10-13 13:07:09
Priority:MajorRegression?Yes
Status:Closed/CompleteComponents:Applications/app_directed_pickup
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) ASTERISK-26464_add_PickupOld1v4_application.patch
Description:Imagine this dialplan:
{noformat}
[incoming]
exten => 200,1,Goto(outgoing,call,1)
exten => *200,1,Goto(pickup,both,1)

[outgoing]
exten => call,1,Dial(SIP/alice)

[pickup]
exten => both,1,Pickup(call@incoming)
exten => both,n,PickupOld1v4(call@outgoing)
{noformat}

Bob calls Alice by calling '200' ({{core show channels}}):

{noformat}
SIP/bob-0000000  call@outgoing:1  Ring     Dial(SIP/alice)
SIP/alice-00000  call@incoming:1  Ringing  AppDial((Outgoing Line))
                     ^
                     |
{noformat}

There is no call@incoming, yet that's what exten+context contain. (I'm not sure if this is a bug or a feature, but it's how it is and tampering with that would probably inflict all sorts of havoc.)

So, when Charlie tries to pick up the call using {{Pickup()}}, we have to use the odd {{call@incoming}} identifier instead of {{call@outgoing}}.

This was unintentionally changed in commit {{cba19c8a671}} (in 2009, merged into what became Asterisk 1.8) when this code got changed:
{noformat}
--- a/apps/app_directed_pickup.c
+++ b/apps/app_directed_pickup.c
...
-static int find_by_exten(struct ast_channel *c, void *data)
-{
-       struct pickup_criteria *info = data;
-
-       return (!strcasecmp(c->macroexten, info->exten) || !strcasecmp(c->exten, info->exten)) &&
-               !strcasecmp(c->dialcontext, info->context) &&
-               can_pickup(c);
-}
...
-       target = ast_channel_search_locked(find_by_exten, &search);
+       if (!(iter = ast_channel_iterator_by_exten_new(0, exten, context))) {
...
{noformat}
Unlike the find_by_exten above, the new iterator uses 'context':
{noformat}
--- a/main/channel.c
+++ b/main/channel.c
...
+                       if (i->context && strcasecmp(chan->context, i->context) &&
+                                       strcasecmp(chan->macrocontext, i->context)) {
...
{noformat}

The check that used the 'dialcontext' now uses the checks used by ast_channel_iterator_by_exten_new; which is 'context'.

This breaks Pickup semantics between pre-1.8 (e.g. Asterisk 1.4) and 1.8 and higher.

----

While I don't think it makes sense to change {{Pickup()}} again, I've filed this ticket for future reference: for those still migrating from Asterisk 1.4 upwards, this could pose an upgrade hurdle.

On the other hand, I don't really see how the *new* semantics are worth anything. Who would use Pickup referencing exten+context where the combination doesn't exist in the dialplan, unless they're intimately familiar with the inner workings?

Attached a patch that adds {{PickupOld1v4()}} with the old semantics.
Comments:By: Asterisk Team (asteriskteam) 2016-10-13 06:08:43.153-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Rusty Newton (rnewton) 2016-10-13 13:07:09.750-0500

Thanks for pointing this out Walter. I'm sure it will be useful to others.

I'll go ahead and close it out since there isn't anything else to do with it at the moment.

We are not likely to change this behavior since it has been this way for a long while now with no complaints and pickup is a commonly used feature.

It is odd that we seemed to have missed that change way back then.

You are always welcome to bring up a conversation on the dev list about changing it , if you felt it was worth it of course!

Thanks!