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

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Nov 22 02:56:47 MST 2006


Author: rizzo
Date: Wed Nov 22 03:56:47 2006
New Revision: 47917

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47917
Log:
in handle_response_register() we already have r = p->registry
so don't dereference p all the times.

Also remove some conditionals where we know already that r->register_pvt
is valid.


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=47917&r1=47916&r2=47917
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Nov 22 03:56:47 2006
@@ -12332,25 +12332,24 @@
 	switch (resp) {
 	case 401:	/* Unauthorized */
 		if (p->authtries == MAX_AUTHTRIES || do_register_auth(p, req, resp)) {
-			ast_log(LOG_NOTICE, "Failed to authenticate on REGISTER to '%s@%s' (Tries %d)\n", p->registry->username, p->registry->hostname, p->authtries);
+			ast_log(LOG_NOTICE, "Failed to authenticate on REGISTER to '%s@%s' (Tries %d)\n", r->username, r->hostname, p->authtries);
 			set_destroy(p);
 		}
 		break;
 	case 403:	/* Forbidden */
-		ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for REGISTER for '%s' to '%s'\n", p->registry->username, p->registry->hostname);
+		ast_log(LOG_WARNING, "Forbidden - wrong password on authentication for REGISTER for '%s' to '%s'\n", r->username, r->hostname);
 		if (global_regattempts_max)
-			p->registry->regattempts = global_regattempts_max+1;
+			r->regattempts = global_regattempts_max+1;
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		set_destroy(p);
 		break;
 	case 404:	/* Not found */
-		ast_log(LOG_WARNING, "Got 404 Not found on SIP register to service %s@%s, giving up\n", p->registry->username,p->registry->hostname);
+		ast_log(LOG_WARNING, "Got 404 Not found on SIP register to service %s@%s, giving up\n", r->username, r->hostname);
 		if (global_regattempts_max)
-			p->registry->regattempts = global_regattempts_max+1;
+			r->regattempts = global_regattempts_max+1;
 		set_destroy(p);
-		if (r->register_pvt)
-			r->register_pvt = pvt_unref(r->register_pvt);
+		r->register_pvt = pvt_unref(r->register_pvt);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		break;
@@ -12362,15 +12361,13 @@
 		break;
 	case 423:	/* Interval too brief */
 		r->expiry = atoi(get_header(req, "Min-Expires"));
-		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_log(LOG_WARNING, "Got 423 Interval too brief for service %s@%s, minimum is %d seconds\n", r->username, r->hostname, r->expiry);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
-		if (r->register_pvt) {
-			r->register_pvt = pvt_unref(r->register_pvt);
-			set_destroy(p);
-		}
+		r->register_pvt = pvt_unref(r->register_pvt);
+		set_destroy(p);
 		if (r->expiry > max_expiry) {
-			ast_log(LOG_WARNING, "Required expiration time from %s@%s is too high, giving up\n", p->registry->username, p->registry->hostname);
+			ast_log(LOG_WARNING, "Required expiration time from %s@%s is too high, giving up\n", r->username, r->hostname);
 			r->expiry = default_expiry;
 			r->regstate = REG_STATE_REJECTED;
 		} else {
@@ -12380,22 +12377,15 @@
 		manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
 		break;
 	case 479:	/* SER: Not able to process the URI - address is wrong in register*/
-		ast_log(LOG_WARNING, "Got error 479 on register to %s@%s, giving up (check config)\n", p->registry->username,p->registry->hostname);
+		ast_log(LOG_WARNING, "Got error 479 on register to %s@%s, giving up (check config)\n", r->username, r->hostname);
 		if (global_regattempts_max)
-			p->registry->regattempts = global_regattempts_max+1;
+			r->regattempts = global_regattempts_max+1;
 		set_destroy(p);
-		if (r->register_pvt)
-			r->register_pvt = pvt_unref(r->register_pvt);
+		r->register_pvt = pvt_unref(r->register_pvt);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		break;
 	case 200:	/* 200 OK */
-		if (!r) {
-			ast_log(LOG_WARNING, "Got 200 OK on REGISTER that isn't a register\n");
-			set_destroy(p);
-			return 0;
-		}
-
 		r->regstate = REG_STATE_REGISTERED;
 		r->regtime = time(NULL);		/* Reset time of last succesful registration */
 		manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelDriver: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
@@ -12408,8 +12398,7 @@
 			ast_sched_del(sched, r->timeout);
 		}
 		r->timeout=-1;
-		if (r->register_pvt)	/* XXX are we sure about pvt_unref ? */
-			r->register_pvt = pvt_unref(r->register_pvt);
+		r->register_pvt = pvt_unref(r->register_pvt);
 		p->registry = NULL;
 		/* Let this one hang around until we have all the responses */
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);



More information about the asterisk-commits mailing list