Summary:ASTERISK-02935: app_dial DIALSTATUS is always CHANUNAVAIL when not answered
Reporter:Andrew Kohlsmith (akohlsmith)Labels:
Date Opened:2004-12-07 10:28:41.000-0600Date Closed:2008-01-15 15:16:28.000-0600
Versions:Frequency of
Environment:Attachments:( 0) app_dial-1.111.diff
( 1) app_dial-1[1].111.diff.txt
Description:A little bug in the HANDLE_CAUSE macro causes DIALSTATUS to always be set to CHANUNAVAIL when a call is not answered.  I blame the "cute" macro variable use.


Patch attached which "fixes" the cute variable use, fixes the bug and makes the "everyone is busy/congested" message a little more informative by showing the line count and busy/congested/unavail counts.
Comments:By: Andrew Kohlsmith (akohlsmith) 2004-12-07 10:55:04.000-0600

Faxed disclaimer and dropped hardcopy into outgoing mail box.

By: Kevin P. Fleming (kpfleming) 2004-12-07 11:43:42.000-0600

I don't see that your patch actually changes any logic, only variable names and the console warning message. Can you explain what the actual bug was? I'd like to test this patch on my system, if I can understand what it's doing...

edited on: 12-07-04 11:43

By: Andrew Kohlsmith (akohlsmith) 2004-12-07 22:11:00.000-0600

The bug was this:

#define HANDLE_CAUSE(blah, bleh) do { \
 switch(cause) { \

(note that the switch uses 'cause' not 'blah' -- I changed the macro variables to names that actually meant something, which also fixed the bug since I renamed 'blah' to 'cause'.

What was happening in the macro was that the switch(cause) statement was looking at the wrong variable most of the time.  'cause' was not a macro variable; bleh was what you want to run the switch() against.  Since 'cause' was not a macro variable the compiler would run switch() against the function (not macro) variable named 'cause' which was almost never what was desired.  This caused (heh) the default case of the switch to be executed for everything except an "ANSWER" cause.

So, what the patch does:
- renames 'blah' to 'cause'
- renames 'bleh' to 'chan'
 (these changes allow the macro to work as intended)
- add "line:busy/congested/unavailable" counts to the output of a couple of messages to better aid in debugging of the dialplan and/or routing

edited on: 12-07-04 22:24

By: Kevin P. Fleming (kpfleming) 2004-12-07 23:07:35.000-0600

I see... so the macro was incorrectly relying on a "cause" variable that happened to be in scope where it was used. Yeah, I can see how that would have been unclear. Thanks for the explanation :-)

By: Andrew Kohlsmith (akohlsmith) 2004-12-09 21:03:50.000-0600

Is there anything holding up this patch from being committed?  It seems straightforward enough but this is my first patch to asterisk so I'm not sure if I'm missing something or not.

By: Mark Spencer (markster) 2004-12-12 00:01:06.000-0600

Fixed in CVS

By: Russell Bryant (russell) 2004-12-19 08:17:57.000-0600

macro not present in 1.0

By: Digium Subversion (svnbot) 2008-01-15 15:16:28.000-0600

Repository: asterisk
Revision: 4438

U   trunk/apps/app_dial.c

r4438 | markster | 2008-01-15 15:16:27 -0600 (Tue, 15 Jan 2008) | 2 lines

fix DIALSTATUS issue (bug ASTERISK-2935)