[asterisk-commits] rizzo: branch rizzo/astobj2 r77633 - /team/rizzo/astobj2/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jul 28 04:51:43 CDT 2007


Author: rizzo
Date: Sat Jul 28 04:51:42 2007
New Revision: 77633

URL: http://svn.digium.com/view/asterisk?view=rev&rev=77633
Log:
rename the dialog _ref/_unref functions

Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=77633&r1=77632&r2=77633
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Sat Jul 28 04:51:42 2007
@@ -1191,13 +1191,13 @@
  * when we create or delete references, make sure to use these
  * functions so we keep track of the refcounts.
  */
-static struct sip_pvt *pvt_ref(struct sip_pvt *p)
+static struct sip_pvt *dialog_ref(struct sip_pvt *p)
 {
 	ao2_ref(p, 1);
 	return p;
 }
 
-static struct sip_pvt *pvt_unref(struct sip_pvt *p)
+static struct sip_pvt *dialog_unref(struct sip_pvt *p)
 {
 	ao2_ref(p, -1);
 	return NULL;
@@ -2411,7 +2411,7 @@
 	for (prev = NULL, cur = pvt->packets; cur; prev = cur, cur = cur->next) {
 		if (cur == pkt) {
 			UNLINK(cur, pvt->packets, prev);
-			pkt->owner = pvt_unref(pvt);	/* release the reference to the dialog */
+			pkt->owner = dialog_unref(pvt);	/* release the reference to the dialog */
 			sip_pvt_unlock(pvt);
 			ast_free(pkt);
 			return 0;
@@ -2437,7 +2437,7 @@
 	pkt->data[len] = '\0';
 	pkt->packetlen = len;
 	pkt->method = sipmethod;
-	pkt->owner = pvt_ref(p);
+	pkt->owner = dialog_ref(p);
 	pkt->seqno = seqno;
 	pkt->is_resp = resp;	/* mark as response */
 	if (mode == XMIT_CRITICAL)
@@ -2495,7 +2495,7 @@
 		transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
 		append_history(p, "ReferBYE", "Sending BYE on transferer call leg %s", p->callid);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
-		pvt_unref(p);
+		dialog_unref(p);
 	} else {
 		append_history(p, "AutoDestroy", "%s", p->callid);
 		ast_debug(3, "Auto destroying SIP dialog '%s'\n", p->callid);
@@ -2521,7 +2521,7 @@
 	if (p->autokillid > -1)	/* cancel previous schedule, but keep the reference */
 		ast_sched_del(sched, p->autokillid);
 	else
-		pvt_ref(p);	/* create a new reference */
+		dialog_ref(p);	/* create a new reference */
 	p->autokillid = ast_sched_add(sched, ms, __sip_autodestruct, p);
 }
 
@@ -2532,7 +2532,7 @@
 		ast_sched_del(sched, p->autokillid);
 		append_history(p, "CancelDestroy", "");
 		p->autokillid = -1;
-		pvt_unref(p);
+		dialog_unref(p);
 	}
 }
 
@@ -2568,7 +2568,7 @@
 				cur->retransid = -1;
 			}
 			UNLINK(cur, p->packets, prev);
-			pvt_unref(cur->owner);
+			dialog_unref(cur->owner);
 			ast_free(cur);
 			break;
 		}
@@ -3495,7 +3495,7 @@
 		p->invitestate = INV_CALLING;
 
 		/* Initialize auto-congest time */
-		p->initid = ast_sched_add(sched, SIP_TRANS_TIMEOUT, auto_congest, pvt_ref(p));
+		p->initid = ast_sched_add(sched, SIP_TRANS_TIMEOUT, auto_congest, dialog_ref(p));
 	}
 
 	return res;
@@ -3542,7 +3542,7 @@
 
 	/* Remove link from peer to subscription of MWI */
 	if (p->relatedpeer && p->relatedpeer->mwipvt) /* XXX sip_destroy ? */
-		p->relatedpeer->mwipvt = pvt_unref(p->relatedpeer->mwipvt);
+		p->relatedpeer->mwipvt = dialog_unref(p->relatedpeer->mwipvt);
 
 	if (dumphistory)
 		sip_dump_history(p);
