[svn-commits] mmichelson: branch group/CCSS_Monitor_Restructure r244422 - /team/group/CCSS_...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Feb 2 15:23:26 CST 2010


Author: mmichelson
Date: Tue Feb  2 15:23:24 2010
New Revision: 244422

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244422
Log:
Add code to deal with monitor suspension in the case of multiple call legs.

Most of the code previously committed makes the assumption
that when monitoring a SIP endpoint, it is the only one
that was called. However, this is not always the case, and
so smarts have to be built in to know how to handle specific
situations.

This commit deals with the biggest of the offenders, the suspension
and unsuspension routines. There is still a bit more to do here,
I suspect.


Modified:
    team/group/CCSS_Monitor_Restructure/channels/chan_sip.c

Modified: team/group/CCSS_Monitor_Restructure/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/channels/chan_sip.c?view=diff&rev=244422&r1=244421&r2=244422
==============================================================================
--- team/group/CCSS_Monitor_Restructure/channels/chan_sip.c (original)
+++ team/group/CCSS_Monitor_Restructure/channels/chan_sip.c Tue Feb  2 15:23:24 2010
@@ -3774,6 +3774,21 @@
 		publish_type = SIP_PUBLISH_MODIFY;
 	}
 
+	if (ast_strlen_zero(monitor_instance->notify_uri)) {
+		/* If we have no set notify_uri, then what this means is that we have
+		 * not received a NOTIFY from this destination stating that he is
+		 * currently available.
+		 *
+		 * This situation can arise when the core calls the suspend callbacks
+		 * of multiple destinations. If one of the other destinations aside
+		 * from this one notified Asterisk that he is available, then there
+		 * is no reason to take any suspension action on this device. Rather,
+		 * we should return now and if we receive a NOTIFY while monitoring
+		 * is still "suspended" then we can immediately respond with the
+		 * proper PUBLISH to let this endpoint know what is going on.
+		 */
+		return 0;
+	}
 	construct_pidf_body(CC_CLOSED, monitor_instance->suspension_entry->body, sizeof(monitor_instance->suspension_entry->body));
 	transmit_publish(monitor_instance->suspension_entry, publish_type, monitor_instance->notify_uri);
 
@@ -3791,6 +3806,7 @@
 static int sip_cc_monitor_unsuspend(struct ast_cc_monitor *monitor)
 {
 	struct sip_monitor_instance *monitor_instance = monitor->private_data;
+	struct cc_epa_entry *cc_entry;
 
 	if (!monitor_instance) {
 		return -1;
@@ -3798,6 +3814,15 @@
 
 	ast_assert(monitor_instance->suspension_entry != NULL);
 
+	cc_entry = monitor_instance->suspension_entry->instance_data;
+	cc_entry->current_state = CC_OPEN;
+	if (ast_strlen_zero(monitor_instance->notify_uri)) {
+		/* This means we are being asked to unsuspend a call leg we never
+		 * sent a PUBLISH on. As such, there is no reason to send another
+		 * PUBLISH at this point either. We can just return instead.
+		 */
+		return 0;
+	}
 	construct_pidf_body(CC_OPEN, monitor_instance->suspension_entry->body, sizeof(monitor_instance->suspension_entry->body));
 	transmit_publish(monitor_instance->suspension_entry, SIP_PUBLISH_MODIFY, monitor_instance->notify_uri);
 
@@ -21452,6 +21477,7 @@
 	struct sip_monitor_instance *monitor_instance = ao2_callback(sip_monitor_instances, 0,
 			find_sip_monitor_instance_by_subscription_pvt, pvt);
 	const char *status = get_body(req, "cc-state", ':');
+	struct cc_epa_entry *cc_entry;
 	char *uri;
 
 	if (!monitor_instance) {
@@ -21483,7 +21509,17 @@
 	}
 
 	ast_string_field_set(monitor_instance, notify_uri, uri);
-	ast_cc_monitor_callee_available(monitor_instance->core_id);
+	if (monitor_instance->suspension_entry && (cc_entry = monitor_instance->suspension_entry->instance_data) == CC_CLOSED) {
+		/* If we've created a suspension entry and the current state is closed, then that means
+		 * we got a notice from the CC core earlier to suspend monitoring, but because this particular
+		 * call leg had not yet notified us that it was ready for recall, it meant that we
+		 * could not yet send a PUBLISH. Now, however, we can.
+		 */
+		construct_pidf_body(CC_CLOSED, monitor_instance->suspension_entry->body, sizeof(monitor_instance->suspension_entry->body));
+		transmit_publish(monitor_instance->suspension_entry, SIP_PUBLISH_INITIAL, monitor_instance->notify_uri);
+	} else {
+		ast_cc_monitor_callee_available(monitor_instance->core_id);
+	}
 	ao2_ref(monitor_instance, -1);
 	transmit_response(pvt, "200 OK", req);
 




More information about the svn-commits mailing list