[asterisk-commits] russell: branch russell/chan_refcount r82963 - /team/russell/chan_refcount/ch...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 18 19:03:08 CDT 2007


Author: russell
Date: Tue Sep 18 19:03:07 2007
New Revision: 82963

URL: http://svn.digium.com/view/asterisk?view=rev&rev=82963
Log:
handle most of the channel references in chan_sip ... there is still more to do
as it gets tricky in the SIP REFER handling

Modified:
    team/russell/chan_refcount/channels/chan_sip.c

Modified: team/russell/chan_refcount/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/channels/chan_sip.c?view=diff&rev=82963&r1=82962&r2=82963
==============================================================================
--- team/russell/chan_refcount/channels/chan_sip.c (original)
+++ team/russell/chan_refcount/channels/chan_sip.c Tue Sep 18 19:03:07 2007
@@ -3666,6 +3666,7 @@
 		p->owner->tech_pvt = NULL;
 		if (lockowner)
 			ast_channel_unlock(p->owner);
+		p->owner = ast_channel_unref(p->owner);
 	}
 	/* Clear history */
 	if (p->history) {
@@ -4034,7 +4035,7 @@
 		ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);	/* Really hang up next time */
 		p->needdestroy = 0;
 		p->owner->tech_pvt = dialog_unref(p->owner->tech_pvt);
-		p->owner = NULL;  /* Owner will be gone after we return, so take it away */
+		p->owner = ast_channel_unref(p->owner);
 		return 0;
 	}
 
@@ -4074,7 +4075,7 @@
 	if (p->vad)
 		ast_dsp_free(p->vad);
 
-	p->owner = NULL;
+	p->owner = ast_channel_unref(p->owner);
 	ast->tech_pvt = dialog_unref(ast->tech_pvt);
 
 	ast_module_unref(ast_module_info->self);
@@ -4334,7 +4335,8 @@
 	if (p->owner != oldchan)
 		ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
 	else {
-		p->owner = newchan;
+		ast_channel_unref(oldchan);
+		p->owner = ast_channel_ref(newchan);
 		ret = 0;
 	}
 	ast_debug(3, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
@@ -4633,7 +4635,7 @@
 		tmp->amaflags = i->amaflags;
 	if (!ast_strlen_zero(i->language))
 		ast_string_field_set(tmp, language, i->language);
-	i->owner = tmp;
+	i->owner = ast_channel_ref(tmp);
 	ast_module_ref(ast_module_info->self);
 	ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
 	ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
@@ -7745,7 +7747,7 @@
 	add_header(&req, "Allow", ALLOWED_METHODS);
 	add_header(&req, "Supported", SUPPORTED_EXTENSIONS);
 	if (p->options && p->options->addsipheaders && p->owner) {
-		struct ast_channel *ast = p->owner; /* The owner channel */
+		struct ast_channel *ast = ast_channel_ref(p->owner); /* The owner channel */
 		struct varshead *headp = &ast->varshead;
 
 			if (!headp)
@@ -7777,6 +7779,8 @@
 					}
 				}
 			}
+
+		ast_channel_unref(ast);
 	}
 	if (sdp) {
 		if (p->udptl && p->t38.state == T38_LOCAL_DIRECT) {
@@ -13638,7 +13642,7 @@
 		msg++;
 	sipmethod = find_sip_method(msg);
 
-	owner = p->owner;
+	owner = p->owner ? ast_channel_ref(p->owner) : NULL;
 	if (owner) 
 		owner->hangupcause = hangup_sip2cause(resp);
 
@@ -13999,6 +14003,9 @@
 			break;
 		}
 	}
+
+	if (owner)
+		ast_channel_unref(owner);
 }
 
 
@@ -14447,6 +14454,8 @@
 	struct ast_channel *targetcall;		/* The bridge to the take-over target */
 
 	struct ast_channel *test;
+
+	/* XXX CHAN_REFCOUNT_TODO handle channel references in this function and the rest of the module down from here */
 
 	/* Check if we're in ring state */
 	if (replacecall->_state == AST_STATE_RING)




More information about the asterisk-commits mailing list