[asterisk-commits] mmichelson: trunk r372138 - in /trunk: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 4 10:50:32 CDT 2012


Author: mmichelson
Date: Tue Sep  4 10:50:30 2012
New Revision: 372138

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372138
Log:
Fix issue where SIP devices were not notified when custom devices changed to "ringing".

The problem had to do with logic used when checking for what the oldest ringing channel
was. The problem was that if no channel was found, then no notification would be sent.
For custom device states, there is no associated channel, so no notification would get
sent. This fixes the issue by still sending the notification even if no associated
channel can be found for a ringing device state change.

(closes issue ASTERISK-20297)
Reported by Noah Engelberth
........

Merged revisions 372137 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=372138&r1=372137&r2=372138
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Sep  4 10:50:30 2012
@@ -15859,22 +15859,22 @@
 		} else if (data->state & AST_EXTENSION_RINGING) {
 			/* check if another channel than last time is ringing now to be notified */
 			struct ast_channel *ringing = find_ringing_channel(data->device_state_info, p);
-			if (!ringing) {
-				/* there's something wrong, the device is ringing but there is no
-				 * ringing channel (yet, chan_sip is strange
-				 * the device is in AST_DEVICE_RINGING but the channel is in AST_STATE_DOWN)
-				 */
-				sip_pvt_unlock(p);
-				return 0;
-			}
-			if (!ast_tvcmp(ast_channel_creationtime(ringing), p->last_ringing_channel_time)) {
-				/* we assume here that no two channels have the exact same creation time */
-				ao2_ref(ringing, -1);
-				sip_pvt_unlock(p);
-				return 0;
-			}
-			p->last_ringing_channel_time = ast_channel_creationtime(ringing);
-			ao2_ref(ringing, -1);
+			if (ringing) {
+				if (!ast_tvcmp(ast_channel_creationtime(ringing), p->last_ringing_channel_time)) {
+					/* we assume here that no two channels have the exact same creation time */
+					ao2_ref(ringing, -1);
+					sip_pvt_unlock(p);
+					return 0;
+				} else {
+					p->last_ringing_channel_time = ast_channel_creationtime(ringing);
+					ao2_ref(ringing, -1);
+				}
+			}
+			/* If no ringing channel was found, it doesn't necessarily indicate anything bad.
+			 * Likely, a device state change occurred for a custom device state, which does not
+			 * correspond to any channel. In such a case, just go ahead and pass the notification
+			 * along.
+			 */
 		}
 		/* ref before unref because the new could be the same as the old one. Don't risk destruction! */
 		if (data->device_state_info) {
@@ -27011,13 +27011,10 @@
 				if (ringing) {
 					p->last_ringing_channel_time = ast_channel_creationtime(ringing);
 					ao2_ref(ringing, -1);
-				} else {
-					/* The device is ringing but there is no ringing channel (chan_sip:
-					 * the device can be AST_DEVICE_RINGING but the channel is AST_STATE_DOWN yet),
-					 * correct state for state_notify_build_xml not to search a ringing channel.
-					 */
-					data.state &= ~AST_EXTENSION_RINGING;
 				}
+				/* If there is no channel, this likely indicates that the ringing indication
+				 * is due to a custom device state. These do not have associated channels.
+				 */
 			}
 			extensionstate_update(p->context, p->exten, &data, p, TRUE);
 			append_history(p, "Subscribestatus", "%s", ast_extension_state2str(data.state));




More information about the asterisk-commits mailing list