[asterisk-commits] murf: branch murf/bug11210 r95165 - /team/murf/bug11210/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 28 09:38:28 CST 2007


Author: murf
Date: Fri Dec 28 09:38:28 2007
New Revision: 95165

URL: http://svn.digium.com/view/asterisk?view=rev&rev=95165
Log:
Had some corrections to make to the peer_by_ip code-- everyone remember this: Thou shalt not return a negative hash. Only enter those peers with non-zero addr's. First experiment with sipp passes, if I upgrade ulimit on open files.

Modified:
    team/murf/bug11210/channels/chan_sip.c

Modified: team/murf/bug11210/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_sip.c?view=diff&rev=95165&r1=95164&r2=95165
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Fri Dec 28 09:38:28 2007
@@ -1468,6 +1468,8 @@
 	int recheck;
 } regl;
 
+static void addr2str(struct sockaddr_in *sin, char *buf);
+
 /*!
  * \note The only member of the peer passed here guaranteed to be set is the name field
  */
@@ -1494,11 +1496,15 @@
 static int peer_iphash_cb(const void *obj, const int flags)
 {
 	const struct sip_peer *peer = obj;
-
-	if (ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT))
-		return peer->addr.sin_addr.s_addr;
-	else 
-		return peer->addr.sin_addr.s_addr + peer->addr.sin_port;
+	int ret1 = peer->addr.sin_addr.s_addr;
+	if (ret1 < 0)
+		ret1 = -ret1;
+	
+	if (ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT)) {
+		return ret1;
+	} else {
+		return ret1 + peer->addr.sin_port;
+	}
 }
 
 /*!
@@ -1508,11 +1514,6 @@
 {
 	struct sip_peer *peer = obj, *peer2 = arg;
 
-	ast_log(LOG_NOTICE,"peerip %d/%d (ins:%d) == peerip %d/%d (ins:%d) ? %d\n", 
-			peer->addr.sin_addr.s_addr, peer->addr.sin_port, ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT),
-			peer2->addr.sin_addr.s_addr, peer2->addr.sin_port, ast_test_flag(&peer2->flags[0], SIP_INSECURE_PORT),
-			!strcasecmp(peer->name, peer2->name) ? CMP_MATCH : 0);
-	
 	if (peer->addr.sin_addr.s_addr != peer2->addr.sin_addr.s_addr)
 		return 0;
 	
@@ -2105,14 +2106,12 @@
 		dialog->registry = registry_unref(dialog->registry, "delete dialog->registry");
 	}
 	if (dialog->initid > -1) {
-		ast_log(LOG_WARNING,"About to sched_del autocongest for dialog %s in dialog_unlink_all\n", dialog->callid);
 		if (ast_sched_del(sched, dialog->initid)==0)
 			dialog_unref(dialog,"when you delete the initid sched, you should dec the refcount for the stored dialog ptr");
 		dialog->initid = -1;
 	}
 	
 	if (dialog->autokillid > -1) {
-		ast_log(LOG_WARNING,"About to sched_del autokill for dialog %s in dialog_unlink_all\n", dialog->callid);
 		dialog->autokillid = -1;
 		if (ast_sched_del(sched, dialog->autokillid)==0)
 			dialog_unref(dialog,"when you delete the autokillid sched, you should dec the refcount for the stored dialog ptr");
@@ -2635,7 +2634,6 @@
 
 	if (xmitres == XMIT_ERROR) {	/* Serious network trouble, no need to try again */
 		append_history(pkt->owner, "XmitErr", "%s", pkt->is_fatal ? "(Critical)" : "(Non-critical)");
-		ast_log(LOG_WARNING,"About to sched_del pkt->retransid (%d) in __sip_reliable_xmit\n", pkt->retransid);
 		ast_sched_del(sched, pkt->retransid);	/* No more retransmission */
 		pkt->retransid = -1;
 		return AST_FAILURE;
