[asterisk-commits] murf: branch murf/bug11210 r103749 - /team/murf/bug11210/channels/chan_iax2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Feb 16 13:19:39 CST 2008


Author: murf
Date: Sat Feb 16 13:19:38 2008
New Revision: 103749

URL: http://svn.digium.com/view/asterisk?view=rev&rev=103749
Log:
checkpoint-- instrumented chan_iax for refcounting

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

Modified: team/murf/bug11210/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_iax2.c?view=diff&rev=103749&r1=103748&r2=103749
==============================================================================
--- team/murf/bug11210/channels/chan_iax2.c (original)
+++ team/murf/bug11210/channels/chan_iax2.c Sat Feb 16 13:19:38 2008
@@ -86,6 +86,12 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/event.h"
+/*
+  Define REF_DEBUG below, if you are having trouble with memory leaks
+  that might arise from undestroyed astobj2 objects... or, another problem
+  might be crashes during the destruction of astobj2 objects, which could
+  be a symptom of the object being destroyed multiple times.
+*/
 #define  REF_DEBUG 1
 #include "asterisk/astobj2.h"
 
@@ -734,10 +740,10 @@
 	struct ao2_iterator i;
 	struct chan_iax2_pvt *pvt;
 	i = ao2_iterator_init(findcall1, 0);
-	while ( (pvt = ao2_iterator_next(&i))) {
+	while ( (pvt = ao2_t_iterator_next(&i,"iterate thru findcall1 members"))) {
 		ast_log(LOG_NOTICE,"findcall1: addr=%s, port=%d, callno = %d, peercallno=%d\n", 
 				ast_inet_ntoa(pvt->addr.sin_addr), ntohs(pvt->addr.sin_port), pvt->callno, pvt->peercallno);
-		ao2_ref(pvt, -1);
+		call_unref(pvt, "release ptr obtained from iterator_next");
 	}
 }
 
@@ -746,10 +752,10 @@
 	struct ao2_iterator i;
 	struct chan_iax2_pvt *pvt;
 	i = ao2_iterator_init(findcall2, 0);
-	while ( (pvt = ao2_iterator_next(&i))) {
+	while ( (pvt = ao2_t_iterator_next(&i,"iterate thru findcall2 members"))) {
 		ast_log(LOG_NOTICE,"findcall2: addr=%s, port=%d, callno = %d, peercallno=%d\n", 
 				ast_inet_ntoa(pvt->addr.sin_addr), ntohs(pvt->addr.sin_port), pvt->callno, pvt->peercallno);
-		ao2_ref(pvt, -1);
+		call_unref(pvt, "release ptr obtained from iterator_next");
 	}
 }
 
@@ -758,10 +764,10 @@
 	struct ao2_iterator i;
 	struct chan_iax2_pvt *pvt;
 	i = ao2_iterator_init(findcall3, 0);
-	while ( (pvt = ao2_iterator_next(&i))) {
+	while ( (pvt = ao2_t_iterator_next(&i,"iterate thru findcall3 members"))) {
 		ast_log(LOG_NOTICE,"findcall3: transfer=%s, port=%d, callno = %d, transfercallno=%d\n", 
 				ast_inet_ntoa(pvt->addr.sin_addr), ntohs(pvt->addr.sin_port), pvt->callno, pvt->transfercallno);
-		ao2_ref(pvt, -1);
+		call_unref(pvt, "release ptr obtained from iterator_next");
 	}
 }
 
@@ -770,10 +776,10 @@
 	struct ao2_iterator i;
 	struct chan_iax2_pvt *pvt;
 	i = ao2_iterator_init(findcall4, 0);
-	while ( (pvt = ao2_iterator_next(&i))) {
+	while ( (pvt = ao2_t_iterator_next(&i,"iterate thru findcall4 members"))) {
 		ast_log(LOG_NOTICE,"findcall4: transfer=%s, port=%d, callno = %d, transfercallno=%d\n", 
 				ast_inet_ntoa(pvt->addr.sin_addr), ntohs(pvt->addr.sin_port), pvt->callno, pvt->transfercallno);
-		ao2_ref(pvt, -1);
+		call_unref(pvt, "release ptr obtained from iterator_next");
 	}
 }
 #endif
@@ -1506,7 +1512,7 @@
 		.name = name,
 	};
 
-	peer = ao2_find(peers, &tmp_peer, OBJ_POINTER);
+	peer = ao2_t_find(peers, &tmp_peer, OBJ_POINTER,"Find member of peers table");
 
 	/* Now go for realtime if applicable */
 	if(!peer && realtime)
@@ -1515,29 +1521,89 @@
 	return peer;
 }
 
-static struct iax2_peer *peer_ref(struct iax2_peer *peer)
+#ifdef REF_DEBUG
+#define call_ref(arg1,arg2) call_ref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define call_unref(arg1,arg2) call_unref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define peer_ref(arg1,arg2) peer_ref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define peer_unref(arg1,arg2) peer_unref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define user_ref(arg1,arg2) user_ref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define user_unref(arg1,arg2) user_unref_debug((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+static struct iax2_peer *peer_ref_debug(struct iax2_peer *peer, char *tag, char *file, int line, const char *func)
+{
+	ao2_ref_debug(peer, +1, tag, file, line, func);
+	return peer;
+}
+
+static inline struct iax2_peer *peer_unref_debug(struct iax2_peer *peer, char *tag, char *file, int line, const char *func)
+{
+	ao2_ref_debug(peer, -1, tag, file, line, func);
+	return NULL;
+}
+
+static inline struct iax2_user *user_ref_debug(struct iax2_user *user, char *tag, char *file, int line, const char *func)
+{
+	ao2_ref_debug(user, +1, tag, file, line, func);
+	return user;
+}
+
+static inline struct iax2_user *user_unref_debug(struct iax2_user *user, char *tag, char *file, int line, const char *func)
+{
+	ao2_ref_debug(user, -1, tag, file, line, func);
+	return NULL;
+}
+
+static inline struct chan_iax2_pvt *call_ref_debug(struct chan_iax2_pvt *call, char *tag, char *file, int line, const char *func)
+{
+	ao2_ref_debug(call, +1, tag, file, line, func);
+	return call;
+}
+
+static inline struct chan_iax2_pvt *call_unref_debug(struct chan_iax2_pvt *call, char *tag, char *file, int line, const char *func)
+{
+	ao2_ref_debug(call, -1, tag, file, line, func);
+	return NULL;
+}
+
+#else
+
+static struct iax2_peer *peer_ref(struct iax2_peer *peer, char *tag)
 {
 	ao2_ref(peer, +1);
 	return peer;
 }
 