@@ -3555,12 +3555,12 @@
 	if (p->initid > -1) {
 		ast_verbose("XXX very strange, pvt_destructor has initid != 0 %p\n", p);
 		ast_sched_del(sched, p->initid);
-		pvt_unref(p);
+		dialog_unref(p);
 	}
 	if (p->autokillid > -1) {
 		ast_verbose("XXX very strange, pvt_destructor has autokillid != 0 %p\n", p);
 		ast_sched_del(sched, p->autokillid);
-		pvt_unref(p);
+		dialog_unref(p);
 	}
 
 	if (p->rtp)
@@ -3610,7 +3610,7 @@
 		p->packets = p->packets->next;
 		if (cp->retransid > -1)
 			ast_sched_del(sched, cp->retransid);
-		pvt_unref(cp->owner);
+		dialog_unref(cp->owner);
 		ast_free(cp);
 	}
 	if (p->registry) {
@@ -3619,7 +3619,7 @@
 		 * would not be called in astobj2
 		 */
 		if (p->registry->register_pvt == p)
-			p->registry->register_pvt = pvt_unref(p->registry->register_pvt);
+			p->registry->register_pvt = dialog_unref(p->registry->register_pvt);
 		p->registry = registry_unref(p->registry);
 	}
 
@@ -3629,7 +3629,7 @@
 			p, p->owner->tech_pvt);
 		ast_channel_lock(p->owner);
 		ast_debug(1, "Detaching from %s\n", p->owner->name);
-		p->owner->tech_pvt = pvt_unref(p->owner->tech_pvt);	/* self pointer, basically */
+		p->owner->tech_pvt = dialog_unref(p->owner->tech_pvt);	/* self pointer, basically */
 		ast_channel_unlock(p->owner);
 	}
 #ifdef USE_AO2
@@ -3641,9 +3641,9 @@
 		// *(char *)0 = 1;/* crash */
 	}
 }
-	pvt_unref(p);	/* automatically calls pvt_destructor on ao2*/
+	dialog_unref(p);	/* automatically calls pvt_destructor on ao2*/
 #else
-	pvt_unref(p);	/* automatically calls pvt_destructor on ao2*/
+	dialog_unref(p);	/* automatically calls pvt_destructor on ao2*/
 	ast_mutex_destroy(&p->pvt_lock);	/* XXX not used in ao2 */
 	pvt_destructor(p);
 	ast_free(p);
@@ -3960,7 +3960,7 @@
 		p->needdestroy = 0;
 		/* XXX assert(p->owner == ast); */
 		if (p->owner->tech_pvt)	/* i believe that's always */
-			p->owner->tech_pvt = pvt_unref(p->owner->tech_pvt);
+			p->owner->tech_pvt = dialog_unref(p->owner->tech_pvt);
 		p->owner = NULL;  /* Owner will be gone after we return, so take it away */
 		return 0;
 	}
@@ -3998,7 +3998,7 @@
 
 	p->owner = NULL;
 	if (ast->tech_pvt)
-		ast->tech_pvt = pvt_unref(ast->tech_pvt);
+		ast->tech_pvt = dialog_unref(ast->tech_pvt);
 
 	ast_module_unref(ast_module_info->self);
 	/* Do not destroy this pvt until we have timeout or
@@ -4545,7 +4545,7 @@
 	tmp->rawwriteformat = fmt;
 	tmp->readformat = fmt;
 	tmp->rawreadformat = fmt;
-	tmp->tech_pvt = pvt_ref(i);
+	tmp->tech_pvt = dialog_ref(i);
 
 	tmp->callgroup = i->callgroup;
 	tmp->pickupgroup = i->pickupgroup;
@@ -5044,7 +5044,7 @@
 	}
 	ast_string_field_set(p, context, default_context);
 
-	pvt_ref(p);	/* prepare to return a reference */
+	dialog_ref(p);	/* prepare to return a reference */
 	/* Add to active dialog list */
 #ifdef USE_AO2
 	ao2_link(dialogs, p);
@@ -8093,7 +8093,7 @@
 	if (r->register_pvt) {
 		ast_log(LOG_WARNING, "-- sip_reregister should not have a pvt %p (%s@%s)\n",
 			r->register_pvt, r->username, r->hostname);
-		r->register_pvt = pvt_unref(r->register_pvt);
+		r->register_pvt = dialog_unref(r->register_pvt);
 	}
 
 	/* Since registry's are only added/removed by the the monitor thread, this
@@ -8136,7 +8136,7 @@
 		/* decouple the two objects */
 		if (p->registry)
 			p->registry = registry_unref(p->registry);