@@ -2652,7 +2650,6 @@
 {
 	struct sip_pvt *p = (struct sip_pvt *)data;
 
-	ast_log(LOG_NOTICE,"SCHED:  __sip_autodestruct called--- kill dialog\n");
 	/* If this is a subscription, tell the phone that we got a timeout */
 	if (p->subscribed) {
 		transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE);	/* Send last notification */
@@ -2676,7 +2673,6 @@
 	/* Reset schedule ID */
 	if (p->autokillid != -1) {
 		int res3;
-		ast_log(LOG_WARNING,"About to sched_del autokillid(%d) for dialog %s in sip_cancel_destroy\n", p->autokillid, p->callid);
 		res3 = ast_sched_del(sched, p->autokillid);
 		append_history(p, "CancelDestroy", "");
 		p->autokillid = -1;
@@ -2698,7 +2694,6 @@
 	} else {
 		append_history(p, "AutoDestroy", "%s", p->callid);
 		ast_debug(3, "Auto destroying SIP dialog '%s'\n", p->callid);
-		ast_log(LOG_NOTICE,"AutoDestroy dialog %s\n", p->callid);
 		dialog_unlink_all(p, TRUE, TRUE); /* once it's unlinked and unrefd everywhere, it'll be freed automagically */
 		dialog_unref(p,"unref dialog-- no other matching conditions"); /* theoretically, this should be the last ref to this dialog */
 		/* sip_destroy(p); */		/* Go ahead and destroy dialog. All attempts to recover is done */
@@ -2722,7 +2717,6 @@
 	sip_cancel_destroy(p);
 	if (p->do_history)
 		append_history(p, "SchedDestroy", "%d ms", ms);
-	ast_log(LOG_WARNING,"About to sched_add sip_autodestruct for dialog %s in sip_scheddestroy\n", p->callid);
 	p->autokillid = ast_sched_add(sched, ms, __sip_autodestruct, dialog_ref(p,"setting ref as passing into ast_sched_add for __sip_autodestruct"));
 }
 
@@ -2734,7 +2728,6 @@
 {
 	if (p->autokillid > -1) {
 		int res3;
-		ast_log(LOG_WARNING,"About to sched_del autokillid(%d) for dialog %s in sip_cancel_destroy\n", p->autokillid, p->callid);
 		res3 = ast_sched_del(sched, p->autokillid);
 		append_history(p, "CancelDestroy", "");
 		p->autokillid = -1;
@@ -2771,7 +2764,6 @@
 			if (cur->retransid > -1) {
 				if (sipdebug)
 					ast_debug(4, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
-				ast_log(LOG_WARNING,"About to sched_del retransid=%d in __sip_ack\n", cur->retransid);
 				ast_sched_del(sched, cur->retransid);
 				cur->retransid = -1;
 			}
@@ -2817,7 +2809,6 @@
 			if (cur->retransid > -1) {
 				if (sipdebug)
 					ast_debug(4, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
-				ast_log(LOG_WARNING,"About to sched_del retransid=%d in __sip_semi_ack\n", cur->retransid);
 				ast_sched_del(sched, cur->retransid);
 				cur->retransid = -1;
 			}
@@ -3211,7 +3202,6 @@
 
 	/* Delete it, it needs to disappear */
 	if (peer->call) {
-		ast_log(LOG_NOTICE,"Calling Sip_Destroy() from peer for %s....\n", peer->call->callid);
 		dialog_unlink_all(peer->call, TRUE, TRUE);
 		peer->call = dialog_unref(peer->call,"peer->call is being unset");
 		/* peer->call = sip_destroy(peer->call); */
@@ -3219,7 +3209,6 @@
 	
 
 	if (peer->mwipvt) {	/* We have an active subscription, delete it */
-		ast_log(LOG_NOTICE,"Calling Sip_Destroy() from mwipvt for %s....\n", peer->mwipvt->callid);
 		dialog_unlink_all(peer->mwipvt, TRUE, TRUE);
 		peer->mwipvt = dialog_unref(peer->mwipvt, "unreffing peer->mwipvt");
 		/* peer->mwipvt = sip_destroy(peer->mwipvt); */
@@ -3230,7 +3219,6 @@
 		peer->chanvars = NULL;
 	}
 	if (peer->expire > -1) {
-		ast_log(LOG_WARNING,"About to sched_del peer->expire = %d in __sip_destroy_peer\n", peer->expire);
 		ast_sched_del(sched, peer->expire); /* HUH?  normally, if peer were being refcounted thru sched calls, we'd
 											   add code after this to unref the peer */
 	}
@@ -3458,14 +3446,19 @@
 		/* Cache peer */
 		ast_copy_flags(&peer->flags[1],&global_flags[1], SIP_PAGE2_RTAUTOCLEAR|SIP_PAGE2_RTCACHEFRIENDS);
 		if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
-			ast_log(LOG_WARNING,"About to sched_replace peer->expire = %d in realtime_peer\n", peer->expire);
 			peer->expire = ast_sched_replace(peer->expire, sched, 
 				global_rtautoclear * 1000, expire_register, (void *) peer); /* HUH? peer is a refcounted object, and we are storing it in the sched struct, so 
 																			   really, really, we should be incr. its refcount right here, but I guess, since
 																			   peers hang around until module unload time anyway, it's not worth the trouble */
 		}
 		ao2_t_link(peers, peer, "link peer into peers table");
-		ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+		if (peer->addr.sin_addr.s_addr) {
+			char buf8[20];
+			addr2str(&peer->addr,buf8);
+			ast_log(LOG_NOTICE,"Inserted %s into peers_by_ip\n", buf8);
+			ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+		}
+		
 	} else {
 		peer->is_realtime = 1;
 	}
@@ -3499,10 +3492,19 @@
 	\note Avoid using this function in new functions if there's a way to avoid it, i
 	since it causes a database lookup or a traversal of the in-memory peer list.
 */
+static void addr2str(struct sockaddr_in *sin, char *buf)
+{
+	int a,b,c,d;
+	a = (sin->sin_addr.s_addr >> 24);
+	b = (sin->sin_addr.s_addr & 0x00ff0000) >> 16;
+	c = (sin->sin_addr.s_addr & 0x0000ff00) >> 8;
+	d = (sin->sin_addr.s_addr & 0xff);
+	sprintf(buf,"%d.%d.%d.%d (%x)", d,c,b,a, sin->sin_addr.s_addr);
+}
+
 static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int realtime)
 {
 	struct sip_peer *p = NULL;
-	int rc;
 	struct sip_peer tmp_peer;
 	
 	if (peer)
@@ -3512,14 +3514,29 @@
 	} else if (sin) { /* search by addr? */
 		tmp_peer.addr.sin_addr.s_addr = sin->sin_addr.s_addr;
 		tmp_peer.addr.sin_port = sin->sin_port;
-		ast_log(LOG_NOTICE,"Searching for peer %s by IP addr/port = %d/%d\n", peer, sin->sin_addr.s_addr, sin->sin_port);
 		p = ao2_t_find(peers_by_ip, &tmp_peer, OBJ_POINTER,"ao2_find in peers_by_ip table"); /* WAS:  p = ASTOBJ_CONTAINER_FIND_FULL(&peerl, sin, name, sip_addr_hashfunc, 1, sip_addrcmp); */
-	}
-	
+		if (!p) {
+			struct ao2_iterator i;
+			char ad[40];
+			struct sip_peer *d2;
+			addr2str(sin, ad);
+			ast_log(LOG_NOTICE,"Couldn't find sin=> %s...\n", ad);
+				
+			i = ao2_iterator_init(peers_by_ip, 0);
+				
+			while ((d2 = ao2_t_iterator_next(&i,"iterate thru peers_by_ip "))) {
+				addr2str(&d2->addr, ad);
+				ast_log(LOG_NOTICE, "Peers_by_ip:  %s\n", ad);
+				ao2_t_ref(d2,-1,"done with d2 pointer");
+			}
+		}
+	}
 
 	if (!p && realtime)
 		p = realtime_peer(peer, sin);
 
+#ifdef FIND_PEER_DEBUG
+	int rc;
 	if (!p && !sin)
 		ast_log(LOG_NOTICE,"Did not find peer %s\n", peer);
 	else if (!p)
@@ -3529,6 +3546,7 @@
 		rc = ao2_t_ref(p,0,"");
 		ast_log(LOG_NOTICE,"FOUND peer %s refcount = %d\n", peer, rc);
 	}
+#endif
 	return p;
 }
 