-static inline struct iax2_peer *peer_unref(struct iax2_peer *peer)
+static inline struct iax2_peer *peer_unref(struct iax2_peer *peer, char *tag)
 {
 	ao2_ref(peer, -1);
 	return NULL;
 }
 
-static inline struct iax2_user *user_ref(struct iax2_user *user)
+static inline struct iax2_user *user_ref(struct iax2_user *user, char *tag)
 {
 	ao2_ref(user, +1);
 	return user;
 }
 
-static inline struct iax2_user *user_unref(struct iax2_user *user)
+static inline struct iax2_user *user_unref(struct iax2_user *user, char *tag)
 {
 	ao2_ref(user, -1);
 	return NULL;
 }
+
+static inline struct chan_iax2_pvt *call_ref(struct chan_iax2_pvt *call, char *tag)
+{
+	ao2_ref(user, +1);
+	return call;
+}
+
+static inline struct chan_iax2_pvt *call_unref(struct chan_iax2_pvt *call, char *tag)
+{
+	ao2_ref(call, -1);
+	return NULL;
+}
+
+#endif
 
 static int iax2_getpeername(struct sockaddr_in sin, char *host, int len)
 {
@@ -1546,22 +1612,22 @@
 	struct ao2_iterator i;
 
 	i = ao2_iterator_init(peers, 0);
-	while ((peer = ao2_iterator_next(&i))) {
+	while ((peer = ao2_t_iterator_next(&i,"iterate for peer by IP in peers table"))) {
 		if ((peer->addr.sin_addr.s_addr == sin.sin_addr.s_addr) &&
 		    (peer->addr.sin_port == sin.sin_port)) {
 			ast_copy_string(host, peer->name, len);
-			peer_unref(peer);
+			peer_unref(peer, "Release iterator returned pointer-- Found the entry");
 			res = 1;
 			break;
 		}
-		peer_unref(peer);
+		peer_unref(peer, "release iterator returned pointer-- not found");
 	}
 
 	if (!peer) {
 		peer = realtime_peer(NULL, &sin);
 		if (peer) {
 			ast_copy_string(host, peer->name, len);
-			peer_unref(peer);
+			peer_unref(peer, "release pointer obtained from realtime peer");
 			res = 1;
 		}
 	}
@@ -1578,7 +1644,7 @@
 		return NULL;
 
 	if (ast_string_field_init(tmp, 32)) {
-		ao2_t_ref(tmp,-1,"string field init fails-- toss the newly allocated pvt");
+		call_unref(tmp, "string field init fails-- toss the newly allocated pvt");
 		tmp = NULL;
 		return NULL;
 	}
@@ -1704,7 +1770,7 @@
 #define CHECK_LINK_E  if (!zzq) ast_log(LOG_WARNING,"ao2_link failure! Check this out!");}
 			if (iaxs[x]->peercallno == 0)
 				CHECK_LINK_B
-				ao2_t_link(findcall2, iaxs[x], "moved to new pvt callno in trunk range");
+				ao2_t_link(findcall2, iaxs[x], "relink to new pvt callno in trunk range");
 				CHECK_LINK_E
 			/* Update the two timers that should have been started */
 			iaxs[x]->pingid = iax2_sched_replace(iaxs[x]->pingid, sched, 
@@ -1876,11 +1942,11 @@
 			ast_string_field_set(iaxs[x], mohinterpret, mohinterpret);
 			ast_string_field_set(iaxs[x], mohsuggest, mohsuggest);
 			CHECK_LINK_B
-			ao2_t_link(findcall1, iaxs[x], "a new pvt is borne!");
+			ao2_t_link(findcall1, iaxs[x], "a new pvt is borne! linked into findcall1");
 			CHECK_LINK_E
 			if (iaxs[x]->peercallno == 0)
 				CHECK_LINK_B
-			    ao2_t_link(findcall2, iaxs[x], "a new pvt is borne!");
+			    ao2_t_link(findcall2, iaxs[x], "a new pvt is borne! linked into findcall2");
 			    CHECK_LINK_E
 			/* it appears that findcall3 and findcall4 will not be linked, as the transferring field is 0 */
 		} else {
@@ -2360,10 +2426,10 @@
 			.name = pvt->username,
 		};
 
-		user = ao2_find(users, &tmp_user, OBJ_POINTER);
+		user = ao2_t_find(users, &tmp_user, OBJ_POINTER, "find user in users");
 		if (user) {
 			ast_atomic_fetchadd_int(&user->curauthreq, -1);
-			user_unref(user);	
+			user_unref(user, "release user pointer obtained from find");	
 		}
 
 		ast_clear_flag(pvt, IAX_MAXAUTHREQ);
@@ -2403,7 +2469,7 @@
 		ast_log(LOG_NOTICE,"predestroy: channel has pvt index of %d (%p)\n", zz, pvt);
 		c->tech_pvt = NULL;
 		if (pvt)
-			ao2_t_ref(pvt,-1,"Nulled out the index stored in the channel");
+			call_ref(pvt, "Nulled out the pvt index stored in the channel");
 		
 		ast_log(LOG_NOTICE,"predestroy: about to force hangup for callno %d, then null out pvt->owner field\n", callno);
 		
@@ -2451,21 +2517,23 @@
 	struct ast_channel *owner = NULL;
 	ast_log(LOG_NOTICE,"Iax2_unlink called for %d\n", callno);
 	pvt = iaxs[callno];
+
+	if (pvt)
+		call_ref(pvt, "Bumping refcount for unlink... don't want pvt to dissappear until all the fields are inactivated");
+
 	if (pvt)
 	{
-		ao2_t_unlink(findcall1,pvt,"remove from findcall1 table");
+		ao2_t_unlink(findcall1,pvt,"remove (unlink) from findcall1 table");
 		if (!pvt->peercallno)
-			ao2_t_unlink(findcall2,pvt,"remove from findcall2 table");
+			ao2_t_unlink(findcall2,pvt,"remove (unlink) from findcall2 table");
 		if (pvt->transferring)
-			ao2_t_unlink(findcall3,pvt,"remove from the findcall3 table");
+			ao2_t_unlink(findcall3,pvt,"remove from (unlink) the findcall3 table");
 		if (pvt->transferring == TRANSFER_MEDIAPASS)
-			ao2_t_unlink(findcall4,pvt,"remove from the findcall4 table");
+			ao2_t_unlink(findcall4,pvt,"remove (unlink) from the findcall4 table");
 	}
 	lastused[callno] = ast_tvnow();
 	
 retry:
-	if (pvt)
-		ao2_t_ref(pvt,1,"adding to refcount for unlink... don't want pvt to dissappear until all the fields are inactivated");
 	owner = pvt ? pvt->owner : NULL;
 
 	if (owner) {
@@ -2474,8 +2542,6 @@
 			ast_mutex_unlock(&iaxsl[callno]);
 			usleep(1);
 			ast_mutex_lock(&iaxsl[callno]);
-			if (pvt)
-				ao2_t_ref(pvt,-1,"we are going to re-get the pvt ptr... decrement here");
 			goto retry;
 		}
 	}
@@ -2526,7 +2592,7 @@
 		iaxs[callno] = NULL;
 	}
 	if (pvt)
