Propagating extension h

For some reason, I’ve had to create a specific context for dialing - When I need to dial, I call this context (via Goto) - And I want the h of the initial context to be called upon hangup, not of this second context

exten => _X.,1,Noop( some stuff...)
same => n,Goto(dial,${EXTEN},1)

exten => h,1,Noop( the actual hangup stuff....)

exten => _X.,Dial(SIP/provider/${EXTEN})
exten => h,1,Noop(Nothing to do here, need to execute h of calling context)

How can I propagate the hangup to the initial context ? I’ve used the hangup handler, but I get ‘Abnormal ‘Gosub(mycontet,h,1)’ exit. Popping routine return locations.’ - that is just a notice, but I am not keen on seeing ‘Abnormal’ stuff on the CLI, and I thought I had seen a much simpler way to achieve this.

Thanks for the help

Hangup handler should work for you or why just dont copy the code of the h extension of my [mycontext] to [dial] context , other way would be add a goto() on the dial context that send you to h extension of my context [mycontext] , I havent test it such mode but it should work also

Pre-dial and hangup handlers are subroutines. They are invoked internally by the Gosub application. You must always Return from them or you get the ‘abnormal stuff’ messages.

exten = s,1,NoOp(Do stuff in subroutine)
same = n,Return()

exten = _X.,1,NoOp(My extension handling code)
same = n,Gosub(myroutine,s,1)
same = n,Set(CHANNEL(hangup_handler_push)=myroutine,s,1)
same = n,Dial(PJSIP/101,b(myroutine^s^1))
same = n,Hangup()

It is a best practice to end dialplan extension handling with a Hangup. You could get unexpected behavior because execution can fall off the end of your extension handling code and execute dialplan in the middle of another matching extension.



@rmudgett : thanks, with the Return statement, the notice no longer appears
@ambiorixg12 : thanks as well - the [dial] context is called from different places that do different things upon hangup.

Funny, I was convinced I’d seen somewhere a trick to trigger the h of the original context - I must be mistaken !