@@ -3738,7 +3756,6 @@
 				ao2_t_unlink(dialogs,dialog,"About to change the callid -- remove the old name");
 				ast_string_field_build(dialog, callid, "%s@%s", tmpcall, peer->fromdomain);
 				ao2_t_link(dialogs,dialog,"New dialog callid -- inserted back into table");
-				ast_log(LOG_NOTICE,"============================================================Changed Dialog name to %s\n", dialog->callid);
 			}
 		}
 	}
@@ -3846,13 +3863,11 @@
 {
 	struct sip_pvt *p = (struct sip_pvt *)arg;
 
-	ast_log(LOG_NOTICE,"SCHED:  auto_congest called for dialog %s---\n", p->callid);
 	sip_pvt_lock(p);
 	p->initid = -1;	/* event gone, will not be rescheduled */
 	if (p->owner) {
 		/* XXX fails on possible deadlock */
 		if (!ast_channel_trylock(p->owner)) {
-			ast_log(LOG_NOTICE, "Auto-congesting %s\n", p->owner->name);
 			append_history(p, "Cong", "Auto-congesting (timer)");
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
 			ast_channel_unlock(p->owner);
@@ -3946,7 +3961,6 @@
 		p->invitestate = INV_CALLING;
 	
 		/* Initialize auto-congest time */
-		ast_log(LOG_WARNING,"About to sched_replace autocongest for dialog %s in sip_call\n", p->callid);
 		p->initid = ast_sched_replace(p->initid, sched, p->timer_b, 
 									  auto_congest, dialog_ref(p,"sched:replace:this is a pointer for the autocongest callback to use (p->initid)"));
 	}
@@ -3960,26 +3974,22 @@
 {
 	/* Really delete */
 	ast_debug(3, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
-	ast_log(LOG_NOTICE,"Destroying SIP registry entry  %s@%s\n", reg->username, reg->hostname);
 
 	if (reg->call) {
 		/* Clear registry before destroying to ensure
 		   we don't get reentered trying to grab the registry lock */
 		reg->call->registry = registry_unref(reg->call->registry, "destroy reg->call->registry");
 		ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
-		ast_log(LOG_NOTICE,"Calling Sip_Destroy() from registry for %s....\n", reg->call->callid);
 		dialog_unlink_all(reg->call, TRUE, TRUE);
 		reg->call = dialog_unref(reg->call,"unref reg->call");
 		/* reg->call = sip_destroy(reg->call); */
 	}
 	if (reg->expire > -1) {
-		ast_log(LOG_WARNING,"About to sched_del reg->expire in sip_registry_destroy\n");
 		ast_sched_del(sched, reg->expire);  /* HUH?  normally, if reg were being refcounted thru sched calls, we'd
 											   add code after this to unref the reg */
 	}
 	
 	if (reg->timeout > -1) {
-		ast_log(LOG_WARNING,"About to sched_del reg->timeout in sip_registry_destroy\n");
 		ast_sched_del(sched, reg->timeout);   /* HUH?  normally, if peer were being refcounted thru sched calls, we'd
 											   add code after this to unref the peer */
 	}
@@ -3996,7 +4006,6 @@
 {
 	struct sip_pkt *cp;
 
-	ast_log(LOG_NOTICE,"======Destroying the empty shell of dialog %s=====\n", p->callid);
 	if (sip_debug_test_pvt(p))
 		ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
 
@@ -4025,7 +4034,6 @@
 		ast_extension_state_del(p->stateid, NULL);
 	if (p->waitid > -1)
 	{
-		ast_log(LOG_WARNING,"About to sched_del waitid(%d) for dialog %s in __sip_destroy\n", p->waitid, p->callid);
 		if (ast_sched_del(sched, p->waitid) == 0)
 			dialog_unref(p,"when you delete the waitid sched, you should dec the refcount for the stored dialog ptr");
 		p->waitid = -1;
@@ -4034,13 +4042,11 @@
 
 	if (p->initid > -1) {
 		/* Don't auto congest anymore since we've gotten something useful back */
-		ast_log(LOG_WARNING,"About to sched_del p->initid for dialog %s in __sip_destroy\n", p->callid);
 		if (ast_sched_del(sched, p->initid) == 0)
 			dialog_unref(p,"when you delete the initid sched, you should dec the refcount for the stored dialog ptr");
 		p->initid = -1;
 	}
 	if (p->autokillid > -1) {
-		ast_log(LOG_WARNING,"About to sched_del autokillid(%d) for dialog %s in __sip_destroy\n", p->autokillid, p->callid);
 		p->autokillid = -1;
 		if (ast_sched_del(sched, p->autokillid)==0)
 			dialog_unref(p,"when you delete the autokillid sched, you should dec the refcount for the stored dialog ptr");
@@ -4076,7 +4082,6 @@
 	while((cp = p->packets)) {
 		p->packets = p->packets->next;
 		if (cp->retransid > -1) {
-			ast_log(LOG_WARNING,"About to sched_del retransid(%d) in __sip_destroy\n", cp->retransid);
 			ast_sched_del(sched, cp->retransid); /* HUH??? well, ok, sip_pkt's are not refcounted objects */
 		}
 		
@@ -4091,7 +4096,6 @@
 
 	ast_string_field_free_memory(p);
 	
-	ast_log(LOG_NOTICE,"Destroying dialog;\n");
 }
 
 /*! \brief  update_call_counter: Handle call_limit for SIP users 
@@ -4213,7 +4217,6 @@
 
 static void sip_destroy_fn(void *p)
 {
-	ast_log(LOG_NOTICE,"sip_destroy_fn called\n");
 	sip_destroy(p);
 }
 
@@ -4502,7 +4505,6 @@
 				if ( p->initid != -1 ) {
 					/* channel still up - reverse dec of inUse counter
 					   only if the channel is not auto-congested */
-					ast_log(LOG_WARNING,"About to update_call_counter autocongest for dialog %s in sip_hangup\n", p->callid);
 					update_call_counter(p, INC_CALL_LIMIT);
 				}
 			} else {	/* Incoming call, not up */
@@ -4548,7 +4550,6 @@
 				ast_set_flag(&p->flags[0], SIP_PENDINGBYE);	
 				ast_clear_flag(&p->flags[0], SIP_NEEDREINVITE);	
 				if (p->waitid) {
-					ast_log(LOG_WARNING,"About to sched_del waitid(%d) for dialog %s in sip_hangup\n", p->waitid, p->callid);
 					if (ast_sched_del(sched, p->waitid) == 0)
 						dialog_unref(p,"when you delete the waitid sched, you should dec the refcount for the stored dialog ptr");
 				}
@@ -5383,7 +5384,6 @@
 {
 	struct sip_pvt *p;
 
-	ast_log(LOG_NOTICE,"allocating PVT for %s\n", callid);
 	if (!(p = ao2_t_alloc(sizeof(*p), sip_destroy_fn, "allocate a dialog(pvt) struct")))
 		return NULL;
 
@@ -5508,7 +5508,6 @@
 	/* Add to active dialog list */
 
 	ao2_t_link(dialogs, p, "link pvt into dialogs table");
-	ast_log(LOG_NOTICE,"***Just linked %s into dialogs table\n", p->callid);
 	
 	ast_debug(1, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : p->callid, sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
 	return p;
@@ -5646,14 +5645,12 @@
 			sip_pvt_ptr = ao2_t_find(dialogs, &tmp_dialog, OBJ_POINTER, "ao2_find in dialogs");
 			if (sip_pvt_ptr) {
 				rc = ao2_t_ref(sip_pvt_ptr,0,"");
-				ast_log(LOG_NOTICE,"Found CALL dialog %s, refcount = %d\n", tmp_dialog.callid, rc);
 			}
-			
+#ifdef DIALOG_DEBUG
 			if (!sip_pvt_ptr) {
 				struct ao2_iterator i;
 				struct sip_pvt *d2;
 				
-				ast_log(LOG_NOTICE,"Dialog %s not found\n", callid);
 				i = ao2_iterator_init(dialogs, 0);
 				
 				while ((d2 = ao2_t_iterator_next(&i,"iterate thru dialogs "))) {
@@ -5661,6 +5658,7 @@
 					ao2_t_ref(d2,-1,"done with d2 pointer");
 				}
 			}
+#endif
 			ast_string_field_free_memory(&tmp_dialog);
 			if (sip_pvt_ptr) {  /* well, if we don't find it-- what IS in there? */
 				/* Found the call */
@@ -8654,7 +8652,6 @@
 	/* if we are here, we know that we need to reregister. */
 	struct sip_registry *r= registry_addref((struct sip_registry *) data,"reg_addref from sip_reregister");
 
-	ast_log(LOG_NOTICE,"SCHED:  sip_reregister called---\n");
 	/* if we couldn't get a reference to the registry object, punt */
 	if (!r)
 		return 0;
@@ -8695,7 +8692,6 @@
 	struct sip_pvt *p;
 	int res;
 
-	ast_log(LOG_NOTICE,"SCHED:  sip_reg_timeout called---\n");
 	/* if we couldn't get a reference to the registry object, punt */
 	if (!r)
 		return 0;
@@ -8784,18 +8780,15 @@
 		if (create_addr(p, r->hostname)) {
 			/* we have what we hope is a temporary network error,
 			 * probably DNS.  We need to reschedule a registration try */
-			ast_log(LOG_NOTICE,"Calling Sip_Destroy() from registry building for %s....\n", p->callid);
 			dialog_unlink_all(p, TRUE, TRUE);
 			dialog_unref(p, "unref dialog after unlink_all");
 			/* sip_destroy(p); */
 			if (r->timeout > -1) {
-				ast_log(LOG_WARNING,"About to sched_replace reg timeout(%d) for reg in transmit_register\n", r->timeout);
 				r->timeout = ast_sched_replace(r->timeout, sched, 
 					global_reg_timeout * 1000, sip_reg_timeout, r);
 				ast_log(LOG_WARNING, "Still have a registration timeout for %s@%s (create_addr() error), %d\n", r->username, r->hostname, r->timeout);
 			} else {
 				r->timeout = ast_sched_add(sched, global_reg_timeout*1000, sip_reg_timeout, r);
-				ast_log(LOG_WARNING,"Just did sched_add reg timeout(%d) for reg in transmit_register\n", r->timeout);
 				ast_log(LOG_WARNING, "Probably a DNS error for registration to %s@%s, trying REGISTER again (after %d seconds)\n", r->username, r->hostname, global_reg_timeout);
 			}
 			r->regattempts++;
@@ -8844,7 +8837,6 @@
 	if (auth == NULL)  {
 		if (r->timeout > -1)
 			ast_log(LOG_WARNING, "Still have a registration timeout, #%d - deleting it\n", r->timeout);
-		ast_log(LOG_WARNING,"About to sched_replace reg timeout(%d) for reg in transmit_register\n", r->timeout);
 		r->timeout = ast_sched_replace(r->timeout, sched, global_reg_timeout * 1000, sip_reg_timeout, r);
 		ast_debug(1, "Scheduled a registration timeout for %s id  #%d \n", r->hostname, r->timeout);
 	}
@@ -9151,7 +9143,6 @@
 {
 	struct sip_peer *peer = (struct sip_peer *)data;
 	
-	ast_log(LOG_NOTICE,"SCHED:  expire_register called---\n");
 	if (!peer)		/* Hmmm. We have no peer. Weird. */
 		return 0;
 
@@ -9172,13 +9163,15 @@
 
 	if (peer->selfdestruct ||
 	    ast_test_flag(&peer->flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
-		int rc = ao2_t_ref(peer,0,"");
-		ast_log(LOG_NOTICE,"Peer %s removing from the name hash. Refc=%d\n", peer->name, rc);
 		ao2_t_unlink(peers, peer, "ao2_unlink of peer from peers table");
+		if (peer->addr.sin_addr.s_addr)
+		{
+			char buf8[40];
+			addr2str(&peer->addr,buf8);
+			ast_log(LOG_NOTICE,"Unlinking %s from peers_by_ip table", buf8);
+			ao2_t_unlink(peers_by_ip, peer, "ao2_unlink of peer from peers table");
+		}
 		
-		rc = ao2_t_ref(peer,0,"");
-		ast_log(LOG_NOTICE,"Peer %s removing from the IP hash. Refc=%d\n", peer->name, rc);
-		ao2_t_unlink(peers_by_ip, peer, "ao2_unlink of peer from peers table");
 	}
 
 	return 0;
@@ -9361,7 +9354,6 @@
 		/* This means remove all registrations and return OK */
 		memset(&peer->addr, 0, sizeof(peer->addr));
 		if (peer->expire > -1) {
-			ast_log(LOG_WARNING,"About to sched_del peer expire(%d) for peer in parse_register_result\n", peer->expire);
 			ast_sched_del(sched, peer->expire);
 		}
 		
@@ -9414,7 +9406,6 @@
 		ast_copy_string(peer->username, curi, sizeof(peer->username));
 
 	if (peer->expire > -1) {
-		ast_log(LOG_WARNING,"About to sched_del peer expire(%d) for peer in parse_register_result\n", peer->expire);
 		ast_sched_del(sched, peer->expire);
 		peer->expire = -1;
 	}
@@ -9424,7 +9415,6 @@
 		expiry = min_expiry;
 	peer->expire = peer->is_realtime ? -1 :
 		ast_sched_add(sched, (expiry + 10) * 1000, expire_register, peer);
-	ast_log(LOG_WARNING,"Just did sched_add peer expire(%d) for peer in parse_register_result\n", peer->expire);
 	pvt->expiry = expiry;
 	snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry, peer->username, peer->fullcontact);
 	if (!peer->rt_fromcontact) 
@@ -9939,6 +9929,13 @@
 		peer = temp_peer(name);
 		if (peer) {
 			ao2_t_link(peers, peer,"link peer into peer table");
+			if (peer->addr.sin_addr.s_addr) {
+				char buf8[40];
+				addr2str(&peer->addr,buf8);
+				ast_log(LOG_NOTICE,"Inserted %s into peers_by_ip\n", buf8);
+				ao2_t_link(peers_by_ip, peer,"link peer into peer table");
+			}
+			
 			sip_cancel_destroy(p);
 			switch (parse_register_contact(p, peer, req)) {
 			case PARSE_REGISTER_FAILED:
@@ -10237,8 +10234,6 @@
 		sip_pvt_ptr = ao2_t_find(dialogs, &tmp_dialog, OBJ_POINTER, "ao2_find of dialog in dialogs table");
 		if (sip_pvt_ptr) {
 			char *ourtag = sip_pvt_ptr->tag;
-			int rc = ao2_t_ref(sip_pvt_ptr,0,"");
-			ast_log(LOG_NOTICE,"Found dialog %s refcount=%d\n", sip_pvt_ptr->callid, rc);
 			/* Go ahead and lock it (and its owner) before returning */
 			sip_pvt_lock(sip_pvt_ptr);
 
@@ -10257,7 +10252,6 @@
 					ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING",
 					sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
 		}
-		else ast_log(LOG_NOTICE,"Did not Find dialog %s\n", tmp_dialog.callid);
 
 		ast_string_field_free_memory(&tmp_dialog);
 		return sip_pvt_ptr;
@@ -11714,7 +11708,6 @@
 	check_rtp_timeout(dialog, *t);
 
 	if (dialog->needdestroy && !dialog->packets && !dialog->owner) {
-		ast_log(LOG_NOTICE, "Dialog %s should be destroyed\n", dialog->callid);
 		return CMP_MATCH;
 	}
 	return 0;
@@ -11846,7 +11839,6 @@
 				unref_peer(pi,"toss iterator peer ptr");
 			}
 			if (pruned) {
-				ast_log(LOG_NOTICE,"Callback to PRUNE PEERS\n");
 				ao2_t_callback(peers, OBJ_NODATA|OBJ_UNLINK, peer_is_marked, 0, "initiating callback to remove marked peers");
 				ast_cli(a->fd, "%d peers pruned.\n", pruned);
 			} else
@@ -11870,7 +11862,6 @@
 				unref_user(ui,"toss iterator user ptr");
 			}
 			if (pruned) {
-				ast_log(LOG_NOTICE,"Callback to PRUNE USERS\n");
 				ao2_t_callback(users, OBJ_NODATA|OBJ_UNLINK, user_is_marked, 0, "callback to remove marked users");
 				ast_cli(a->fd, "%d users pruned.\n", pruned);
 			} else
@@ -11882,12 +11873,24 @@
 			struct sip_peer tmp;
 			ast_copy_string(tmp.name, name, sizeof(tmp.name));
 			if ((peer = ao2_t_find(peers, &tmp, OBJ_POINTER|OBJ_UNLINK, "finding to unlink from peers"))) {
-				ao2_t_unlink(peers_by_ip,peer,"unlinking peer from peers_by_ip also");
+				if (peer->addr.sin_addr.s_addr)
+				{
+					char buf8[40];
+					addr2str(&peer->addr,buf8);
+					ast_log(LOG_NOTICE,"Unlinking %s from peers_by_ip table",buf8);
+					ao2_t_unlink(peers_by_ip,peer,"unlinking peer from peers_by_ip also");
+				}
 				if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
 					ast_cli(a->fd, "Peer '%s' is not a Realtime peer, cannot be pruned.\n", name);
 					/* put it back! */
 					ao2_t_link(peers, peer, "link peer into peer table");
-					ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+					if (peer->addr.sin_addr.s_addr) {
+						char buf8[40];
+						addr2str(&peer->addr,buf8);
+						ast_log(LOG_NOTICE,"...Inserted %s back into peers_by_ip\n", buf8);
+						ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+					}
+					
 				} else
 					ast_cli(a->fd, "Peer '%s' pruned.\n", name);
 				unref_peer(peer,"sip_prune_realtime: unref_peer: tossing temp peer ptr");
@@ -13379,7 +13382,6 @@
 
 		if (create_addr(p, a->argv[i])) {
 			/* Maybe they're not registered, etc. */
-			ast_log(LOG_NOTICE,"Calling Sip_Destroy() from sip_notify for %s....\n", p->callid);
 			dialog_unlink_all(p, TRUE, TRUE);
 			dialog_unref(p, "unref dialog inside for loop" );
 			/* sip_destroy(p); */
@@ -13398,11 +13400,9 @@
 		/* Recalculate our side, and recalculate Call ID */
 		ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
 		build_via(p);
-		ast_log(LOG_NOTICE,"====================================About to build callid for %s\n", p->callid);
 		ao2_t_unlink(dialogs,p,"About to change the callid -- remove the old name");
 		build_callid_pvt(p);
 		ao2_t_link(dialogs,p,"Linking in new name");
-		ast_log(LOG_NOTICE,"====================================New callid: %s\n", p->callid);
 		ast_cli(a->fd, "Sending NOTIFY of type '%s' to '%s'\n", a->argv[2], a->argv[i]);
 		dialog_ref(p,"bump the count of p, which transmit_sip_request will decrement.");
 		transmit_sip_request(p, &req);
@@ -14004,7 +14004,6 @@
 {
 	struct sip_pvt *p = (struct sip_pvt *) data;
 
-	ast_log(LOG_NOTICE,"SCHED:  sip_reinvite_retry called---\n");
 	ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);	
 	dialog_unref(p,"unref the dialog ptr from sip_reinvite_retry, because it held a dialog ptr");
 	p->waitid = -1;
@@ -14034,7 +14033,6 @@
 	/* Acknowledge sequence number - This only happens on INVITE from SIP-call */
 	if (p->initid > -1) {
 		/* Don't auto congest anymore since we've gotten something useful back */
-		ast_log(LOG_WARNING,"About to sched_del initd (autocongest) for dialog %s in handle_response_invite\n", p->callid);
 		if (ast_sched_del(sched, p->initid) == 0)
 			dialog_unref(p,"when you delete the initid sched, you should dec the refcount for the stored dialog ptr");
 		p->initid = -1;
@@ -14406,7 +14404,6 @@
 		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,"About to sched_del registry timeout(%d) for reg in handle_response_register state 403\n", r->timeout);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		r->regstate = REG_STATE_NOAUTH;
@@ -14418,7 +14415,6 @@
 		if (r->call)
 			r->call = dialog_unref(r->call,"unsetting registry->call pointer-- case 404");
 		r->regstate = REG_STATE_REJECTED;
-		ast_log(LOG_WARNING,"About to sched_del registry timeout(%d) for reg in handle_response_register state 404\n", r->timeout);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		break;
@@ -14434,14 +14430,12 @@
 		p->needdestroy = 1;
 		if (r->call)
 			r->call = dialog_unref(r->call,"unsetting registry->call pointer-- case 408");
-		ast_log(LOG_WARNING,"About to sched_del registry timeout(%d) for reg in handle_response_register state 408\n", r->timeout);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		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,"About to sched_del registry timeout(%d) for reg in handle_response_register state 423\n", r->timeout);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		if (r->call) {
@@ -14464,7 +14458,6 @@
 		if (r->call)
 			r->call = dialog_unref(r->call,"unsetting registry->call pointer-- case 479");
 		r->regstate = REG_STATE_REJECTED;
-		ast_log(LOG_WARNING,"About to sched_del registry timeout(%d) for reg in handle_response_register state 479\n", r->timeout);
 		ast_sched_del(sched, r->timeout);
 		r->timeout = -1;
 		break;
@@ -14482,7 +14475,6 @@
 		ast_debug(1, "Registration successful\n");
 		if (r->timeout > -1) {
 			ast_debug(1, "Cancelling timeout %d\n", r->timeout);
-			ast_log(LOG_WARNING,"About to sched_del registry timeout(%d) for reg in handle_response_register state 200\n", r->timeout);
 			ast_sched_del(sched, r->timeout);
 		}
 		r->timeout=-1;
@@ -14496,7 +14488,6 @@
 		/* set us up for re-registering */
 		/* figure out how long we got registered for */
 		if (r->expire > -1){
-			ast_log(LOG_WARNING,"About to sched_del registry expire(%d) for reg in handle_response_register state 200\n", r->expire);
 			ast_sched_del(sched, r->expire);
 		}
 		
@@ -14543,7 +14534,6 @@
 		r->refresh= (int) expires_ms / 1000;
 		
 		/* Schedule re-registration before we expire */
-		ast_log(LOG_WARNING,"About to sched_replace registry expire(%d) for reg in handle_response_register near end\n", r->expire);
 		r->expire = ast_sched_replace(r->expire, sched, expires_ms, sip_reregister, r); 
 		registry_unref(r,"unref registry ptr r"); /* HUH?  if this gets deleted, p->registry will be a bad pointer! */
 		/* shouldn't this be:
@@ -14596,7 +14586,6 @@
 	p->needdestroy = 1;
 
 	/* Try again eventually */
-	ast_log(LOG_WARNING,"About to sched_replace peer pokeexpire(%d) for peer in handle_response_peerpoke\n", peer->pokeexpire);
 	peer->pokeexpire = ast_sched_replace(peer->pokeexpire, sched,
 		is_reachable ? DEFAULT_FREQ_OK : DEFAULT_FREQ_NOTOK,
 		sip_poke_peer_s, peer);
@@ -17547,7 +17536,6 @@
 			return -1;
 		if (create_addr_from_peer(p, peer)) {
 			/* Maybe they're not registered, etc. */
-			ast_log(LOG_NOTICE,"Calling Sip_Destroy() from peer mwi for %s....\n", p->callid);
 			dialog_unlink_all(p, TRUE, TRUE);
 			dialog_unref(p,"unref dialog p just created via sip_alloc");
 			/* sip_destroy(p); */
@@ -17555,12 +17543,10 @@
 		}
 		/* Recalculate our side, and recalculate Call ID */
 		ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
-		ast_log(LOG_NOTICE,"====================================About to build callid for %s\n", p->callid);
 		build_via(p);
 		ao2_t_unlink(dialogs,p,"About to change the callid -- remove the old name");
 		build_callid_pvt(p);
 		ao2_t_link(dialogs,p,"Linking in under new name");
-		ast_log(LOG_NOTICE,"====================================New callid: %s\n", p->callid);
 		/* Destroy this session after 32 secs */
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 	}
@@ -17737,7 +17723,6 @@
 {
 	struct sip_peer *peer = (struct sip_peer *)data;
 	
-	ast_log(LOG_NOTICE,"SCHED:  sip_poke_noanswer called---\n");
 	peer->pokeexpire = -1;
 	if (peer->lastms > -1) {
 		ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE!  Last qualify: %d\n", peer->name, peer->lastms);
@@ -17746,7 +17731,6 @@
 			register_peer_exten(peer, FALSE);
 	}
 	if (peer->call) {
-		ast_log(LOG_NOTICE,"Calling Sip_Destroy() from peer call poke for %s....\n", peer->call->callid);
 		dialog_unlink_all(peer->call, TRUE, TRUE);
 		peer->call = dialog_unref(peer->call,"unref dialog peer->call");
 		/* peer->call = sip_destroy(peer->call);*/
@@ -17755,7 +17739,6 @@
 	peer->lastms = -1;
 	ast_device_state_changed("SIP/%s", peer->name);
 	/* Try again quickly */
-	ast_log(LOG_WARNING,"About to sched_replace peer pokeexpire(%d) for peer in sip_poke_noanswer\n", peer->pokeexpire);
 	peer->pokeexpire = ast_sched_replace(peer->pokeexpire, sched, 
 		DEFAULT_FREQ_NOTOK, sip_poke_peer_s, peer);
 	return 0;
@@ -17773,7 +17756,6 @@
 		/* IF we have no IP, or this isn't to be monitored, return
 		  imeediately after clearing things out */
 		if (peer->pokeexpire > -1) {
-			ast_log(LOG_WARNING,"About to sched_del peer pokeexpire(%d) for peer in sip_poke_peer\n", peer->pokeexpire);
 			ast_sched_del(sched, peer->pokeexpire);
 		}
 		
@@ -17785,7 +17767,6 @@
 	if (peer->call) {
 		if (sipdebug)
 			ast_log(LOG_NOTICE, "Still have a QUALIFY dialog active, deleting\n");
-		ast_log(LOG_NOTICE,"Calling Sip_Destroy() from peer poking for %s....\n", peer->call->callid);
 		dialog_unlink_all(peer->call, TRUE, TRUE);
 		peer->call = dialog_unref(peer->call, "unref dialog peer->call");
 		/* peer->call = sip_destroy(peer->call); */
@@ -17809,16 +17790,13 @@
 		ast_string_field_set(p, tohost, ast_inet_ntoa(peer->addr.sin_addr));
 
 	/* Recalculate our side, and recalculate Call ID */
-	ast_log(LOG_NOTICE,"====================================About to build callid for %s\n", p->callid);
 	ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
 	build_via(p);
 	ao2_t_unlink(dialogs,p,"About to change the callid -- remove the old name");
 	build_callid_pvt(p);
 	ao2_t_link(dialogs,p,"Linking in under new name");
-	ast_log(LOG_NOTICE,"====================================New callid: %s\n", p->callid);
 
 	if (peer->pokeexpire > -1) {
-		ast_log(LOG_WARNING,"About to sched_del peer pokeexpire(%d) for peer in sip_poke_peer\n", peer->pokeexpire);
 		ast_sched_del(sched, peer->pokeexpire);
 	}
 	
@@ -17834,7 +17812,6 @@
 	if (xmitres == XMIT_ERROR)
 		sip_poke_noanswer(peer);	/* Immediately unreachable, network problems */
 	else {
-		ast_log(LOG_WARNING,"About to sched_replace peer pokeexpire(%d) for peer in sip_poke_peer near end\n", peer->pokeexpire);
 		peer->pokeexpire = ast_sched_replace(peer->pokeexpire, sched, 
 			peer->maxms * 2, sip_poke_noanswer, peer);
 	}
@@ -17987,7 +17964,6 @@
 	p->outgoing_call = TRUE;
 
 	if (!(p->options = ast_calloc(1, sizeof(*p->options)))) {
-		ast_log(LOG_NOTICE,"Calling Sip_Destroy() from call request for %s....\n", p->callid);
 		dialog_unlink_all(p, TRUE, TRUE);
 		dialog_unref(p,"unref dialog p from mem fail");
 		/* sip_destroy(p); */
@@ -18027,7 +18003,6 @@
 	if (create_addr(p, host)) {
 		*cause = AST_CAUSE_UNREGISTERED;
 		ast_debug(3, "Cant create SIP call - target device not registred\n");
-		ast_log(LOG_NOTICE,"Calling Sip_Destroy() from call request 2 for %s....\n", p->callid);
 		dialog_unlink_all(p, TRUE, TRUE);
 		dialog_unref(p,"unref dialog p UNREGISTERED");
 		/* sip_destroy(p); */
@@ -18036,13 +18011,11 @@
 	if (ast_strlen_zero(p->peername) && ext)
 		ast_string_field_set(p, peername, ext);
 	/* Recalculate our side, and recalculate Call ID */
-	ast_log(LOG_NOTICE,"====================================About to build callid for %s\n", p->callid);
 	ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
 	build_via(p);
 	ao2_t_unlink(dialogs,p,"About to change the callid -- remove the old name");
 	build_callid_pvt(p);
 	ao2_t_link(dialogs,p,"Linking in under new name");
-	ast_log(LOG_NOTICE,"====================================New callid: %s\n", p->callid);
 	
 	/* We have an extension to call, don't use the full contact here */
 	/* This to enable dialing registered peers with extension dialling,
@@ -18066,7 +18039,6 @@
 			p->owner? p->owner->name : "", "SIP", p->callid, p->fullcontact, p->peername);
 	sip_pvt_unlock(p);
 	if (!tmpc) {
-		ast_log(LOG_NOTICE,"Calling Sip_Destroy() from call request 3 for %s....\n", p->callid);
 		dialog_unlink_all(p, TRUE, TRUE);
 		/* sip_destroy(p); */
 	}
@@ -18551,7 +18523,6 @@
 {
 	struct sip_peer *peer;
 
-	ast_log(LOG_NOTICE,"Allocating PEER object for the %s\n", name);
 	if (!(peer = ao2_t_alloc(sizeof(*peer), sip_destroy_peer_fn, "allocate a peer struct")))
 		return NULL;
 
@@ -18720,7 +18691,6 @@
 				/* Non-dynamic.  Make sure we become that way if we're not */
 				if (peer->expire > -1)
 				{
-					ast_log(LOG_WARNING,"About to sched_del peer expire(%d) for peer in build_peer near end\n", peer->expire);
 					ast_sched_del(sched, peer->expire);
 				}
 				
@@ -18922,7 +18892,6 @@
 	int registry_count = 0, peer_count = 0, user_count = 0;
 	time_t run_start, run_end;
 	
-	ast_log(LOG_NOTICE,"reload_config begun...\n");
 	run_start = time(0);
 	
 	cfg = ast_config_load(config, config_flags);
@@ -18943,7 +18912,6 @@
 		ucfg = ast_config_load("users.conf", config_flags);
 	}
 
-	ast_log(LOG_NOTICE,"reload_config 2...\n");
 	if (reason != CHANNEL_MODULE_LOAD) {
 		ast_debug(4, "--------------- SIP reload started\n");
 
@@ -18958,7 +18926,6 @@
 			if (iterator->call) {
 				ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
 				/* This will also remove references to the registry */
-				ast_log(LOG_NOTICE,"Calling Sip_Destroy() from reload reg for %s....\n", iterator->call->callid);
 				dialog_unlink_all(iterator->call, TRUE, TRUE);
 				iterator->call = dialog_unref(iterator->call,"remove iterator->call from registry traversal");
 				/* iterator->call = sip_destroy(iterator->call); */
@@ -18977,7 +18944,6 @@
 		users = ao2_t_container_alloc(hash_user_size, user_hash_cb, user_cmp_cb,"allocate users");
 	}
 
-	ast_log(LOG_NOTICE,"reload_config 3...\n");
 	/* Initialize copy of current global_regcontext for later use in removing stale contexts */
 	ast_copy_string(oldcontexts, global_regcontext, sizeof(oldcontexts));
 	oldregcontext = oldcontexts;
@@ -19016,7 +18982,6 @@
 	externexpire = 0;			/* Expiration for DNS re-issuing */
 	externrefresh = 10;
 
-	ast_log(LOG_NOTICE,"reload_config 4...\n");
 	/* Reset channel settings to default before re-configuring */
 	allow_external_domains = DEFAULT_ALLOW_EXT_DOM;				/* Allow external invites */
 	global_regcontext[0] = '\0';
@@ -19086,7 +19051,6 @@
 	ast_clear_flag(&global_flags[1], SIP_PAGE2_VIDEOSUPPORT);
 	ast_clear_flag(&global_flags[1], SIP_PAGE2_TEXTSUPPORT);
 
-	ast_log(LOG_NOTICE,"reload_config 5...\n");
 	/* Read the [general] config section of sip.conf (or from realtime config) */
 	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
 		if (handle_common_options(&global_flags[0], &dummy[0], v))
@@ -19383,7 +19347,6 @@
 		allow_external_domains = 1;
 	}
 	
-	ast_log(LOG_NOTICE,"reload_config 6...\n");
 	/* Build list of authentication to various SIP realms, i.e. service providers */
  	for (v = ast_variable_browse(cfg, "authentication"); v ; v = v->next) {
  		/* Format for authentication is auth = username:password at realm */
@@ -19409,7 +19372,13 @@
 					if (peer) {
 						ast_device_state_changed("SIP/%s", peer->name);
 						ao2_t_link(peers, peer, "link peer into peer table");
-						ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+						if (peer->addr.sin_addr.s_addr) {
+							char buf8[40];
+							addr2str(&peer->addr,buf8);
+							ast_log(LOG_NOTICE,"Inserted %s into peers_by_ip\n", buf8);
+							ao2_t_link(peers_by_ip, peer, "link peer into peers_by_ip table");
+						}
+						
 						unref_peer(peer,"unref_peer: from reload_config");
 						peer_count++;
 					}
@@ -19444,7 +19413,6 @@
 	}
 	
 
-	ast_log(LOG_NOTICE,"reload_config 7...\n");
 	/* Load peers, users and friends */
 	cat = NULL;
 	while ( (cat = ast_category_browse(cfg, cat)) ) {
@@ -19479,14 +19447,18 @@
 				peer = build_peer(cat, ast_variable_browse(cfg, cat), NULL, 0);
 				if (peer) {
 					ao2_t_link(peers, peer,"link peer into peers table");
-					ao2_t_link(peers_by_ip, peer,"link peer into peers_by_ip table");
+					if (peer->addr.sin_addr.s_addr) {
+						char buf8[40];
+						addr2str(&peer->addr,buf8);
+						ast_log(LOG_NOTICE,"Inserted %s into peers_by_ip\n", buf8);
+						ao2_t_link(peers_by_ip, peer,"link peer into peers_by_ip table");
+					}
 					unref_peer(peer,"unref_peer: reload_config: just linked peer to two tables, peers and peers_by_ip");
 					peer_count++;
 				}
 			}
 		}
 	}
-	ast_log(LOG_NOTICE,"reload_config 8...\n");
 	bindaddr.sin_family = AF_INET;
 	internip = bindaddr;
 	if (ast_find_ourip(&internip.sin_addr, bindaddr)) {
@@ -19536,7 +19508,6 @@
 		ast_debug(1, "STUN sees us at %s:%d\n", 
 			ast_inet_ntoa(externip.sin_addr) , ntohs(externip.sin_port));
 	}
-	ast_log(LOG_NOTICE,"reload_config 9...\n");
 	ast_mutex_unlock(&netlock);
 
 	/* Add default domains - host name, IP address and IP:port */

[... 106 lines stripped ...]



More information about the asterisk-commits mailing list