[asterisk-commits] mmichelson: branch group/CCSS_Monitor_Restructure r244396 - /team/group/CCSS_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 2 14:40:58 CST 2010


Author: mmichelson
Date: Tue Feb  2 14:40:56 2010
New Revision: 244396

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244396
Log:
Add some missing code regarding CC EPA entries.

First, I never set the instance_data field of the call_completion
EPA entry when I allocated it, so I needed to do that. This allowed
me to not segfault when an error occurred.

Next, I added a destructor callback to EPA entry static_data
members. This way, the destructor is called properly when
the EPA entry is destroyed.

There is still a bit of murkiness to clean up with regards
to multiple endpoints being dialed, but things appear to work
wonderfully when dialing a single endpoint.

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=244396&r1=244395&r2=244396
==============================================================================
--- team/group/CCSS_Monitor_Restructure/channels/chan_sip.c (original)
+++ team/group/CCSS_Monitor_Restructure/channels/chan_sip.c Tue Feb  2 14:40:56 2010
@@ -1805,6 +1805,7 @@
 	const char *name;
 	void (*handle_ok)(struct sip_pvt *, struct sip_request *, struct sip_epa_entry *);
 	void (*handle_error)(struct sip_pvt *, const int resp, struct sip_request *, struct sip_epa_entry *);
+	void (*destructor)(void *instance_data);
 };
 
 struct epa_backend {
@@ -1831,10 +1832,17 @@
 
 static void cc_handle_publish_error(struct sip_pvt *pvt, const int resp, struct sip_request *req, struct sip_epa_entry *epa_entry);
 
+static void cc_epa_destructor(void *instance_data)
+{
+	struct cc_epa_entry *cc_entry = instance_data;
+	ast_free(cc_entry);
+}
+
 static const struct epa_static_data cc_epa_static_data  = {
 	.event = CALL_COMPLETION,
 	.name = "call-completion",
 	.handle_error = cc_handle_publish_error,
+	.destructor = cc_epa_destructor,
 };
 
 struct sip_epa_entry {
@@ -1889,12 +1897,11 @@
 	struct sip_epa_entry *epa_entry;
 	const struct epa_static_data *static_data;
 
-	if (!(epa_entry = ao2_alloc(sizeof(*epa_entry), NULL))) {
+	if (!(static_data = find_static_data(event_package))) {
 		return NULL;
 	}
 
-	if (!(static_data = find_static_data(event_package))) {
-		ao2_ref(epa_entry, -1);
+	if (!(epa_entry = ao2_alloc(sizeof(*epa_entry), static_data->destructor))) {
 		return NULL;
 	}
 
@@ -3741,6 +3748,7 @@
 {
 	struct sip_monitor_instance *monitor_instance = monitor->private_data;
 	enum sip_publish_type publish_type;
+	struct cc_epa_entry *cc_entry;
 
 	if (!monitor_instance) {
 		return -1;
@@ -3753,6 +3761,14 @@
 			ao2_ref(monitor_instance, -1);
 			return -1;
 		}
+		if (!(cc_entry = ast_calloc(1, sizeof(*cc_entry)))) {
+			ast_log(LOG_WARNING, "Unable to allocate space for instance data of EPA entry for call-completion\n");
+			ao2_ref(monitor_instance, -1);
+			return -1;
+		}
+		cc_entry->core_id = monitor->core_id;
+		cc_entry->current_state = CC_CLOSED;
+		monitor_instance->suspension_entry->instance_data = cc_entry;
 		publish_type = SIP_PUBLISH_INITIAL;
 	} else {
 		publish_type = SIP_PUBLISH_MODIFY;
@@ -19872,6 +19888,7 @@
 		if ((p->authtries == MAX_AUTHTRIES) || do_proxy_auth(p, req, resp, SIP_PUBLISH, 0)) {
 			ast_log(LOG_NOTICE, "Failed to authenticate on PUBLISH to '%s'\n", get_header(&p->initreq, "From"));
 		}
+		return;
 	}
 
 	if (resp == 501 || resp == 405) {




More information about the asterisk-commits mailing list