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

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Nov 22 08:50:14 MST 2006


Author: rizzo
Date: Wed Nov 22 09:50:14 2006
New Revision: 47930

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47930
Log:
remove useless check on first argument to transmit_register - we know
it is non-null.
Also remove checks on arguments to scheduled events, they are correct too
unless the whole scheduler is broken.
Finally, remove ASTOBJ_REF/UNREF in the above handlers, as the
reference is already set up (elsewhere).


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=47930&r1=47929&r2=47930
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Nov 22 09:50:14 2006
@@ -2122,7 +2122,7 @@
 	for (prev = NULL, cur = pvt->packets; cur; prev = cur, cur = cur->next) {
 		if (cur == pkt) {
 			UNLINK(cur, pvt->packets, prev);
-			pkt->pvt = pvt_unref(pvt);	/* release the reference pvt */
+			pkt->pvt = pvt_unref(pvt);	/* release the reference to the dialog */
 			sip_pvt_unlock(pvt);
 			free(pkt);
 			return 0;
@@ -7370,32 +7370,28 @@
  * Update registration with SIP Proxy.
  * Called from the scheduler when the previous registration expires,
  * so we don't have to cancel the pending event.
- * XXX The handling of sip_registry references is wrong here - the pointer is in
- * the scheduled event, so grabbing and releasing the reference here is too late.
+ * We assume the reference so the sip_registry is valid, since it
+ * is stored in the scheduled event anyways.
  */
 static int sip_reregister(void *data) 
 {
 	/* if we are here, we know that we need to reregister. */
-	struct sip_registry *r= ASTOBJ_REF((struct sip_registry *) data);
-	struct sip_pvt *pvt;
-
-	/* if we couldn't get a reference to the registry object, punt */
-	if (!r)
-		return 0;
-
-	/* XXX why do we want to keep a dialog here ??? */
-	pvt = r->register_pvt;	/* XXX do we have a lock on it ? */
-	if (pvt && !ast_test_flag(&pvt->flags[0], SIP_NO_HISTORY))
-		append_history(pvt, "RegistryRenew", "Account: %s@%s", r->username, r->hostname);
+	struct sip_registry *r = data;
+
+	r->timeout = -1;	/* old event, now gone */
+	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);
+	}
+	
 	/* Since registry's are only added/removed by the the monitor thread, this
 	   may be overkill to reference/dereference at all here */
 	if (sipdebug)
 		ast_log(LOG_NOTICE, "   -- Re-registration for  %s@%s\n", r->username, r->hostname);
 
-	r->timeout = -1;
 	transmit_register(r, NULL, NULL);
-	unref_registry(r);
-	return 0;
+	return 0;	/* do not reschedule. */
 }
 
 /*! \brief Registration timeout, register again.
@@ -7406,16 +7402,10 @@
  */
 static int sip_reg_timeout(void *data)
 {
-
 	/* if we are here, our registration timed out, so we'll just do it over */
-	struct sip_registry *r = ASTOBJ_REF((struct sip_registry *) data);
+	struct sip_registry *r = data;
 	struct sip_pvt *p;
 	int res;
-
-	if (!r) {
-		ast_log(LOG_WARNING, "very strange, sip_reg_timeout called without a sip_registry. Should not happen\n");
-		return 0;
-	}
 
 	r->timeout = -1;	/* reset event reference */
 	ast_log(LOG_NOTICE, "   -- Registration for '%s@%s' timed out, trying again (Attempt #%d)\n", r->username, r->hostname, r->regattempts); 
@@ -7448,7 +7438,6 @@
 		res=transmit_register(r, NULL, NULL);
 	}
 	manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelDriver: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
-	unref_registry(r);
 	return 0;
 }
 
@@ -7466,7 +7455,7 @@
 	int ret;
 
 	/* exit if we are already in process with this registrar ?*/
-	if ( r == NULL || ((auth==NULL) && (r->regstate==REG_STATE_REGSENT || r->regstate==REG_STATE_AUTHSENT))) {
+	if (auth == NULL && (r->regstate==REG_STATE_REGSENT || r->regstate==REG_STATE_AUTHSENT)) {
 		ast_log(LOG_NOTICE, "Strange, trying to register %s@%s when registration already pending\n", r->username, r->hostname);
 		return 0;
 	}



More information about the svn-commits mailing list