[Home]

Summary:ASTERISK-14571: [patch] 'h' extension never reach in a macro
Reporter:Serge Berney (sberney)Labels:
Date Opened:2009-07-31 07:05:28Date Closed:2011-06-07 14:00:23
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Applications/app_macro
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) app_macro_issue15623_2009-07-31_15h41.patch
( 1) pbx_issue15623_2009-07-31_15h41.patch
Description:Same than issue 14122 but on version 1.6.0.10, we are unable to reach "h" extension in a macro.

Sample dialplan :

[testing]
exten => 100, 1, Answer
exten => 100, n, Macro(test)

[macro-test]
exten => s, 1, Wait(2)
exten => s, n, Hangup
exten => h, 1, NoOp("Finish !")

Result in CLI is :

   -- Executing [100@testing:1] Answer("SIP/test-b786f960", "") in new stack
   -- Executing [100@testing:2] Macro("SIP/test-b786f960", "test") in new stack
   -- Executing [s@macro-test:1] Wait("SIP/test-b786f960", "2") in new stack
   -- Executing [s@macro-test:2] Hangup("SIP/test-b786f960", "") in new stack
 == Spawn extension (macro-test, s, 2) exited non-zero on 'SIP/test-b786f960' in macro 'test'
 == Spawn extension (testing, 100, 2) exited non-zero on 'SIP/test-b786f960'

And never reach "h" extension.

****** ADDITIONAL INFORMATION ******

Tested on 1.4.26-rc5 : working fine.
Comments:By: Serge Berney (sberney) 2009-07-31 08:35:43

I copy code from v 1.4.24-rc5 sources and that's now working.

Here's the modifications :

On apps/app_macro.c, line 457, add :

if (ast_check_hangup(chan) || res < 0) {
/* Don't need to lock the channel, as we aren't dereferencing emc.
* The intent here is to grab the deepest context, without overwriting
* in any above context. */
const char *emc = pbx_builtin_getvar_helper(chan, "EXIT_MACRO_CONTEXT");
if (!emc) {
pbx_builtin_setvar_helper(chan, "EXIT_MACRO_CONTEXT", fullmacro);
}
}

On file "main/pbx.c", line 3664, add :
const char *emc;

line 3859, add :
if ((emc = pbx_builtin_getvar_helper(c, "EXIT_MACRO_CONTEXT"))) {
emc = ast_strdupa(emc);
}

And modify "if" condition on line 3860..3862 to :
if ((!args || !args->no_hangup_chan) &&
!ast_test_flag(c, AST_FLAG_BRIDGE_HANGUP_RUN) &&
((emc && ast_exists_extension(c, emc, "h", 1, c->cid.cid_num)) ||
(ast_exists_extension(c, c->context, "h", 1, c->cid.cid_num) && (emc = c->context)))
) {

And add a line before line 3863 :
ast_copy_string(c->context, emc, sizeof(c->context));

By: Serge Berney (sberney) 2009-07-31 08:40:29

Patch files are available.



By: Leif Madsen (lmadsen) 2009-08-20 15:56:03

Tilghman, can you check to see if this is really a bug? I have a suspicion the behaviour change he may be seeing here is actually what we want to happen. Thanks!

By: Tilghman Lesher (tilghman) 2009-08-20 16:22:35

lmadsen:  you are correct.  The current behavior is what we want to see.

By: Serge Berney (sberney) 2009-08-21 03:08:21

What do you mean ? This is not a bug ? What do you want to see in future ?! :)

By: Tilghman Lesher (tilghman) 2009-08-21 09:22:38

The "h" extension is supposed to be called in the original context from where Macro was called, not within the macro itself.  True, it did this in the past, but that was a bug.

By: Andrew Lindh (andrew) 2009-08-23 07:13:05

Can we have the "old" way as an option? This new "feature" now causes existing working dialplans to fail.



By: Tilghman Lesher (tilghman) 2009-08-23 09:30:40

It's not a feature.  It's a bugfix.

By: Andrew Lindh (andrew) 2009-08-24 09:44:19

Which way is the bug fix? If you want it to work the "new" way, they it breaks the "old/existing" way. Since it has been working for so long people expect and depend on that mode of operation. If you want it to work the new way by default then at least have a switch to enable the old/compatible way.

By: Serge Berney (sberney) 2009-08-24 10:24:11

I'm agree that's normal to add-it as an optional switch in config file.
Removing stuff that people use isn't cool ;-)


Is there somebody ready to add it or explain me how to do it (add new config parameter, read value, ...) ? Thanks !

By: Tilghman Lesher (tilghman) 2009-08-24 11:03:56

The way Macro originally worked is the current method (that is, "h" is executed in the main context from which Macro is called, never within the Macro).  Because it has run out of the Macro context for the entire 1.4 series (a long running bug introduced in ASTERISK-6019), we decided that we would put in some code that would allow it to continue working this way in 1.4, but the correct behavior would exist in 1.6.

By: Leif Madsen (lmadsen) 2009-09-14 12:14:22

Closing this as there is no change required.