[Home]

Summary:ASTERISK-09698: Timelimit for options L and S is set to the inbound channel not the outbound
Reporter:Gaspar Zoltan (gasparz)Labels:
Date Opened:2007-06-18 03:24:58Date Closed:2007-06-20 14:30:04
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Applications/app_dial
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Hi,

When using options S or L in the Dial application and the call limit times out no other messages can be played back to the caller.

This is because the inbound channel is no longer up. This functionnality is wrong because:
- An application that creates a channel should not close the inbound channel, it should only set channel variables and give back the control to the dialplan
- the dialplan can not control the callflow in this case.

I think this bug can be reproduced in the 1.4 branch to.

How to reproduce:

exten => 10,1,Answer
exten => 10,2,SayDigits(1234)
exten => 10,3,Dial(SIP/number@provider,,S(20))
exten => 10,4,SayDigits(4321)
exten => 10,5,Hangup

Just let the 20 seconds to pass and you won't hear the 4321 played back.

I put the debug option on and I saw:

Jun 18 03:22:12 DEBUG[25838]: channel.c:3584 ast_channel_bridge: Bridge stops because we're zombie or need a soft hangup: c0=SIP/45e2b8014cddb47a9cfd3cf34d3d6db4-0a05b9d0, c1=SIP/204.8.108.55-0a067e78, flags: No,Yes,No,No

Jun 18 03:22:12 DEBUG[25838]: channel.c:3675 ast_channel_bridge: Bridge stops bridging channels SIP/45e2b8014cddb47a9cfd3cf34d3d6db4-0a05b9d0 and SIP/204.8.108.55-0a067e78
Jun 18 03:22:12 DEBUG[25838]: chan_sip.c:2448 sip_hangup: update_call_counter(--number--) - decrement call limit counter
Jun 18 03:22:12 DEBUG[25838]: app_dial.c:1644 dial_exec_full: Exiting with DIALSTATUS=ANSWER.
Jun 18 03:22:12 DEBUG[25809]: res_config_mysql.c:674 mysql_reconnect: MySQL RealTime: Everything is fine.
Jun 18 03:22:12 DEBUG[25809]: res_config_mysql.c:141 realtime_mysql: MySQL RealTime: Retrieve SQL: SELECT * FROM sip WHERE name = '204.8.108.55'
Jun 18 03:22:12 WARNING[25838]: file.c:587 ast_readaudio_callback: Failed to write frame
   -- Playing 'digits/4' (language 'en')

Let's analyse it a little bit:
Jun 18 03:22:12 DEBUG[25838]: channel.c:3584 ast_channel_bridge: Bridge stops because we're zombie or need a soft hangup: c0=SIP/45e2b8014cddb47a9cfd3cf34d3d6db4-0a05b9d0, c1=SIP/204.8.108.55-0a067e78, flags: No,Yes,No,No

The code is: (channel.c)
ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
03591             c0->name, c1->name,
03592             ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
03593             ast_check_hangup(c0) ? "Yes" : "No",
03594             ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
03595             ast_check_hangup(c1) ? "Yes" : "No");

so channel 0 is not zombie
channel 0 needs to hang up
channel 1 is not zombie
channel 1 doesn't needs to hang up

I would expect the channel 0 not needing hang up and channel 1 needing the hangup. I wanted to set the timelimit for the outbound channel not the inbound, for the imbound channel timeout I would use AbsoluteTimeout.

Looking a little further I found in app_dial.c:

01573          if (calldurationlimit > 0) {
01574             time_t now;
01575
01576             time(&now);
01577             chan->whentohangup = now + calldurationlimit;
01578          }

This means that there is a timeout event set on the inbound channel (line 01577). This should not happen. The time limit should be set on the outbound channel:

this timeout should be set on:
01233    peer = wait_for_answer(chan, outgoing, &to, peerflags, &sentringing, status, sizeof(status), numbusy, numnochan, numcongestion, ast_test_flag(&opts, OPT_PRIORITY_JUMP), &result);
01234    

The peer channel created in the line above. Adding the timeout to the outbound channel and not the inbound one would fix this issue.

Thanks
Comments:By: Gaspar Zoltan (gasparz) 2007-06-20 04:12:59

I modified a line:
01577 chan->whentohangup = now + calldurationlimit;

to

peer->whentohangup = now + calldurationlimit;

It passed the test and now it's working correctly.

Patch 68070 is outdated by this fix so it can be removed.

By: Sergey Tamkovich (sergee) 2007-06-20 04:40:26

i think this is very good improvement to L()'s logic. With this change we can process call after dial, playing some messages or promting user to input something.

By: Tilghman Lesher (tilghman) 2007-06-20 14:30:04

Fixed in 70444, merged in 70445, 70446.