-		ao2_t_ref(pvt,-1, "done with the pvt ptr in the unlink routine");
+		ao2_t_ref(pvt,-1, "Unbumping the pvt ptr in the unlink routine to allow destruction");
 	if (callno & 0x4000)
 		update_max_trunk();
 	
@@ -2733,12 +2799,12 @@
 	} else if ((peer = find_peer(a->argv[3], 0))) {
 		if(ast_test_flag(peer, IAX_RTCACHEFRIENDS)) {
 			ast_set_flag(peer, IAX_RTAUTOCLEAR);
-			expire_registry(peer_ref(peer));
+			expire_registry(peer_ref(peer,"passing peer into expire_registry"));
 			ast_cli(a->fd, "Peer %s was removed from the cache.\n", a->argv[3]);
 		} else {
 			ast_cli(a->fd, "Peer %s is not eligible for this operation.\n", a->argv[3]);
 		}
-		peer_unref(peer);
+		peer_unref(peer, "toss peer ptr from find_peer call");
 	} else {
 		ast_cli(a->fd, "Peer %s was not found in the cache.\n", a->argv[3]);
 	}
@@ -2921,7 +2987,7 @@
 		ast_cli(a->fd, "%s\n",status);
 		ast_cli(a->fd, "  Qualify      : every %dms when OK, every %dms when UNREACHABLE (sample smoothing %s)\n", peer->pokefreqok, peer->pokefreqnotok, peer->smoothing ? "On" : "Off");
 		ast_cli(a->fd, "\n");
-		peer_unref(peer);
+		peer_unref(peer, "toss ptr from find_peer call");
 	} else {
 		ast_cli(a->fd, "Peer %s not found.\n", a->argv[3]);
 		ast_cli(a->fd, "\n");
@@ -2943,13 +3009,13 @@
 		return NULL;
 
 	i = ao2_iterator_init(peers, 0);
-	while ((peer = ao2_iterator_next(&i))) {
+	while ((peer = ao2_t_iterator_next(&i,"iterate next element in peer table"))) {
 		if (!strncasecmp(peer->name, word, wordlen) && ++which > state) {
 			res = ast_strdup(peer->name);
-			peer_unref(peer);
+			peer_unref(peer, "release peer ptr from iterate_next");
 			break;
 		}
-		peer_unref(peer);
+		peer_unref(peer, "toss peer ptr from iterate_next");
 	}
 
 	return res;
@@ -3451,7 +3517,7 @@
 			if (strcasecmp(tmp->value, "friend") &&
 			    strcasecmp(tmp->value, "peer")) {
 				/* Whoops, we weren't supposed to exist! */
-				peer = peer_unref(peer);
+				peer = peer_unref(peer, "toss peer ptr that isn't supposed to exist");
 				break;
 			} 
 		} else if (!strcasecmp(tmp->name, "regseconds")) {
@@ -3477,14 +3543,14 @@
  			if (peer->expire > -1) {
  				if (!ast_sched_del(sched, peer->expire)) {
  					peer->expire = -1;
- 					peer_unref(peer);
+ 					peer_unref(peer, "toss sched-del for peer->expire peer ptr");
  				}
  			}
- 			peer->expire = iax2_sched_add(sched, (global_rtautoclear) * 1000, expire_registry, peer_ref(peer));
+ 			peer->expire = iax2_sched_add(sched, (global_rtautoclear) * 1000, expire_registry, peer_ref(peer,"passing peer ptr into sched-add expire_registry"));
  			if (peer->expire == -1)
- 				peer_unref(peer);
-		}
-		ao2_link(peers, peer);
+ 				peer_unref(peer, "toss unsuccessful sched-add peer ptr for expire_registry");
+		}
+		ao2_t_link(peers, peer,"link peer into peers table");
 		if (ast_test_flag(peer, IAX_DYNAMIC))
 			reg_source_db(peer);
 	} else {
@@ -3572,7 +3638,7 @@
 
 	if (ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS)) {
 		ast_set_flag(user, IAX_RTCACHEFRIENDS);
-		ao2_link(users, user);
+		ao2_t_link(users, user, "Link user into users table");
 	} else {
 		ast_set_flag(user, IAX_TEMPONLY);	
 	}
@@ -3695,7 +3761,7 @@
 	res = 0;
 
 return_unref:
-	peer_unref(peer);
+	peer_unref(peer, "toss peer ptr from find_peer");
 
 	return res;
 }
@@ -4340,14 +4406,14 @@
 	struct ao2_iterator i;
 
 	i = ao2_iterator_init(peers, 0);