-		r->register_pvt = pvt_unref(r->register_pvt);	/* reference goes away */
+		r->register_pvt = dialog_unref(r->register_pvt);	/* reference goes away */
 	}
 
 	/* If we have a limit, stop registration and give up */
@@ -8185,7 +8185,7 @@
 			ast_log(LOG_WARNING, "Already have a REGISTER going on to %s@%s?? \n", r->username, r->hostname);
 			return 0;
 		} else {
-			p = pvt_ref(r->register_pvt);	/* grab a reference */
+			p = dialog_ref(r->register_pvt);	/* grab a reference */
 			make_our_tag(p->tag, sizeof(p->tag));	/* create a new local tag for every register attempt */
 			ast_string_field_free(p, theirtag);	/* forget their old tag, so we don't match tags when getting response */
 		}
@@ -8220,7 +8220,7 @@
 		else 	/* Set registry port to the port set from the peer definition/srv or default */
 			r->portno = ntohs(p->sa.sin_port);
 		ast_set_flag(&p->flags[0], SIP_OUTGOING);	/* Registration is outgoing call */
-		r->register_pvt = pvt_ref(p);			/* Save pointer to SIP dialog */
+		r->register_pvt = dialog_ref(p);			/* Save pointer to SIP dialog */
 		p->registry = registry_addref(r);	/* Add pointer to registry in dialog */
 		if (!ast_strlen_zero(r->secret))	/* Secret (password) */
 			ast_string_field_set(p, secret, r->secret);
@@ -8353,7 +8353,7 @@
 			regstate2str(auth ? REG_STATE_AUTHSENT : REG_STATE_REGSENT) );
 	r->regstate = auth ? REG_STATE_AUTHSENT : REG_STATE_REGSENT;
 	ret = send_request(p, &req, XMIT_CRITICAL, p->ocseq);
-	pvt_unref(p);
+	dialog_unref(p);
 	return ret;
 }
 
@@ -8379,7 +8379,7 @@
 	if (!p->refer)
 		return;
 	if (p->refer->refer_call)
-		p->refer->refer_call = pvt_unref(p->refer->refer_call);
+		p->refer->refer_call = dialog_unref(p->refer->refer_call);
 	ast_free(p->refer);
 	p->refer = NULL;
 }
@@ -9901,7 +9901,7 @@
 		ast_copy_string(referdata->referred_by, "", sizeof(referdata->referred_by));
 		ast_copy_string(referdata->refer_contact, "", sizeof(referdata->refer_contact));
 		if (referdata->refer_call)
-			referdata->refer_call = pvt_unref(referdata->refer_call);
+			referdata->refer_call = dialog_unref(referdata->refer_call);
 		/* Set new context */
 		ast_string_field_set(p, context, transfer_context);
 		return 0;
@@ -12426,7 +12426,7 @@
 		ast_cli(fd, "Sending NOTIFY of type '%s' to '%s'\n", argv[2], argv[i]);
 		transmit_sip_request(p, &req);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
-		pvt_unref(p);
+		dialog_unref(p);
 	}
 
 	return RESULT_SUCCESS;
@@ -13045,7 +13045,7 @@
 		/* Don't auto congest anymore since we've gotten something useful back */
 		ast_sched_del(sched, p->initid);
 		p->initid = -1;
-		pvt_unref(p);
+		dialog_unref(p);
 	}
 
 	/* RFC3261 says we must treat every 1xx response (but not 100)
@@ -13379,7 +13379,7 @@
 {
 	struct sip_registry *r = p->registry;
 
-	r->register_pvt = pvt_unref(r->register_pvt);
+	r->register_pvt = dialog_unref(r->register_pvt);
 	p->registry = registry_unref(r);
 	p->needdestroy = 1;
 }
@@ -13581,7 +13581,7 @@
 	peer->lastms = pingtime;
 	/* XXX do we need to unlink too ? */
 	if (peer->call)
