[asterisk-commits] mmichelson: branch group/CCSS r251733 - in /team/group/CCSS: channels/ channe...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 10 16:39:05 CST 2010


Author: mmichelson
Date: Wed Mar 10 16:39:01 2010
New Revision: 251733

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=251733
Log:
A couple of bug fixes/improvements.

Bug fixes:

* Make the agent unref the final operation of offer_timer_expire. That way if it happens
  to be that we destroy it there, we don't immediately attempt to reference one of its
  fields afterwards.

* Be sure to set p->lastinvite when we send a SIP_SUBSCRIBE. Otherwise, when we receive
  a NOTIFY, we'll attempt to destroy the pvt. This is not a huge problem since the
  SIP monitor has a reference to the SUBSCRIBE pvt, but this still is not ideal behavior.

* Change the sip_cc_agent_pvt to not keep a reference to the original call. Instead, we
  just make copies of the (very few) portions of the sip_pvt we actually need. This way
  we don't potentially tie up a sip_pvt long after the call is over. Cool.


Modified:
    team/group/CCSS/channels/chan_sip.c
    team/group/CCSS/channels/sip/include/sip.h
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=251733&r1=251732&r2=251733
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Wed Mar 10 16:39:01 2010
@@ -1682,18 +1682,18 @@
 	return agent;
 }
 
-static int find_by_call_pvt_helper(void *obj, void *arg, int flags)
+static int find_by_callid_helper(void *obj, void *arg, int flags)
 {
 	struct ast_cc_agent *agent = obj;
 	struct sip_cc_agent_pvt *agent_pvt = agent->private_data;
 	struct sip_pvt *call_pvt = arg;
 
-	return agent_pvt->original_call == call_pvt ? CMP_MATCH | CMP_STOP : 0;
-}
-
-static struct ast_cc_agent *find_sip_cc_agent_by_call_pvt(struct sip_pvt *pvt)
-{
-	struct ast_cc_agent *agent = ast_cc_agent_callback(0, find_by_call_pvt_helper, pvt, "SIP");
+	return !strcmp(agent_pvt->original_callid, call_pvt->callid) ? CMP_MATCH | CMP_STOP : 0;
+}
+
+static struct ast_cc_agent *find_sip_cc_agent_by_original_callid(struct sip_pvt *pvt)
+{
+	struct ast_cc_agent *agent = ast_cc_agent_callback(0, find_by_callid_helper, pvt, "SIP");
 	return agent;
 }
 
@@ -1708,12 +1708,13 @@
 
 	ast_assert(!strcmp(chan->tech->type, "SIP"));
 
-	agent_pvt->original_call = dialog_ref(call_pvt, "Get reference to original call dialog");
+	ast_copy_string(agent_pvt->original_callid, call_pvt->callid, sizeof(agent_pvt->original_callid));
+	ast_copy_string(agent_pvt->original_exten, call_pvt->exten, sizeof(agent_pvt->original_exten));
 	agent_pvt->offer_timer_id = -1;
 	agent->private_data = agent_pvt;
-	sip_pvt_lock(agent_pvt->original_call);
-	ast_set_flag(&agent_pvt->original_call->flags[0], SIP_OFFER_CC);
-	sip_pvt_unlock(agent_pvt->original_call);
+	sip_pvt_lock(call_pvt);
+	ast_set_flag(&call_pvt->flags[0], SIP_OFFER_CC);
+	sip_pvt_unlock(call_pvt);
 	return 0;
 }
 
@@ -1801,7 +1802,6 @@
 	}
 
 	sip_cc_agent_stop_offer_timer(agent);
-	agent_pvt->original_call = dialog_unref(agent_pvt->original_call, "SIP CC agent destructor: Remove ref to original call");
 	if (agent_pvt->subscribe_pvt) {
 		sip_pvt_lock(agent_pvt->subscribe_pvt);
 		if (!ast_test_flag(&agent_pvt->subscribe_pvt->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED)) {
@@ -10137,7 +10137,7 @@
 {
 	char uri[SIPBUFSIZE];
 	struct ast_str *header = ast_str_alloca(SIPBUFSIZE);
-	struct ast_cc_agent *agent = find_sip_cc_agent_by_call_pvt(p);
+	struct ast_cc_agent *agent = find_sip_cc_agent_by_original_callid(p);
 	struct sip_cc_agent_pvt *agent_pvt;
 
 	if (!agent) {
@@ -10736,7 +10736,7 @@
 
 	if (!p->initreq.headers || init > 2)
 		initialize_initreq(p, &req);
-	if (sipmethod == SIP_INVITE) {
+	if (sipmethod == SIP_INVITE || sipmethod == SIP_SUBSCRIBE) {
 		p->lastinvite = p->ocseq;
 	}
 	return send_request(p, &req, init ? XMIT_CRITICAL : XMIT_RELIABLE, p->ocseq);
@@ -13463,7 +13463,7 @@
 			/* This is a CC recall. We can set p's extension to the exten from
 			 * the original INVITE
 			 */
-			ast_string_field_set(p, exten, agent_pvt->original_call->exten);
+			ast_string_field_set(p, exten, agent_pvt->original_exten);
 			/* And we need to let the CC core know that the caller is attempting
 			 * his recall
 			 */

Modified: team/group/CCSS/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/sip/include/sip.h?view=diff&rev=251733&r1=251732&r2=251733
==============================================================================
--- team/group/CCSS/channels/sip/include/sip.h (original)
+++ team/group/CCSS/channels/sip/include/sip.h Wed Mar 10 16:39:01 2010
@@ -1599,10 +1599,18 @@
 
 struct sip_cc_agent_pvt {
 	int offer_timer_id;
-	/* A reference to the dialog with the caller
-	 * who is failing to reach his intended destination.
-	 */
-	struct sip_pvt *original_call;
+	/* A copy of the original call's Call-ID.
+	 * We use this as a search key when attempting
+	 * to find a particular sip_pvt.
+	 */
+	char original_callid[SIPBUFSIZE];
+	/* A copy of the exten called originally.
+	 * We use this to set the proper extension
+	 * to dial during the recall since the incoming
+	 * request URI is one that was generated just
+	 * for the recall
+	 */
+	char original_exten[SIPBUFSIZE];
 	/* A reference to the dialog which we will
 	 * be sending a NOTIFY on when it comes time
 	 * to send one

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=251733&r1=251732&r2=251733
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Mar 10 16:39:01 2010
@@ -2314,8 +2314,8 @@
 	ast_log_dynamic_level(cc_logger_level, "Core %d: Queuing change request because offer timer has expired.\n",
 			agent->core_id);
 	agent_pvt->offer_timer_id = -1;
+	ast_cc_failed(agent->core_id, "Generic agent %s offer timer expired", agent->device_name);
 	cc_unref((struct ast_cc_agent *)agent, "Remove scheduler's reference to the agent");
-	ast_cc_failed(agent->core_id, "Generic agent %s offer timer expired", agent->device_name);
 	return 0;
 }
 




More information about the asterisk-commits mailing list