-	while ((peer = ao2_iterator_next(&i))) {
+	while ((peer = ao2_t_iterator_next(&i,"Iterate thru peers table looking for IP addr"))) {
 		if ((peer->addr.sin_addr.s_addr == sin.sin_addr.s_addr) &&
 		    (peer->addr.sin_port == sin.sin_port)) {
 			res = ast_test_flag(peer, IAX_TRUNK);
-			peer_unref(peer);
+			peer_unref(peer, "release matching iterated member peer ptr");
 			break;
 		}
-		peer_unref(peer);
+		peer_unref(peer, "release non-matching iterated member peer ptr");
 	}
 
 	return res;
@@ -5116,8 +5182,8 @@
 
 	ast_cli(a->fd, FORMAT, "Username", "Secret", "Authen", "Def.Context", "A/C","Codec Pref");
 	i = ao2_iterator_init(users, 0);
-	for (user = ao2_iterator_next(&i); user; 
-		user_unref(user), user = ao2_iterator_next(&i)) {
+	for (user = ao2_t_iterator_next(&i,"Got iterated user ptr"); user; 
+		 user_unref(user, "release iterated user ptr"), user = ao2_t_iterator_next(&i,"Got another iterated user ptr")) {
 		if (havepattern && regexec(&regexbuf, user->name, 0, NULL, 0))
 			continue;
 		
@@ -5204,8 +5270,8 @@
 		ast_cli(fd, FORMAT2, "Name/Username", "Host", "   ", "Mask", "Port", "   ", "Status", term);
 
 	i = ao2_iterator_init(peers, 0);
-	for (peer = ao2_iterator_next(&i); peer; 
-		peer_unref(peer), peer = ao2_iterator_next(&i)) {
+	for (peer = ao2_t_iterator_next(&i,"Got iterated peer ptr"); peer; 
+		 peer_unref(peer, "releasing iterated peer ptr"), peer = ao2_t_iterator_next(&i,"Got another iterated peer ptr")) {
 		char nm[20];
 		char status[20];
 		char srch[2000];
@@ -5371,10 +5437,10 @@
 			};
 			struct iax2_peer *peer;
 
-			peer = ao2_find(peers, &tmp_peer, OBJ_POINTER);
+			peer = ao2_t_find(peers, &tmp_peer, OBJ_POINTER, "Find peer in peers table");
 			if (peer) {
-				expire_registry(peer_ref(peer)); /* will release its own reference when done */
-				peer_unref(peer); /* ref from ao2_find() */
+				expire_registry(peer_ref(peer,"pass peer ptr in expire_registry")); /* will release its own reference when done */
+				peer_unref(peer, "release ptr obtained from ao2_find"); /* ref from ao2_find() */
 				ast_cli(a->fd, "Peer %s unregistered\n", a->argv[2]);
 			} else {
 				ast_cli(a->fd, "Peer %s not found\n", a->argv[2]);
@@ -5398,14 +5464,14 @@
 	/* 0 - iax2; 1 - unregister; 2 - <peername> */
 	if (pos == 2) {
 		struct ao2_iterator i = ao2_iterator_init(peers, 0);
-		while ((p = ao2_iterator_next(&i))) {
+		while ((p = ao2_t_iterator_next(&i,"iterated member of peers table, search for matching name"))) {
 			if (!strncasecmp(p->name, word, wordlen) && 
 				++which > state && p->expire > 0) {
 				res = ast_strdup(p->name);
-				peer_unref(p);
+				peer_unref(p, "release matched iterated peer ptr");
 				break;
 			}
-			peer_unref(p);
+			peer_unref(p, "release unmatched iterated peer ptr");
 		}
 	}
 
@@ -5506,7 +5572,7 @@
 
 
 	i = ao2_iterator_init(peers, 0);
-	for (peer = ao2_iterator_next(&i); peer; peer_unref(peer), peer = ao2_iterator_next(&i)) {
+	for (peer = ao2_t_iterator_next(&i,"iterated peer ptr"); peer; peer_unref(peer, "release iterator peer ptr"), peer = ao2_t_iterator_next(&i,"Next iterated peer ptr")) {
 
 		astman_append(s, "Event: PeerEntry\r\n%sChanneltype: IAX\r\n", idtext);
 		if (!ast_strlen_zero(peer->username)) {
@@ -6065,7 +6131,7 @@
 	}
 	/* Search the userlist for a compatible entry, and fill in the rest */
 	i = ao2_iterator_init(users, 0);
-	while ((user = ao2_iterator_next(&i))) {
+	while ((user = ao2_t_iterator_next(&i,"iterated user ptr"))) {
 		if ((ast_strlen_zero(iaxs[callno]->username) ||				/* No username specified */
 			!strcmp(iaxs[callno]->username, user->name))	/* Or this username specified */
 			&& ast_apply_ha(user->ha, sin) 	/* Access is permitted from this IP */
@@ -6074,7 +6140,7 @@
 			if (!ast_strlen_zero(iaxs[callno]->username)) {
 				/* Exact match, stop right now. */
 				if (best)
-					user_unref(best);
+					user_unref(best, "release iterated user ptr");
 				best = user;
 				break;
 			} else if (ast_strlen_zero(user->secret) && ast_strlen_zero(user->dbsecret) && ast_strlen_zero(user->inkeys)) {
@@ -6084,7 +6150,7 @@
 					if (bestscore < 4) {
 						bestscore = 4;
 						if (best)
-							user_unref(best);
+							user_unref(best, "release iterated user ptr");
 						best = user;
 						continue;
 					}
@@ -6093,7 +6159,7 @@
 					if (bestscore < 3) {
 						bestscore = 3;
 						if (best)
-							user_unref(best);
+							user_unref(best, "release iterated user ptr");
 						best = user;
 						continue;
 					}
@@ -6104,7 +6170,7 @@
 					if (bestscore < 2) {
 						bestscore = 2;
 						if (best)
-							user_unref(best);
+							user_unref(best, "release iterated user ptr");
 						best = user;
 						continue;
 					}
@@ -6113,21 +6179,21 @@
 					if (bestscore < 1) {
 						bestscore = 1;
 						if (best)
-							user_unref(best);
+							user_unref(best, "release iterated user ptr");
 						best = user;
 						continue;
 					}
 				}
 			}
 		}
-		user_unref(user);
+		user_unref(user, "release iterated user ptr");
 	}
 	user = best;
 	if (!user && !ast_strlen_zero(iaxs[callno]->username)) {
 		user = realtime_user(iaxs[callno]->username, sin);
 		if (user && !ast_strlen_zero(iaxs[callno]->context) &&			/* No context specified */
 		    !apply_context(user->contexts, iaxs[callno]->context)) {		/* Context is permitted */
-			user = user_unref(user);
+			user = user_unref(user, "release user ptr obtained from realtime_user");
 		}
 	}
 	if (user) {
@@ -6207,7 +6273,7 @@
 		} else
 			ast_string_field_set(iaxs[callno], secret, user->secret);
 		res = 0;
-		user = user_unref(user);
+		user = user_unref(user, "toss user ptr from iterated search or from realtime_user call");
 	}
 	ast_set2_flag(iaxs[callno], iax2_getpeertrunk(*sin), IAX_TRUNK);	
 	return res;
@@ -6266,13 +6332,13 @@
 			.name = p->username,	
 		};
 
-		user = ao2_find(users, &tmp_user, OBJ_POINTER);
+		user = ao2_t_find(users, &tmp_user, OBJ_POINTER, "Find user in users table");
 		if (user) {
 			if (user->curauthreq == user->maxauthreq)
 				authreq_restrict = 1;
 			else
 				user->curauthreq++;
-			user = user_unref(user);
+			user = user_unref(user, "release user found in users table");
 		}
 	}
 
@@ -6316,14 +6382,14 @@
 		.name = p->username,	
 	};
 
-	user = ao2_find(users, &tmp_user, OBJ_POINTER);
+	user = ao2_t_find(users, &tmp_user, OBJ_POINTER, "find user in users table");
 	if (user) {
 		if (ast_test_flag(p, IAX_MAXAUTHREQ)) {
 			ast_atomic_fetchadd_int(&user->curauthreq, -1);
 			ast_clear_flag(p, IAX_MAXAUTHREQ);
 		}
 		ast_string_field_set(p, host, user->name);
-		user = user_unref(user);
+		user = user_unref(user, "release found user ptr");
 	}
 
 	if (!ast_test_flag(&p->state, IAX_STATE_AUTHENTICATED))
@@ -6511,7 +6577,7 @@
 
 return_unref:
 	if (p)
-		peer_unref(p);
+		peer_unref(p, "toss peer ptr from find_peer call");
 
 	return res;
 }
@@ -6601,7 +6667,7 @@
 		res = authenticate(p->challenge, override, okey, authmethods, &ied, sin, &p->ecx, &p->dcx);
 	} else {
 		struct ao2_iterator i = ao2_iterator_init(peers, 0);
-		while ((peer = ao2_iterator_next(&i))) {
+		while ((peer = ao2_t_iterator_next(&i, "iterate in peer table"))) {
 			if ((ast_strlen_zero(p->peer) || !strcmp(p->peer, peer->name)) 
 			    /* No peer specified at our end, or this is the peer */
 			    && (ast_strlen_zero(peer->username) || (!strcmp(peer->username, p->username)))
@@ -6611,11 +6677,11 @@
 				) {
 				res = authenticate(p->challenge, peer->secret, peer->outkey, authmethods, &ied, sin, &p->ecx, &p->dcx);
 				if (!res) {
-					peer_unref(peer);
+					peer_unref(peer, "release matching iterated peer");
 					break;
 				}
 			}
-			peer_unref(peer);
+			peer_unref(peer, "release non-matching iterated peer ptr");
 		}
 		if (!peer) {
 			/* We checked our list and didn't find one.  It's unlikely, but possible, 
@@ -6625,11 +6691,11 @@
 			if ((peer = realtime_peer(peer_name, NULL))) {
 				ast_mutex_lock(&iaxsl[callno]);
 				if (!(p = iaxs[callno])) {
-					peer_unref(peer);
+					peer_unref(peer, "release peer ptr from realtime_peer call");
 					return -1;
 				}
 				res = authenticate(p->challenge, peer->secret,peer->outkey, authmethods, &ied, sin, &p->ecx, &p->dcx);
-				peer_unref(peer);
+				peer_unref(peer, "toss peer ptr from realtime_peer call");
 			}
 			if (!peer) {
 				ast_mutex_lock(&iaxsl[callno]);
@@ -6996,18 +7062,18 @@
 	if (peer->expire > -1) {
 		if (!ast_sched_del(sched, peer->expire)) {
 			peer->expire = -1;
-			peer_unref(peer);
+			peer_unref(peer, "toss peer ptr from sched-del of peer->expire");
 		}
 	}
 
 	if (peer->pokeexpire > -1) {
 		if (!ast_sched_del(sched, peer->pokeexpire)) {
 			peer->pokeexpire = -1;
-			peer_unref(peer);
-		}
-	}
-
-	ao2_unlink(peers, peer);
+			peer_unref(peer, "toss peer ptr from sched-del of peer->pokeexpire");
+		}
+	}
+
+	ao2_t_unlink(peers, peer, "unlink peer from peers table");
 }
 
 static void __expire_registry(const void *data)
@@ -7037,7 +7103,7 @@
 	if (ast_test_flag(peer, IAX_RTAUTOCLEAR))
 		unlink_peer(peer);
 
-	peer_unref(peer);
+	peer_unref(peer, "release peer ptr stored via sched-add at end of scheduled callback __expire_registry");
 }
 
 static int expire_registry(const void *data)
@@ -7077,13 +7143,13 @@
  					if (p->expire > -1) {
  						if (!ast_sched_del(sched, p->expire)) {
  							p->expire = -1;
- 							peer_unref(p);
+ 							peer_unref(p, "toss peer ptr via sched-del of p->expire");
  						}
  					}
   					ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
- 					p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, peer_ref(p));
+ 					p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, peer_ref(p, "passing peer ptr into sched-add of expire_registry"));
  					if (p->expire == -1)
- 						peer_unref(p);
+ 						peer_unref(p, "toss peer ptr via unsuccessful sched-add to expire_registry");
 					if (iax2_regfunk)
 						iax2_regfunk(p->name, 1);
 					register_peer_exten(p, 1);
@@ -7173,7 +7239,7 @@
 	if (p->expire > -1) {
 		if (!ast_sched_del(sched, p->expire)) {
 			p->expire = -1;
-			peer_unref(p);
+			peer_unref(p, "toss peer ptr from sched-del of p->exire");
 		}
 	}
 	/* treat an unspecified refresh interval as the minimum */
@@ -7191,9 +7257,9 @@
 		p->expiry = refresh;
 	}
 	if (p->expiry && sin->sin_addr.s_addr) {
-		p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, peer_ref(p));
+		p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, peer_ref(p, "passing peer ptr into expire_registry"));
 		if (p->expire == -1)
-			peer_unref(p);
+			peer_unref(p, "toss peer ptr from unsuccessful sched-add for expire_registry");
 	}
 	iax_ie_append_str(&ied, IAX_IE_USERNAME, p->name);
 	iax_ie_append_int(&ied, IAX_IE_DATETIME, iax2_datetime(p->zonetag));
@@ -7243,7 +7309,7 @@
 	res = 0;
 
 return_unref:
-	peer_unref(p);
+	peer_unref(p, "toss peer ptr from find_peer call");
 
 	return res ? res : send_command_final(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_REGACK, 0, ied.buf, ied.pos, -1);
 }
@@ -7282,7 +7348,7 @@
 	res = 0;
 
 return_unref:
-	peer_unref(p);
+	peer_unref(p, "toss peer ptr from find_peer call");
 
 	return res ? res : send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_REGAUTH, 0, ied.buf, ied.pos, -1);;
 }
