[svn-commits] rizzo: branch rizzo/astobj2 r47858 - /team/rizzo/astobj2/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Nov 20 11:30:33 MST 2006


Author: rizzo
Date: Mon Nov 20 12:30:33 2006
New Revision: 47858

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47858
Log:
misc merges from trunk, and changes of sip_destroy to pvt_unref
where necessary.


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=47858&r1=47857&r2=47858
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Mon Nov 20 12:30:33 2006
@@ -2203,6 +2203,7 @@
 				if (sipdebug && option_debug > 3)
 					ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
 				ast_sched_del(sched, cur->retransid);
+				cur->retransid = -1;
 			}
 			UNLINK(cur, p->packets, prev);
 			cur->pvt = pvt_unref(cur->pvt);
@@ -2248,8 +2249,8 @@
 				if (option_debug > 3 && sipdebug)
 					ast_log(LOG_DEBUG, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
 				ast_sched_del(sched, cur->retransid);
+				cur->retransid = -1;
 			}
-			cur->retransid = -1;
 			res = 0;
 			break;
 		}
@@ -5480,7 +5481,7 @@
 					p->owner->name, 
 					p->owner->uniqueid);
 			if (global_notifyhold)
-				sip_peer_hold(p, 0);
+				sip_peer_hold(p, FALSE);
 		} 
 		ast_clear_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD);	/* Clear both flags */
 	} else if (!sin.sin_addr.s_addr || sendonly ) {
@@ -5498,7 +5499,8 @@
 			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_ONEDIR);
 		else if (sendonly == 2)	/* Inactive stream */
 			ast_set_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_INACTIVE);
-		sip_peer_hold(p, 1);
+		if (global_notifyhold)
+			sip_peer_hold(p, TRUE);
 	}
 	
 	return 0;
@@ -6983,7 +6985,6 @@
 	
 	req.method = sipmethod;
 	if (init) { /* Bump branch even on initial requests */
-		/* Bump branch even on initial requests */
 		p->branch ^= ast_random();
 		build_via(p);
 	}
@@ -7371,21 +7372,18 @@
 	if (!r)
 		return 0;
 
-	p = r->register_pvt;
 	ast_log(LOG_NOTICE, "   -- Registration for '%s@%s' timed out, trying again (Attempt #%d)\n", r->username, r->hostname, r->regattempts); 
-	if (p) {
+	if (r->register_pvt) {
 		/* Unlink us, destroy old call.  Locking is not relevant here because all this happens
 		   in the single SIP manager thread. */
-		/* clear register_pvt to prevent unref_registry from killing the session.
-		 * the actual destruction is done down in sip_destroy().
-		 */
-		r->register_pvt = NULL;
+		/* XXX p->registry == r so and r has 2 refs, so the unref won't take the object away */
+		p = r->register_pvt;
 		if (p->registry)
 			unref_registry(p->registry);
 		set_destroy(p);	/* XXX why do that if we are going to kill it in a moment ? */
 		/* Pretend to ACK anything just in case */
 		__sip_pretend_ack(p); /* XXX we need p locked, not sure we have */
-		sip_destroy(p);	/* reference goes away */
+		r->register_pvt = pvt_unref(r->register_pvt);	/* reference goes away */
 	}
 	/* If we have a limit, stop registration and give up */
 	if (global_regattempts_max && (r->regattempts > global_regattempts_max)) {
@@ -12314,8 +12312,8 @@
 		if (global_regattempts_max)
 			p->registry->regattempts = global_regattempts_max+1;
 		set_destroy(p);
-		if (r->register_pvt)	/* XXX are we sure about destroy ? */
-			r->register_pvt = sip_destroy(r->register_pvt);
+		if (r->register_pvt)
+			r->register_pvt = pvt_unref(r->register_pvt);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		break;
@@ -12330,8 +12328,8 @@
 		ast_log(LOG_WARNING, "Got 423 Interval too brief for service %s@%s, minimum is %d seconds\n", p->registry->username, p->registry->hostname, r->expiry);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
-		if (r->register_pvt) {	/* XXX are we sure about destroy ? */
-			r->register_pvt = sip_destroy(r->register_pvt);
+		if (r->register_pvt) {
+			r->register_pvt = pvt_unref(r->register_pvt);
 			set_destroy(p);
 		}
 		if (r->expiry > max_expiry) {
@@ -12349,8 +12347,8 @@
 		if (global_regattempts_max)
 			p->registry->regattempts = global_regattempts_max+1;
 		set_destroy(p);
-		if (r->register_pvt)	/* XXX are we sure about destroy ? */
-			r->register_pvt = sip_destroy(r->register_pvt);
+		if (r->register_pvt)
+			r->register_pvt = pvt_unref(r->register_pvt);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		break;



More information about the svn-commits mailing list