-		peer->call = pvt_unref(peer->call);
+		peer->call = dialog_unref(peer->call);
 	if (statechanged) {
 		const char *s = is_reachable ? "Reachable" : "Lagged";
 
@@ -14589,7 +14589,7 @@
 	 * And why do we reset it before calling hangup ?
 	 */
 	if (c->tech_pvt)
-		c->tech_pvt = pvt_unref(c->tech_pvt);
+		c->tech_pvt = dialog_unref(c->tech_pvt);
 	ast_hangup(c);
 	return 0;
 }
@@ -14717,7 +14717,7 @@
 		if (p->refer->refer_call) {
 			ast_log(LOG_DEBUG, "-- note, refer_call %p for %p is going to be replaced\n",
 				p->refer->refer_call, p);
-			p->refer->refer_call = pvt_unref(p->refer->refer_call);
+			p->refer->refer_call = dialog_unref(p->refer->refer_call);
 		}
 		if ((p->refer->refer_call = get_sip_pvt_byid_locked(replace_id, totag, fromtag)) == NULL) {
 			ast_log(LOG_NOTICE, "Supervised transfer attempted to replace non-existent call id (%s)!\n", replace_id);
@@ -14733,7 +14733,7 @@
 
 		if (p->refer->refer_call == p) {
 			ast_log(LOG_NOTICE, "INVITE with replaces into it's own call id (%s == %s)!\n", replace_id, p->callid);
-			p->refer->refer_call = pvt_unref(p->refer->refer_call);
+			p->refer->refer_call = dialog_unref(p->refer->refer_call);
 			transmit_response(p, "400 Bad request", req);	/* The best way to not not accept the transfer */
 			error = 1;
 		}
@@ -15199,7 +15199,7 @@
 			ast_channel_unlock(targetcall_pvt->owner);
 		}
 	}
-	pvt_unref(targetcall_pvt);
+	dialog_unref(targetcall_pvt);
 	return 1;
 }
 
@@ -15913,9 +15913,9 @@
 			if (authpeer->mwipvt != p)	/* Destroy old PVT if this is a new one */
 				sip_destroy(authpeer->mwipvt);
 			else
-				pvt_unref(authpeer->mwipvt);
-		}
-		authpeer->mwipvt = pvt_ref(p);		/* Link from peer to pvt */
+				dialog_unref(authpeer->mwipvt);
+		}
+		authpeer->mwipvt = dialog_ref(p);		/* Link from peer to pvt */
 		p->relatedpeer = authpeer;	/* Link from pvt to peer */
 		/* Do not release authpeer here */
 	} else { /* At this point, Asterisk does not understand the specified event */
@@ -16409,7 +16409,7 @@
 		ast_verbose("loop %d p %p chan %p trylock failed\n", lockretry, p, p->owner);
 		ast_debug(1, "Failed to grab owner channel lock, trying again. (SIP call %s)\n", p->callid);
 		sip_pvt_unlock(p);
-		p = pvt_unref(p);	/* release the reference, no good anymore */
+		p = dialog_unref(p);	/* release the reference, no good anymore */
 		/* Sleep for a very short amount of time */
 		usleep(1);
 	}
@@ -16436,7 +16436,7 @@
 	if (p->owner && !nounlock)
 		ast_channel_unlock(p->owner);
 	sip_pvt_unlock(p);
-	pvt_unref(p);
+	dialog_unref(p);
 	if (recount)
 		ast_update_use_count();
 
@@ -16479,7 +16479,7 @@
 
 	if (peer->mwipvt) {
 		/* Base message on subscription */
-		p = pvt_ref(peer->mwipvt);
+		p = dialog_ref(peer->mwipvt);
 	} else {
 		/* Build temporary dialog for this message */
 		if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY))) 
@@ -16500,7 +16500,7 @@
 	/* Send MWI */
 	ast_set_flag(&p->flags[0], SIP_OUTGOING);
 	transmit_notify_with_mwi(p, newmsgs, oldmsgs, peer->vmexten);
-	pvt_unref(p);
+	dialog_unref(p);
 	return 0;
 }
 
@@ -16954,7 +16954,7 @@
 	if (!tmpc)
 		sip_destroy(p);
 	else
-		pvt_unref(p);
+		dialog_unref(p);
 	ast_update_use_count();
 	restart_monitor();
 	return tmpc;




More information about the asterisk-commits mailing list