@@ -7455,7 +7521,7 @@
 {
 	struct iax2_peer *peer = (struct iax2_peer *)data;
 	iax2_poke_peer(peer, 0);
-	peer_unref(peer);
+	peer_unref(peer, "toss peer ptr at end of iax2_poke_peer callback");
 }
 
 static int iax2_poke_peer_s(const void *data)
@@ -9078,17 +9144,17 @@
 					/* Remove scheduled iax2_poke_noanswer */
 					if (peer->pokeexpire > -1) {
 						if (!ast_sched_del(sched, peer->pokeexpire)) {
-							peer_unref(peer);
+							peer_unref(peer, "toss peer ptr from sched-del peer->pokeexpire");
 							peer->pokeexpire = -1;
 						}
 					}
 					/* Schedule the next cycle */
 					if ((peer->lastms < 0)  || (peer->historicms > peer->maxms)) 
-						peer->pokeexpire = iax2_sched_add(sched, peer->pokefreqnotok, iax2_poke_peer_s, peer_ref(peer));
+						peer->pokeexpire = iax2_sched_add(sched, peer->pokefreqnotok, iax2_poke_peer_s, peer_ref(peer,"passing peer ptr into sched-add iax2_poke_peer_s"));
 					else
-						peer->pokeexpire = iax2_sched_add(sched, peer->pokefreqok, iax2_poke_peer_s, peer_ref(peer));
+						peer->pokeexpire = iax2_sched_add(sched, peer->pokefreqok, iax2_poke_peer_s, peer_ref(peer, "passing peer ptr into sched-add iax2_poke_peer_s"));
 					if (peer->pokeexpire == -1)
