[Home]

Summary:ASTERISK-09504: RINGING state not working with call-limit >0
Reporter:Wolfgang Liegel (wliegel)Labels:
Date Opened:2007-05-24 04:45:35Date Closed:2007-07-11 19:59:22
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/Subscriptions
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) devicestate.c.patch
Description:If call-limit is set to any value greater 0 in sip.conf, the devicestate for the called hint is set to "InUse" instead of "Ringing" on incoming calls.

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

I need the ringing indication for successful call-pickup and I need call-limit to be set in order to get a correct value from ${SIPPEER(<peername>:curcalls)}

This issue was introduced with Rev. ASTERISK-6282 in chan_sip.c in function sip_devicestate(void *data) by returning additional information about the device state (AST_DEVICE_NOT_INUSE). In this function any RINGING state is not considered.

This function returns the state to devicestate.c to function ast_device_state(const char *device). If call-limit=0, the return value was AST_DEVICE_UNKNOWN which causes the function to additionally parse the device state in ast_parse_device_state(device). That function also takes care of AST_STATE_RINGING.

To solve this issue I swapped lines 125 and 127:

--- asterisk-1.2.18_old/devicestate.c   2006-02-10 21:38:59.000000000 +0100
+++ asterisk-1.2.18/devicestate.c       2007-05-24 10:38:28.000000000 +0200
@@ -122,9 +122,9 @@
       if (!chan_tech->devicestate)    /* Does the channel driver support device state notification? */
               return ast_parse_device_state(device);  /* No, try the generic function */
       else {
-               res = chan_tech->devicestate(number);   /* Ask the channel driver for device state */
+               res = ast_parse_device_state(device);
               if (res == AST_DEVICE_UNKNOWN) {
-                       res = ast_parse_device_state(device);
+                       res = chan_tech->devicestate(number);   /* Ask the channel driver for device state */
                       /* at this point we know the device exists, but the channel driver
                          could not give us a state; if there is no channel state available,
                          it must be 'not in use'


this tiny patch worked for me. Can you confirm if this patch doesn't create any new problems?
I haven't tested it with clients other than SIP.
Comments:By: Wolfgang Liegel (wliegel) 2007-05-25 04:42:43

I have a little update for this patch. I think it would be better if the generic function is called first to check RINGING state only:


--- ../asterisk-1.2.18_old/devicestate.c        2006-02-10 21:38:59.000000000 +0100
+++ ../asterisk-1.2.18/devicestate.c    2007-05-25 10:18:16.000000000 +0200
@@ -122,6 +122,9 @@
       if (!chan_tech->devicestate)    /* Does the channel driver support device state notification? */
               return ast_parse_device_state(device);  /* No, try the generic function */
       else {
+               res = ast_parse_device_state(device);
+               if (res == AST_DEVICE_RINGING)
+                       return res;
               res = chan_tech->devicestate(number);   /* Ask the channel driver for device state */
               if (res == AST_DEVICE_UNKNOWN) {
                       res = ast_parse_device_state(device);

By: Olle Johansson (oej) 2007-05-29 03:09:49

Ok, we need a disclaimer from you on these patches. Thanks. Always add patches as files, not inline in the bug report. That will make life easier for us developers!

By: Wolfgang Liegel (wliegel) 2007-05-29 03:29:39

sorry, that was my first bug report.
I've added the second patch as a file, because in my opinion it's the better one.

By: Joshua C. Colp (jcolp) 2007-05-29 09:40:45

oej: Since this has been drastically changed in 1.4+ to work right I guess the question we have to ask ourselves is... is this the right fix for 1.2?

By: Wolfgang Liegel (wliegel) 2007-05-29 09:55:36

sure it might be the better solution to merge this with version 1.4 but it wasn't intended to provide the perfect fix, but to have a quick workaround to get the ringing state signaled right.
Do you still want a disclaimer on this file?

By: Olle Johansson (oej) 2007-05-29 10:30:17

I don't think I want to change this in 1.2. What's the status of 1.4 and ringing?

By: Wolfgang Liegel (wliegel) 2007-05-30 01:02:32

in 1.4 ringing is working.
In fact, the behaviour is exactly the other way round. If you set call-limit to 0 you get no ringing and no inuse indication.
I don't know if this is the desired behaviour but if you set call-limit to a high value you can still use other features like SIPPEER(curcalls) which only works if call-limit is set.
In my opinion ringing should be indicated, even if call-limit is set to 0.



By: Wolfgang Liegel (wliegel) 2007-05-30 01:11:36

I need to add that in 1.4 hinting in conjunction with realtime is really unstable.  That's why I'm still using 1.2

By: Olle Johansson (oej) 2007-05-30 02:10:56

Call states where never designed to work with realtime at all. The whole idea with realtime is *not* to keep any states or peers in memory unless forced to.

And yes, almost no call states work without a call limit set. That's how we indicate that you want to get state notifications.

By: Wolfgang Liegel (wliegel) 2007-05-30 02:30:20

I thought, by subscribing to a hint extensions it would be enough indication that I want to get state notifications.
Anyway, in 1.2 call states (except of ringing) work fine with realtime without any crashes.
And according to issue ASTERISK-8560 I think I'm not the only one who'd like to use call states with realtime peers.



By: Olle Johansson (oej) 2007-05-30 04:33:15

Well, I know that people WANT to use it, but that will indeed need a redesign of realtime. Please join the discussion on asterisk-dev for that!

/O

By: Olle Johansson (oej) 2007-05-30 04:34:01

Not an issue in 1.4. Will not backport all the changes to the devicestate subsystem or change 1.2 at this point.

By: Olle Johansson (oej) 2007-05-30 04:34:50

All changes will affect both SIP subscriptions for state changes and queue system and it's a big can of worms to open... I hope you understand. Thanks.