Summary: | ASTERISK-08101: [patch] A GoSub called from within a Macro clears MACRO_EXTEN, others | ||
Reporter: | Terry Wilson (twilson) | Labels: | |
Date Opened: | 2006-11-09 18:05:51.000-0600 | Date Closed: | 2007-08-29 14:18:32 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Applications/app_macro |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) 20061110__bug8329__gosub_within_macro.diff.txt ( 1) 20061116__bug8329.diff.txt ( 2) 20061117__bug8329__gosub_within_macro.diff.txt ( 3) 20070722__bug8329.diff.txt ( 4) app_macro_gosub_fix.patch.txt | |
Description: | When a GoSub/Return is called from within a Macro, MACRO_EXTEN, ARG*, etc. are cleared. ****** STEPS TO REPRODUCE ****** default] exten => _X.,1,Macro(test) [macro-test] exten => s,1,NoOp(Starting MACRO_EXTEN is '${MACRO_EXTEN}') exten => s,n,GoSub(sub-test,s,1) exten => s,n,NoOp(Now MACRO_EXTEN is '${MACRO_EXTEN}') [sub-test] exten => s,1,NoOp(Sub test) exten => s,n,Return ****** ADDITIONAL INFORMATION ****** Output of above: sd3test*CLI> dial 123@default The 'dial' command is deprecated and will be removed in a future release. Please use 'console dial' instead. [Nov 9 17:37:00] WARNING[22584]: chan_oss.c:686 setformat: Unable to re-open DSP device /dev/dsp: No such file or directory -- Executing [123@default:1] Macro("OSS/dsp", "test") in new stack -- Executing [s@macro-test:1] NoOp("OSS/dsp", "Starting MACRO_EXTEN is 123") in new stack -- Executing [s@macro-test:2] Gosub("OSS/dsp", "sub-test|s|1") in new stack == Channel 'OSS/dsp' jumping out of macro 'test' -- Executing [s@sub-test:1] NoOp("OSS/dsp", "Sub test") in new stack -- Executing [s@sub-test:2] Return("OSS/dsp", "") in new stack -- Executing [s@macro-test:3] NoOp("OSS/dsp", "Now MACRO_EXTEN is ") in new stack | ||
Comments: | By: Leif Madsen (lmadsen) 2006-11-09 18:06:59.000-0600 Tested here, and confirmed it exists in 1.4/trunk. By: Leif Madsen (lmadsen) 2006-11-09 18:24:13.000-0600 Ummm... I think acknowledged is a better status.... By: Tilghman Lesher (tilghman) 2006-11-10 07:27:10.000-0600 That is correct. The problem is that it is verboten to jump out of the Macro context from within Macro. You'll need to restrict your Gosub to running within the same Macro context or else don't mix Macro and Gosub. By: Tilghman Lesher (tilghman) 2006-11-10 07:29:42.000-0600 blitzrage: per bug marshal guidelines, "confirmed" is the correct status for reported issues. "acknowledged" is for feature patches. By: Terry Wilson (twilson) 2006-11-10 17:03:56.000-0600 Corydon76: Do you mean verboten in the since that we should leave the beahviour as is, or that it just currently doesn't allow this, but the behaviour can be changed? By: Tilghman Lesher (tilghman) 2006-11-10 17:32:15.000-0600 The behavior is such because when Macro sees you try to jump out of the macro context, it immediately exits. That is why when you return, none of your arguments are set. It is part of the design of Macro to intentionally exit when you jump out of the macro context, and I'm not sure that we could change that behavior without potentially affecting hundreds of Asterisk installations. The only possible logical change might be to enable Macro not to jump out when it encounters a Gosub, but that's rather tricky, as not all Gosub's will return (for example, if you execute a StackPop). Going forward, it is likely that Macro will entirely disappear, due to the issue with stack usage. However, that's not going to happen at least until after 1.6 is released, which is likely more than a year away. By: Tilghman Lesher (tilghman) 2006-11-10 18:11:22.000-0600 This _might_ work. Untested. Try at your own risk. By: Terry Wilson (twilson) 2006-11-16 14:25:03.000-0600 [default] exten => 123,1,NoOp(${EXTEN}) exten => 123,n,Macro(test) exten => 123,n,Hangup [macro-test] exten => s,1,NoOp(MACRO_EXTEN is ${MACRO_EXTEN}) exten => s,n,Gosub(sub,s,1) exten => s,n,NoOp(MACRO_EXTEN is now ${MACRO_EXTEN}) [sub] exten => s,1,NoOp(In sub) exten => s,n,Return still results in -- Executing [123@default:1] NoOp("OSS/dsp", "123") in new stack -- Executing [123@default:2] Macro("OSS/dsp", "test") in new stack -- Executing [s@macro-test:1] NoOp("OSS/dsp", "MACRO_EXTEN is 123") in new stack -- Executing [s@macro-test:2] Gosub("OSS/dsp", "sub|s|1") in new stack == Channel 'OSS/dsp' jumping out of macro 'test' -- Executing [s@sub:1] NoOp("OSS/dsp", "In sub") in new stack -- Executing [s@sub:2] Return("OSS/dsp", "") in new stack -- Executing [s@macro-test:3] NoOp("OSS/dsp", "MACRO_EXTEN is now ") in new stack By: Tilghman Lesher (tilghman) 2006-11-16 17:51:49.000-0600 Okay, this patch doesn't solve the problem, entirely, but it will prevent Gosub from returning to the Macro which already exited. By: Tilghman Lesher (tilghman) 2006-11-17 16:24:03.000-0600 Okay, let's try this patch. By: Terry Wilson (twilson) 2006-12-02 10:45:31.000-0600 Sorry, I've been unavailable lately. Should get a chance to try this out on Tuesday. Thanks for your patience. By: Tilghman Lesher (tilghman) 2006-12-31 00:19:42.000-0600 Ping / housekeeping: Have you had a chance to test this yet? By: Tilghman Lesher (tilghman) 2007-02-05 15:49:25.000-0600 twilson: we need you to test this and report back your results. By: Serge Vecher (serge-v) 2007-03-20 14:56:53 ping twilson By: Terry Wilson (twilson) 2007-04-06 16:22:04 Sorry it took me so long to get around to this! I updated the patch for the latest 1.4 SVN and tested and it appears to work. Adding as app_macro_gosub_fix.patch.txt By: Tilghman Lesher (tilghman) 2007-04-08 09:22:59 Fixed in 1.2 at rev 60711, merged to 1.4 in 60713, merged to trunk in 60715. By: Tilghman Lesher (tilghman) 2007-05-31 11:32:13 Still broken for pbx_realtime - see ASTERISK-9530 By: Tilghman Lesher (tilghman) 2007-07-22 09:27:04 Finally, I have a possible fix for pbx_realtime (only for 1.4, this issue will remain broken in 1.2). By: Tilghman Lesher (tilghman) 2007-08-29 14:18:32 Closing due to lack of interest. |