-						peer_unref(peer);
+						peer_unref(peer, "toss peer ptr from unsuccessful sched-add for iax2_poke_peer_s");
 					/* and finally send the ack */
 					send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
 					/* And wrap up the qualify call */
@@ -10077,9 +10143,9 @@
 	peer->callno = 0;
 	peer->lastms = -1;
 	/* Try again quickly */
-	peer->pokeexpire = iax2_sched_add(sched, peer->pokefreqnotok, iax2_poke_peer_s, peer_ref(peer));
+	peer->pokeexpire = iax2_sched_add(sched, peer->pokefreqnotok, iax2_poke_peer_s, peer_ref(peer,"sched-add iax2_poke_peer_s"));
 	if (peer->pokeexpire == -1)
-		peer_unref(peer);
+		peer_unref(peer, "tossing peer ptr from unsuccessful sched-add call for iax2_poke_peer_s");
 }
 
 static int iax2_poke_noanswer(const void *data)
@@ -10090,7 +10156,7 @@
 	if (schedule_action(__iax2_poke_noanswer, data))
 #endif		
 		__iax2_poke_noanswer(data);
-	peer_unref(peer);
+	peer_unref(peer, "toss peer ptr from non-rescheduled sched'd calback iax2_poke_noanser");
 	return 0;
 }
 
@@ -10139,19 +10205,19 @@
  	if (peer->pokeexpire > -1) {
  		if (!ast_sched_del(sched, peer->pokeexpire)) {
  			peer->pokeexpire = -1;
- 			peer_unref(peer);
+ 			peer_unref(peer, "toss peer ptr from sched-del of peer->pokeexpire");
  		}
  	}
  
 	/* Queue up a new task to handle no reply */
 	/* If the host is already unreachable then use the unreachable interval instead */
 	if (peer->lastms < 0)
- 		peer->pokeexpire = iax2_sched_add(sched, peer->pokefreqnotok, iax2_poke_noanswer, peer_ref(peer));
+ 		peer->pokeexpire = iax2_sched_add(sched, peer->pokefreqnotok, iax2_poke_noanswer, peer_ref(peer, "passing peer ptr to sched-add of iax2_poke_noanswer"));
 	else
- 		peer->pokeexpire = iax2_sched_add(sched, DEFAULT_MAXMS * 2, iax2_poke_noanswer, peer_ref(peer));
+ 		peer->pokeexpire = iax2_sched_add(sched, DEFAULT_MAXMS * 2, iax2_poke_noanswer, peer_ref(peer, "passing peer ptr to sched-add of iax2_poke_noanswer"));
 
  	if (peer->pokeexpire == -1)
- 		peer_unref(peer);
+ 		peer_unref(peer, "tossing peer ptr from unsuccessful sched-add call");
 
 	/* And send the poke */
 	send_command(iaxs[peer->callno], AST_FRAME_IAX, IAX_COMMAND_POKE, 0, NULL, 0, -1);
@@ -10533,7 +10599,7 @@
 	};
 
 	if (!temponly) {
-		peer = ao2_find(peers, &tmp_peer, OBJ_POINTER);
+		peer = ao2_t_find(peers, &tmp_peer, OBJ_POINTER, "find peer in peers");
 		if (peer && !ast_test_flag(peer, IAX_DELME))
 			firstpass = 0;
 	}
@@ -10545,12 +10611,12 @@
 			peer->ha = NULL;
 		}
 		unlink_peer(peer);
-	} else if ((peer = ao2_alloc(sizeof(*peer), peer_destructor))) {
+	} else if ((peer = ao2_t_alloc(sizeof(*peer), peer_destructor, "allocate a neew peer"))) {
 		peer->expire = -1;
 		peer->pokeexpire = -1;
 		peer->sockfd = defaultsockfd;
 		if (ast_string_field_init(peer, 32))
-			peer = peer_unref(peer);
+			peer = peer_unref(peer, "toss peer ptr from unsuccessful string_field_init call");
 	}
 
 	if (peer) {
@@ -10631,7 +10697,7 @@
 					AST_SCHED_DEL(sched, peer->expire);
 					ast_clear_flag(peer, IAX_DYNAMIC);
 					if (ast_dnsmgr_lookup(v->value, &peer->addr.sin_addr, &peer->dnsmgr))
-						return peer_unref(peer);
+						return peer_unref(peer, "toss peer ptr from bad dnsmgr_lookup call");
 					if (!peer->addr.sin_port)
 						peer->addr.sin_port = htons(IAX_DEFAULT_PORTNO);
 				}
@@ -10639,7 +10705,7 @@
 					inet_aton("255.255.255.255", &peer->mask);
 			} else if (!strcasecmp(v->name, "defaultip")) {
 				if (ast_get_ip(&peer->defaddr, v->value))
-					return peer_unref(peer);
+					return peer_unref(peer, "toss peer ptr from bad get_ip call");
 			} else if (!strcasecmp(v->name, "sourceaddress")) {
 				peer_set_srcaddr(peer, v->value);
 			} else if (!strcasecmp(v->name, "permit") ||
@@ -10788,7 +10854,7 @@
 	};
 
 	if (!temponly) {
-		user = ao2_find(users, &tmp_user, OBJ_POINTER);
+		user = ao2_t_find(users, &tmp_user, OBJ_POINTER, "find user in users table");
 		if (user && !ast_test_flag(user, IAX_DELME))
 			firstpass = 0;
 	}
@@ -10802,9 +10868,9 @@
 			user->contexts = NULL;
 		}
 		/* Already in the list, remove it and it will be added back (or FREE'd) */
-		ao2_unlink(users, user);
+		ao2_t_unlink(users, user, "release user ptr obtained from ao2_find");
  	} else {
-		user = ao2_alloc(sizeof(*user), user_destructor);
+		user = ao2_t_alloc(sizeof(*user), user_destructor, "allocate unfound user");
 	}
 	
 	if (user) {
@@ -10812,7 +10878,7 @@
 			ast_string_field_free_memory(user);
 			memset(user, 0, sizeof(struct iax2_user));
 			if (ast_string_field_init(user, 32)) {
-				user = user_unref(user);
+				user = user_unref(user, "relingquish user ptr because string_field_init didn't work");
 				goto cleanup;
 			}
 			user->maxauthreq = maxauthreq;
@@ -11003,7 +11069,7 @@
 {
 	struct iax2_registry *reg;
 
-	ao2_callback(users, 0, user_delme_cb, NULL);
+	ao2_t_callback(users, 0, user_delme_cb, NULL, "delete users calling user_delme_cb");
 
 	AST_LIST_LOCK(&registrations);
 	while ((reg = AST_LIST_REMOVE_HEAD(&registrations, entry))) {
@@ -11023,7 +11089,7 @@
 	}
 	AST_LIST_UNLOCK(&registrations);
 
-	ao2_callback(peers, 0, peer_delme_cb, NULL);
+	ao2_t_callback(peers, 0, peer_delme_cb, NULL, "delete users calling peer_delme_cb, to delete peers" );
 }
 
 static void prune_users(void)
@@ -11032,10 +11098,10 @@
 	struct ao2_iterator i;
 
 	i = ao2_iterator_init(users, 0);
-	while ((user = ao2_iterator_next(&i))) {
+	while ((user = ao2_t_iterator_next(&i, "iterate over users for prune users"))) {
 		if (ast_test_flag(user, IAX_DELME))
-			ao2_unlink(users, user);
-		user_unref(user);
+			ao2_t_unlink(users, user, "unlink user from users");
+		user_unref(user, "release iterated user ptr");
 	}
 }
 
@@ -11046,10 +11112,10 @@
 	struct ao2_iterator i;
 
 	i = ao2_iterator_init(peers, 0);
-	while ((peer = ao2_iterator_next(&i))) {
+	while ((peer = ao2_t_iterator_next(&i, "iterate over peers for prune_peers"))) {
 		if (ast_test_flag(peer, IAX_DELME))
 			unlink_peer(peer);
-		peer_unref(peer);
+		peer_unref(peer,"toss iterated peer ptr");
 	}
 }
 
@@ -11441,15 +11507,15 @@
 					/* Start with general parameters, then specific parameters, user and peer */
 					user = build_user(cat, gen, ast_variable_browse(ucfg, cat), 0);
 					if (user) {
-						ao2_link(users, user);
-						user = user_unref(user);
+						ao2_t_link(users, user, "link user into users table");
+						user = user_unref(user, "release user ptr from build_user before it goes out of scope");
 					}
 					peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
 					if (peer) {
 						if (ast_test_flag(peer, IAX_DYNAMIC))
 							reg_source_db(peer);
-						ao2_link(peers, peer);
-						peer = peer_unref(peer);
+						ao2_t_link(peers, peer, "link peer into peers table");
+						peer = peer_unref(peer, "release peer from build_peer before it goes out of scope");
 					}
 				}
 				if (ast_true(registeriax) || (!registeriax && genregisteriax)) {
@@ -11485,8 +11551,8 @@
 				if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
 					user = build_user(cat, ast_variable_browse(cfg, cat), NULL, 0);
 					if (user) {
-						ao2_link(users, user);
-						user = user_unref(user);
+						ao2_t_link(users, user, "link user into users table");
+						user = user_unref(user, "toss user ptr from build_user before it goes out of scope");
 					}
 				}
 				if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
@@ -11494,8 +11560,8 @@
 					if (peer) {
 						if (ast_test_flag(peer, IAX_DYNAMIC))
 							reg_source_db(peer);
-						ao2_link(peers, peer);
-						peer = peer_unref(peer);
+						ao2_t_link(peers, peer, "link built peer into peers table");
+						peer = peer_unref(peer, "toss peer ptr from build_peer before it goes out scope");
 					}
 				} else if (strcasecmp(utype, "user")) {
 					ast_log(LOG_WARNING, "Unknown type '%s' for '%s' in %s\n", utype, cat, config_file);
@@ -11516,9 +11582,9 @@
 	struct iax2_peer *peer;
 
 	i = ao2_iterator_init(peers, 0);
-	while ((peer = ao2_iterator_next(&i))) {
+	while ((peer = ao2_t_iterator_next(&i,"iterate over peers for poke_all_peers"))) {
 		iax2_poke_peer(peer, 0);
-		peer_unref(peer);
+		peer_unref(peer, "toss iterated peer ptr");
 	}
 }
 static int reload_config(void)
@@ -11951,7 +12017,7 @@
 		}
 	}
 
-	peer_unref(peer);
+	peer_unref(peer, "toss peer ptr from find_peer call");
 
 	return 0;
 }
@@ -12068,7 +12134,7 @@
 			res = AST_DEVICE_UNKNOWN;	
 	}
 
-	peer_unref(p);
+	peer_unref(p, "toss peer ptr from find_peer call");
 
 	return res;
 }
@@ -12289,8 +12355,12 @@
 	for (x = 0; x < IAX_MAX_CALLS; x++)
 		ast_mutex_destroy(&iaxsl[x]);
 
-	ao2_ref(peers, -1);
-	ao2_ref(users, -1);
+	ao2_t_ref(peers, -1, "unlink the entire peers table");
+	ao2_t_ref(users, -1, "unlink the entire users table");
+	ao2_t_ref(findcall1, -1, "Unlink the entire findcall1 table");
+	ao2_t_ref(findcall2, -1, "Unlink the entire findcall2 table");
+	ao2_t_ref(findcall3, -1, "Unlink the entire findcall3 table");
+	ao2_t_ref(findcall4, -1, "Unlink the entire findcall4 table");
 	
 	con = ast_context_find(regcontext);
 	if (con)
@@ -12323,42 +12393,42 @@
 	int x = 0;
 	struct iax2_registry *reg = NULL;
 
-	peers = ao2_container_alloc(hash_peer_size, peer_hash_cb, peer_cmp_cb);
+	peers = ao2_t_container_alloc(hash_peer_size, peer_hash_cb, peer_cmp_cb, "allocating peers table");
 	if (!peers)
 		return AST_MODULE_LOAD_FAILURE;
-	users = ao2_container_alloc(hash_user_size, user_hash_cb, user_cmp_cb);
+	users = ao2_t_container_alloc(hash_user_size, user_hash_cb, user_cmp_cb, "allocating users table");
 	if (!users) {
-		ao2_ref(peers, -1);
+		ao2_t_ref(peers, -1, "Destroy peers table because we couldn't allocate the users table");
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	findcall1 = ao2_container_alloc(hash_findcallno_size, findcall1_hash_cb, findcall1_cmp_cb);
+	findcall1 = ao2_t_container_alloc(hash_findcallno_size, findcall1_hash_cb, findcall1_cmp_cb, "allocate findcall1 table");
 	if (!findcall1) {
-		ao2_ref(peers, -1);
-		ao2_ref(users, -1);
+		ao2_t_ref(peers, -1, "Destroy peers table because we couldn't allocate the findcall1 table");
+		ao2_t_ref(users, -1, "Destroy users table because we couldn't allocate the findcall1 table");
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	findcall2 = ao2_container_alloc(hash_findcallno_size, findcall2_hash_cb, findcall2_cmp_cb);
+	findcall2 = ao2_t_container_alloc(hash_findcallno_size, findcall2_hash_cb, findcall2_cmp_cb, "allocate findcall2 table");
 	if (!findcall2) {
-		ao2_ref(peers, -1);
-		ao2_ref(users, -1);
-		ao2_ref(findcall1, -1);
+		ao2_t_ref(peers, -1, "Destroy peers table because we couldn't allocate the findcall2 table");
+		ao2_t_ref(users, -1, "Destroy users table because we couldn't allocate the findcall2 table");
+		ao2_t_ref(findcall1, -1, "Destroy findcall1 table because we couldn't allocate the findcall2 table");
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	findcall3 = ao2_container_alloc(hash_findcallno3_size, findcall3_hash_cb, findcall3_cmp_cb);
+	findcall3 = ao2_t_container_alloc(hash_findcallno3_size, findcall3_hash_cb, findcall3_cmp_cb, "allocate findcall3 table");
 	if (!findcall3) {
-		ao2_ref(peers, -1);
-		ao2_ref(users, -1);
-		ao2_ref(findcall1, -1);
-		ao2_ref(findcall2, -1);
+		ao2_t_ref(peers, -1, "Destroy peers table because we couldn't allocate the findcall3 table");
+		ao2_t_ref(users, -1, "Destroy users table because we couldn't allocate the findcall3 table");
+		ao2_t_ref(findcall1, -1, "Destroy findcall1 table because we couldn't allocate the findcall3 table");
+		ao2_t_ref(findcall2, -1, "Destroy findcall2 table because we couldn't allocate the findcall3 table");
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	findcall4 = ao2_container_alloc(hash_findcallno4_size, findcall4_hash_cb, findcall4_cmp_cb);
+	findcall4 = ao2_t_container_alloc(hash_findcallno4_size, findcall4_hash_cb, findcall4_cmp_cb, "allocate findcall4 table");
 	if (!findcall4) {
-		ao2_ref(peers, -1);
-		ao2_ref(users, -1);
-		ao2_ref(findcall1, -1);
-		ao2_ref(findcall2, -1);
-		ao2_ref(findcall3, -1);
+		ao2_t_ref(peers, -1, "Destroy peers table because we couldn't allocate the findcall4 table");
+		ao2_t_ref(users, -1, "Destroy users table because we couldn't allocate the findcall4 table");
+		ao2_t_ref(findcall1, -1, "Destroy findcall1 table because we couldn't allocate the findcall4 table");
+		ao2_t_ref(findcall2, -1, "Destroy findcall2 table because we couldn't allocate the findcall4 table");
+		ao2_t_ref(findcall3, -1, "Destroy findcall3 table because we couldn't allocate the findcall4 table");
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
@@ -12446,8 +12516,8 @@
 		iax2_do_register(reg);
 	AST_LIST_UNLOCK(&registrations);	
 	
-	ao2_callback(peers, 0, peer_set_sock_cb, NULL);
-	ao2_callback(peers, 0, iax2_poke_peer_cb, NULL);
+	ao2_t_callback(peers, 0, peer_set_sock_cb, NULL, "Callback on peers table members to call peer_set_sock_cb");
+	ao2_t_callback(peers, 0, iax2_poke_peer_cb, NULL, "Callback on peers table members to call iax2_poke_peer_cb");
 
 
 	reload_firmware(0);




More information about the asterisk-commits mailing list