[asterisk-commits] jpeeler: branch jpeeler/chan_dahdi r118379 - in /team/jpeeler/chan_dahdi: ./ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 27 11:47:23 CDT 2008


Author: jpeeler
Date: Tue May 27 11:47:22 2008
New Revision: 118379

URL: http://svn.digium.com/view/asterisk?view=rev&rev=118379
Log:
sync with trunk

Added:
    team/jpeeler/chan_dahdi/configs/pbx_realtime.conf
      - copied unchanged from r118359, trunk/configs/pbx_realtime.conf
    team/jpeeler/chan_dahdi/doc/api-1.6.0-changes.odt
      - copied unchanged from r118359, trunk/doc/api-1.6.0-changes.odt
    team/jpeeler/chan_dahdi/doc/cli.txt
      - copied unchanged from r118359, trunk/doc/cli.txt
Modified:
    team/jpeeler/chan_dahdi/   (props changed)
    team/jpeeler/chan_dahdi/CHANGES
    team/jpeeler/chan_dahdi/UPGRADE.txt
    team/jpeeler/chan_dahdi/apps/app_chanisavail.c
    team/jpeeler/chan_dahdi/apps/app_rpt.c
    team/jpeeler/chan_dahdi/apps/app_voicemail.c
    team/jpeeler/chan_dahdi/channels/chan_gtalk.c
    team/jpeeler/chan_dahdi/channels/chan_sip.c
    team/jpeeler/chan_dahdi/channels/chan_usbradio.c
    team/jpeeler/chan_dahdi/channels/chan_vpb.cc
    team/jpeeler/chan_dahdi/configs/queues.conf.sample
    team/jpeeler/chan_dahdi/include/asterisk/compat.h
    team/jpeeler/chan_dahdi/include/asterisk/lock.h
    team/jpeeler/chan_dahdi/include/asterisk/logger.h
    team/jpeeler/chan_dahdi/include/asterisk/manager.h
    team/jpeeler/chan_dahdi/include/asterisk/utils.h
    team/jpeeler/chan_dahdi/main/features.c
    team/jpeeler/chan_dahdi/main/http.c
    team/jpeeler/chan_dahdi/main/logger.c
    team/jpeeler/chan_dahdi/main/manager.c
    team/jpeeler/chan_dahdi/main/pbx.c
    team/jpeeler/chan_dahdi/main/utils.c
    team/jpeeler/chan_dahdi/pbx/pbx_realtime.c
    team/jpeeler/chan_dahdi/res/res_config_ldap.c
    team/jpeeler/chan_dahdi/res/res_jabber.c
    team/jpeeler/chan_dahdi/res/res_odbc.c
    team/jpeeler/chan_dahdi/utils/ael_main.c
    team/jpeeler/chan_dahdi/utils/check_expr.c
    team/jpeeler/chan_dahdi/utils/conf2ael.c
    team/jpeeler/chan_dahdi/utils/hashtest.c
    team/jpeeler/chan_dahdi/utils/hashtest2.c
    team/jpeeler/chan_dahdi/utils/refcounter.c

Propchange: team/jpeeler/chan_dahdi/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/jpeeler/chan_dahdi/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/jpeeler/chan_dahdi/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue May 27 11:47:22 2008
@@ -1,1 +1,1 @@
-/trunk:1-117947
+/trunk:1-118370

Modified: team/jpeeler/chan_dahdi/CHANGES
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/CHANGES?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/CHANGES (original)
+++ team/jpeeler/chan_dahdi/CHANGES Tue May 27 11:47:22 2008
@@ -75,6 +75,8 @@
  * ExternalIVR now takes several options that affect the way it performs, as
    well as having several new commands.  Please see doc/externalivr.txt for the
    complete documentation.
+ * ChanIsAvail has a new option, 'a', which will return all available channels instead
+   of just the first one if you give the function more then one channel to check.
 
 SIP Changes
 -----------
@@ -742,3 +744,9 @@
      turned on, via the CHANNEL(trace) dialplan function.  Could be useful for
      dialplan debugging.
   * iLBC source code no longer included (see UPGRADE.txt for details)
+  * If compiled with DETECT_DEADLOCKS enabled and if you have glibc, then if 
+     deadlock is detected, a backtrace of the stack which led to the lock calls
+	 will be output to the CLI.
+  * If compiled with DEBUG_THREADS enabled and if you have glibc, then issuing
+     the "core show locks" CLI command will give lock information output as well
+	 as a backtrace of the stack which led to the lock calls.

Modified: team/jpeeler/chan_dahdi/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/UPGRADE.txt?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/UPGRADE.txt (original)
+++ team/jpeeler/chan_dahdi/UPGRADE.txt Tue May 27 11:47:22 2008
@@ -58,6 +58,12 @@
 
 * The silencethreshold used for various applications is now settable via a
   centralized config option in dsp.conf.
+
+* The logical value of spaces immediately preceding a standalone 0 previously
+  evaluated to true.  It now evaluates to false.  This has confused a good
+  many people in the past (typically because they failed to realize the space
+  had any significance).  Since this violates the Principle of Least Surprise,
+  it has been changed.
 
 Voicemail:
 

Modified: team/jpeeler/chan_dahdi/apps/app_chanisavail.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/apps/app_chanisavail.c?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/apps/app_chanisavail.c (original)
+++ team/jpeeler/chan_dahdi/apps/app_chanisavail.c Tue May 27 11:47:22 2008
@@ -50,6 +50,7 @@
 "This application will check to see if any of the specified channels are\n"
 "available.\n"
 "  Options:\n"
+"    a - Check for all available channels, not only the first one.\n"
 "    s - Consider the channel unavailable if the channel is in use at all.\n"
 "    t - Simply checks if specified channels exist in the channel list\n"
 "        (implies option s).\n"
@@ -61,9 +62,12 @@
 
 static int chanavail_exec(struct ast_channel *chan, void *data)
 {
-	int res=-1, inuse=-1, option_state=0, string_compare=0;
+	int inuse=-1, option_state=0, string_compare=0, option_all_avail=0;
 	int status;
 	char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur;
+	struct ast_str *tmp_availchan = ast_str_alloca(2048);
+	struct ast_str *tmp_availorig = ast_str_alloca(2048);
+	struct ast_str *tmp_availstat = ast_str_alloca(2048);
 	struct ast_channel *tempchan;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(reqchans);
@@ -80,10 +84,15 @@
 	AST_STANDARD_APP_ARGS(args, info);
 
 	if (args.options) {
-		if (strchr(args.options, 's'))
+		if (strchr(args.options, 'a')) {
+			option_all_avail = 1;
+		}
+		if (strchr(args.options, 's')) {
 			option_state = 1;
-		if (strchr(args.options, 't'))
+		}
+		if (strchr(args.options, 't')) {
 			string_compare = 1;
+		}
 	}
 	peers = args.reqchans;
 	if (peers) {
@@ -119,27 +128,32 @@
 				status = inuse = ast_device_state(trychan);
 			}
 			if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status))) {
-					pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name);
-					/* Store the originally used channel too */
+					ast_str_append(&tmp_availchan, 0, "%s%s", tmp_availchan->used ? "&" : "", tempchan->name);
+					
 					snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
-					pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", tmp);
+					ast_str_append(&tmp_availorig, 0, "%s%s", tmp_availorig->used ? "&" : "", tmp);
+
 					snprintf(tmp, sizeof(tmp), "%d", status);
-					pbx_builtin_setvar_helper(chan, "AVAILSTATUS", tmp);
+					ast_str_append(&tmp_availstat, 0, "%s%s", tmp_availstat->used ? "&" : "", tmp);
+
 					ast_hangup(tempchan);
 					tempchan = NULL;
-					res = 1;
-					break;
+
+					if (!option_all_avail) {
+						break;
+					}
 			} else {
 				snprintf(tmp, sizeof(tmp), "%d", status);
-				pbx_builtin_setvar_helper(chan, "AVAILSTATUS", tmp);
+				ast_str_append(&tmp_availstat, 0, "%s%s", tmp_availstat->used ? "&" : "", tmp);
 			}
 			cur = rest;
 		} while (cur);
 	}
-	if (res < 1) {
-		pbx_builtin_setvar_helper(chan, "AVAILCHAN", "");
-		pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", "");
-	}
+
+	pbx_builtin_setvar_helper(chan, "AVAILCHAN", tmp_availchan->str);
+	/* Store the originally used channel too */
+	pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", tmp_availorig->str);
+	pbx_builtin_setvar_helper(chan, "AVAILSTATUS", tmp_availstat->str);
 
 	return 0;
 }

Modified: team/jpeeler/chan_dahdi/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/apps/app_rpt.c?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/apps/app_rpt.c (original)
+++ team/jpeeler/chan_dahdi/apps/app_rpt.c Tue May 27 11:47:22 2008
@@ -1876,7 +1876,7 @@
 	wf.offset = 0;
 	wf.mallocd = 0;
 	wf.datalen = strlen(txt) + 1;
-	wf.data = txt;
+	wf.data.ptr = txt;
 	wf.samples = 0;
 	ast_write(myrpt->txchannel,&wf); 
 	return 0;
@@ -5613,7 +5613,7 @@
 		/* if we found it, write it and were done */
 		if (!strcmp(l->name,myrpt->cmdnode))
 		{
-			wf.data = str;
+			wf.data.ptr = str;
 			if (l->chan) ast_write(l->chan,&wf);
 			return;
 		}
@@ -5623,7 +5623,7 @@
 	/* if not, give it to everyone */
 	while(l != &myrpt->links)
 	{
-		wf.data = str;
+		wf.data.ptr = str;
 		if (l->chan) ast_write(l->chan,&wf);
 		l = l->next;
 	}
@@ -5652,7 +5652,7 @@
 	/* give it to everyone */
 	while(l != &myrpt->links)
 	{
-		wf.data = str;
+		wf.data.ptr = str;
 		if (l->chan) ast_write(l->chan,&wf);
 		l = l->next;
 	}
@@ -5954,7 +5954,7 @@
 				wf.mallocd = 0;
 				wf.datalen = strlen(discstr) + 1;
 				wf.samples = 0;
-				wf.data = discstr;
+				wf.data.ptr = discstr;
 				if (l->chan)
 				{
 					ast_write(l->chan,&wf);
@@ -6069,7 +6069,7 @@
                                 wf.mallocd = 0;
                                 wf.datalen = strlen(discstr) + 1;
                                 wf.samples = 0;
-                                wf.data = discstr;
+                                wf.data.ptr = discstr;
                                 if (l->chan)
                                 {
                                         ast_write(l->chan,&wf);
@@ -6751,7 +6751,7 @@
 				{
 					/* send, but not to src */
 					if (strcmp(l->name,src)) {
-						wf.data = str;
+						wf.data.ptr = str;
 						if (l->chan) ast_write(l->chan,&wf);
 					}
 					return;
@@ -6779,7 +6779,7 @@
 				}
 				/* send, but not to src */
 				if (strcmp(l->name,src)) {
-					wf.data = str;
+					wf.data.ptr = str;
 					if (l->chan) ast_write(l->chan,&wf); 
 				}
 				l = l->next;
@@ -6798,7 +6798,7 @@
 				n = (int)(now - myrpt->lastkeyedtime);
 			}
 			sprintf(tmp1,"K %s %s %d %d",src,myrpt->name,myrpt->keyed,n);
-			wf.data = tmp1;
+			wf.data.ptr = tmp1;
 			wf.datalen = strlen(tmp1) + 1;
 			if (mylink->chan) ast_write(mylink->chan,&wf); 
 			return;
@@ -6876,7 +6876,7 @@
 			{
 				/* send, but not to src */
 				if (strcmp(l->name,src)) {
-					wf.data = str;
+					wf.data.ptr = str;
 					if (l->chan) ast_write(l->chan,&wf);
 				}
 				return;
@@ -6900,7 +6900,7 @@
 			}
 			/* send, but not to src */
 			if (strcmp(l->name,src)) {
-				wf.data = str;
+				wf.data.ptr = str;
 				if (l->chan) ast_write(l->chan,&wf); 
 			}
 			l = l->next;
@@ -11693,7 +11693,7 @@
 				if (l->chan)
 				{
 					lf.datalen = strlen(lstr) + 1;
-					lf.data = lstr;
+					lf.data.ptr = lstr;
 					ast_write(l->chan,&lf);
 					if (debug > 6) ast_log(LOG_NOTICE,
 						"@@@@ node %s sent node string %s to node %s\n",
@@ -12040,7 +12040,7 @@
 #endif
 
 				if ((!myrpt->localtx) && (!myrpt->p.linktolink)) {
-					memset(f->data,0,f->datalen);
+					memset(f->data.ptr,0,f->datalen);
 				}
 
 #ifdef	_MDC_DECODE_H_
@@ -12096,11 +12096,11 @@
 				dtmfed = 0;
 				if (ismuted)
 				{
-					memset(f->data,0,f->datalen);
+					memset(f->data.ptr,0,f->datalen);
 					if (myrpt->lastf1)
-						memset(myrpt->lastf1->data,0,myrpt->lastf1->datalen);
+						memset(myrpt->lastf1->data.ptr,0,myrpt->lastf1->datalen);
 					if (myrpt->lastf2)
-						memset(myrpt->lastf2->data,0,myrpt->lastf2->datalen);
+						memset(myrpt->lastf2->data.ptr,0,myrpt->lastf2->datalen);
 				} 
 				if (f) f2 = ast_frdup(f);
 				else f2 = NULL;
@@ -12110,9 +12110,9 @@
 				if (ismuted)
 				{
 					if (myrpt->lastf1)
-						memset(myrpt->lastf1->data,0,myrpt->lastf1->datalen);
+						memset(myrpt->lastf1->data.ptr,0,myrpt->lastf1->datalen);
 					if (myrpt->lastf2)
-						memset(myrpt->lastf2->data,0,myrpt->lastf2->datalen);
+						memset(myrpt->lastf2->data.ptr,0,myrpt->lastf2->datalen);
 				}
 				if (f1)
 				{
@@ -12124,9 +12124,9 @@
 			else if (f->frametype == AST_FRAME_DTMF_BEGIN)
 			{
 				if (myrpt->lastf1)
-					memset(myrpt->lastf1->data,0,myrpt->lastf1->datalen);
+					memset(myrpt->lastf1->data.ptr,0,myrpt->lastf1->datalen);
 				if (myrpt->lastf2)
-					memset(myrpt->lastf2->data,0,myrpt->lastf2->datalen);
+					memset(myrpt->lastf2->data.ptr,0,myrpt->lastf2->datalen);
 				dtmfed = 1;
 			}
 #endif
@@ -12135,9 +12135,9 @@
 				c = (char) f->subclass; /* get DTMF char */
 				ast_frfree(f);
 				if (myrpt->lastf1)
-					memset(myrpt->lastf1->data,0,myrpt->lastf1->datalen);
+					memset(myrpt->lastf1->data.ptr,0,myrpt->lastf1->datalen);
 				if (myrpt->lastf2)
-					memset(myrpt->lastf2->data,0,myrpt->lastf2->datalen);
+					memset(myrpt->lastf2->data.ptr,0,myrpt->lastf2->datalen);
 				dtmfed = 1;
 				if (!myrpt->keyed) continue;
 				c = func_xlat(myrpt,c,&myrpt->p.inxlat);
@@ -12166,13 +12166,13 @@
 					{
 						donodelog(myrpt,"RXKEY,MAIN");
 					}
-					if (f->datalen && f->data)
+					if (f->datalen && f->data.ptr)
 					{
 						char *val, busy = 0;
 
-						if (debug) ast_log(LOG_NOTICE,"Got PL %s on node %s\n",(char *)f->data,myrpt->name);
+						if (debug) ast_log(LOG_NOTICE,"Got PL %s on node %s\n",(char *)f->data.ptr,myrpt->name);
 						// ctcss code autopatch initiate
-						if (strstr((char *)f->data,"/M/")&& !myrpt->macropatch)
+						if (strstr((char *)f->data.ptr,"/M/")&& !myrpt->macropatch)
 						{
 						    char val[16];
 							strcat(val,"*6");
@@ -12185,16 +12185,16 @@
 							if(!busy){
 								myrpt->macrotimer = MACROTIME;
 								strncat(myrpt->macrobuf,val,MAXMACRO - 1);
-								if (!busy) strcpy(myrpt->lasttone,(char*)f->data);
+								if (!busy) strcpy(myrpt->lasttone,(char*)f->data.ptr);
 							}
 							rpt_mutex_unlock(&myrpt->lock);
 						}
-						else if (strcmp((char *)f->data,myrpt->lasttone))
+						else if (strcmp((char *)f->data.ptr,myrpt->lasttone))
 						{
-							val = (char *) ast_variable_retrieve(myrpt->cfg, myrpt->p.tonemacro, (char *)f->data);
+							val = (char *) ast_variable_retrieve(myrpt->cfg, myrpt->p.tonemacro, (char *)f->data.ptr);
 							if (val) 
 							{
-								if (debug) ast_log(LOG_NOTICE,"Tone %s doing %s on node %s\n",(char *) f->data,val,myrpt->name);
+								if (debug) ast_log(LOG_NOTICE,"Tone %s doing %s on node %s\n",(char *) f->data.ptr,val,myrpt->name);
 								rpt_mutex_lock(&myrpt->lock);
 								if ((MAXMACRO - strlen(myrpt->macrobuf)) < strlen(val)){
 									rpt_mutex_unlock(&myrpt->lock);
@@ -12206,7 +12206,7 @@
 								}
 								rpt_mutex_unlock(&myrpt->lock);
 							}
-						 	if (!busy) strcpy(myrpt->lasttone,(char*)f->data);
+						 	if (!busy) strcpy(myrpt->lasttone,(char*)f->data.ptr);
 						}
 					} else myrpt->lasttone[0] = 0;
 				}
@@ -12300,7 +12300,7 @@
 						    for(;x < myrpt->p.simplexpatchdelay; x++)
 						    {
 								f1 = ast_frdup(f);
-								memset(f1->data,0,f1->datalen);
+								memset(f1->data.ptr,0,f1->datalen);
 								AST_LIST_INSERT_TAIL(&myrpt->txq,f1,frame_list);
 						    }
 						    myfirst = 1;
@@ -12314,7 +12314,7 @@
 						frame_list) x++;
 					if (!x)
 					{
-						memset(f->data,0,f->datalen);
+						memset(f->data.ptr,0,f->datalen);
 					}
 					else
 					{
@@ -12478,7 +12478,7 @@
 					if ((l->phonemode) && (l->phonevox))
 					{
 						n1 = dovox(&l->vox,
-							f->data,f->datalen / 2);
+							f->data.ptr,f->datalen / 2);
 						if (n1 != l->wasvox)
 						{
 							if (debug)ast_log(LOG_DEBUG,"Link Node %s, vox %d\n",l->name,n1);
@@ -12497,7 +12497,7 @@
 							    for(;x < myrpt->p.simplexphonedelay; x++)
 								{
 									f1 = ast_frdup(f);
-									memset(f1->data,0,f1->datalen);
+									memset(f1->data.ptr,0,f1->datalen);
 									AST_LIST_INSERT_TAIL(&l->rxq,
 										f1,frame_list);
 							    }
@@ -12510,7 +12510,7 @@
 						AST_LIST_TRAVERSE(&l->rxq, f1,frame_list) x++;
 						if (!x)
 						{
-							memset(f->data,0,f->datalen);
+							memset(f->data.ptr,0,f->datalen);
 						}
 						else
 						{
@@ -12527,11 +12527,11 @@
 						l->dtmfed = 0;
 						if (ismuted)
 						{
-							memset(f->data,0,f->datalen);
+							memset(f->data.ptr,0,f->datalen);
 							if (l->lastf1)
-								memset(l->lastf1->data,0,l->lastf1->datalen);
+								memset(l->lastf1->data.ptr,0,l->lastf1->datalen);
 							if (l->lastf2)
-								memset(l->lastf2->data,0,l->lastf2->datalen);
+								memset(l->lastf2->data.ptr,0,l->lastf2->datalen);
 						} 
 						if (f) f2 = ast_frdup(f);
 						else f2 = NULL;
@@ -12541,9 +12541,9 @@
 						if (ismuted)
 						{
 							if (l->lastf1)
-								memset(l->lastf1->data,0,l->lastf1->datalen);
+								memset(l->lastf1->data.ptr,0,l->lastf1->datalen);
 							if (l->lastf2)
-								memset(l->lastf2->data,0,l->lastf2->datalen);
+								memset(l->lastf2->data.ptr,0,l->lastf2->datalen);
 						}
 						if (f1)
 						{
@@ -12554,7 +12554,7 @@
 					else
 					{
 						if (!l->lastrx)
-							memset(f->data,0,f->datalen);
+							memset(f->data.ptr,0,f->datalen);
 						ast_write(l->pchan,f);
 					}
 				}
@@ -12562,22 +12562,22 @@
 				else if (f->frametype == AST_FRAME_DTMF_BEGIN)
 				{
 					if (l->lastf1)
-						memset(l->lastf1->data,0,l->lastf1->datalen);
+						memset(l->lastf1->data.ptr,0,l->lastf1->datalen);
 					if (l->lastf2)
-						memset(l->lastf2->data,0,l->lastf2->datalen);
+						memset(l->lastf2->data.ptr,0,l->lastf2->datalen);
 					l->dtmfed = 1;
 				}
 #endif
 				if (f->frametype == AST_FRAME_TEXT)
 				{
-					handle_link_data(myrpt,l,f->data);
+					handle_link_data(myrpt,l,f->data.ptr);
 				}
 				if (f->frametype == AST_FRAME_DTMF)
 				{
 					if (l->lastf1)
-						memset(l->lastf1->data,0,l->lastf1->datalen);
+						memset(l->lastf1->data.ptr,0,l->lastf1->datalen);
 					if (l->lastf2)
-						memset(l->lastf2->data,0,l->lastf2->datalen);
+						memset(l->lastf2->data.ptr,0,l->lastf2->datalen);
 					l->dtmfed = 1;
 					handle_link_phone_dtmf(myrpt,l,f->subclass);
 				}
@@ -12827,7 +12827,7 @@
 			}
 			if (f->frametype == AST_FRAME_VOICE)
 			{
-				n = dovox(&myrpt->vox,f->data,f->datalen / 2);
+				n = dovox(&myrpt->vox,f->data.ptr,f->datalen / 2);
 				if (n != myrpt->wasvox)
 				{
 					if (debug) ast_log(LOG_DEBUG,"Node %s, vox %d\n",myrpt->name,n);
@@ -14343,11 +14343,11 @@
 				dtmfed = 0;
 				if (ismuted)
 				{
-					memset(f->data,0,f->datalen);
+					memset(f->data.ptr,0,f->datalen);
 					if (myrpt->lastf1)
-						memset(myrpt->lastf1->data,0,myrpt->lastf1->datalen);
+						memset(myrpt->lastf1->data.ptr,0,myrpt->lastf1->datalen);
 					if (myrpt->lastf2)
-						memset(myrpt->lastf2->data,0,myrpt->lastf2->datalen);
+						memset(myrpt->lastf2->data.ptr,0,myrpt->lastf2->datalen);
 				} 
 				if (f) f2 = ast_frdup(f);
 				else f2 = NULL;
@@ -14357,9 +14357,9 @@
 				if (ismuted)
 				{
 					if (myrpt->lastf1)
-						memset(myrpt->lastf1->data,0,myrpt->lastf1->datalen);
+						memset(myrpt->lastf1->data.ptr,0,myrpt->lastf1->datalen);
 					if (myrpt->lastf2)
-						memset(myrpt->lastf2->data,0,myrpt->lastf2->datalen);
+						memset(myrpt->lastf2->data.ptr,0,myrpt->lastf2->datalen);
 				}
 				if (f1)
 				{
@@ -14374,18 +14374,18 @@
 			else if (f->frametype == AST_FRAME_DTMF_BEGIN)
 			{
 				if (myrpt->lastf1)
-					memset(myrpt->lastf1->data,0,myrpt->lastf1->datalen);
+					memset(myrpt->lastf1->data.ptr,0,myrpt->lastf1->datalen);
 				if (myrpt->lastf2)
-					memset(myrpt->lastf2->data,0,myrpt->lastf2->datalen);
+					memset(myrpt->lastf2->data.ptr,0,myrpt->lastf2->datalen);
 				dtmfed = 1;
 			}
 #endif
 			if (f->frametype == AST_FRAME_DTMF)
 			{
 				if (myrpt->lastf1)
-					memset(myrpt->lastf1->data,0,myrpt->lastf1->datalen);
+					memset(myrpt->lastf1->data.ptr,0,myrpt->lastf1->datalen);
 				if (myrpt->lastf2)
-					memset(myrpt->lastf2->data,0,myrpt->lastf2->datalen);
+					memset(myrpt->lastf2->data.ptr,0,myrpt->lastf2->datalen);
 				dtmfed = 1;
 				if (handle_remote_phone_dtmf(myrpt,f->subclass,&keyed,phone_mode) == -1)
 				{
@@ -14396,7 +14396,7 @@
 			}
 			if (f->frametype == AST_FRAME_TEXT)
 			{
-				if (handle_remote_data(myrpt,f->data) == -1)
+				if (handle_remote_data(myrpt,f->data.ptr) == -1)
 				{
 					if (debug) printf("@@@@ rpt:Hung Up\n");
 					ast_frfree(f);
@@ -14448,7 +14448,7 @@
 				((myrpt->remote) && (myrpt->remotetx)) ||
 				  ((myrpt->remmode != REM_MODE_FM) &&
 				    notremming))
-					memset(f->data,0,f->datalen); 
+					memset(f->data.ptr,0,f->datalen); 
 				 ast_write(myrpt->pchannel,f);
 			}
 			else if (f->frametype == AST_FRAME_CONTROL)

Modified: team/jpeeler/chan_dahdi/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/apps/app_voicemail.c?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/apps/app_voicemail.c (original)
+++ team/jpeeler/chan_dahdi/apps/app_voicemail.c Tue May 27 11:47:22 2008
@@ -9166,6 +9166,8 @@
 	AST_RWLIST_WRLOCK(&mwi_subs);
 	AST_RWLIST_INSERT_TAIL(&mwi_subs, mwi_sub, entry);
 	AST_RWLIST_UNLOCK(&mwi_subs);
+	ast_free((void *) p->mailbox);
+	ast_free((void *) p->context);
 	ast_free(p);	
 	return 0;
 }
@@ -9200,8 +9202,8 @@
 		ast_log(LOG_ERROR, "could not allocate a mwi_sub_task\n");
 		return;
 	}
-	mwist->mailbox = ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX);
-	mwist->context = ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT);
+	mwist->mailbox = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX));
+	mwist->context = ast_strdup(ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT));
 	mwist->uniqueid = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
 	
 	if (ast_taskprocessor_push(mwi_subscription_tps, handle_subscribe, mwist) < 0) {

Modified: team/jpeeler/chan_dahdi/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/channels/chan_gtalk.c?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/channels/chan_gtalk.c (original)
+++ team/jpeeler/chan_dahdi/channels/chan_gtalk.c Tue May 27 11:47:22 2008
@@ -1702,7 +1702,10 @@
 {
 	struct gtalk *client = ASTOBJ_REF((struct gtalk *) data);
 
-	if (iks_find_with_attrib(pak->x, "session", "type", "initiate")) {
+	if (iks_find_attrib(pak->x, "type") && !strcmp(iks_find_attrib (pak->x, "type"),"error")) {
+		ast_log(LOG_NOTICE, "Remote peer reported an error, trying to establish the call anyway\n");
+	}
+	else if (iks_find_with_attrib(pak->x, "session", "type", "initiate")) {
 		/* New call */
 		gtalk_newcall(client, pak);
 	} else if (iks_find_with_attrib(pak->x, "session", "type", "candidates") || iks_find_with_attrib(pak->x, "session", "type", "transport-info")) {

Modified: team/jpeeler/chan_dahdi/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/channels/chan_sip.c?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/channels/chan_sip.c (original)
+++ team/jpeeler/chan_dahdi/channels/chan_sip.c Tue May 27 11:47:22 2008
@@ -3956,7 +3956,7 @@
 
 
 	/* Peer found in realtime, now build it in memory */
-	peer = build_peer(newpeername, var, varregs, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
+	peer = build_peer(newpeername, var, varregs, 1);
 	if (!peer) {
 		if(peerlist)
 			ast_config_destroy(peerlist);
@@ -20894,8 +20894,9 @@
 	struct sip_peer tmp_peer;
 	const char *srvlookup = NULL;
 	static int deprecation_warning = 1;
+	struct ast_str *fullcontact = ast_str_alloca(sizeof(peer->fullcontact));
 	
-	if (!realtime) {
+	if (!realtime || ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
 		/* Note we do NOT use find_peer here, to avoid realtime recursion */
 		/* We also use a case-sensitive comparison (unlike find_peer) so
 		   that case changes made to the peer name will be properly handled
@@ -20914,7 +20915,7 @@
 		if (!(peer = ao2_t_alloc(sizeof(*peer), sip_destroy_peer_fn, "allocate a peer struct")))
 			return NULL;
 
-		if (realtime) {
+		if (realtime && !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
 			ast_atomic_fetchadd_int(&rpeerobjs, 1);
 			ast_debug(3, "-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
 		} else
@@ -20958,8 +20959,12 @@
 		} else if (realtime && !strcasecmp(v->name, "name"))
 			ast_copy_string(peer->name, v->value, sizeof(peer->name));
 		else if (realtime && !strcasecmp(v->name, "fullcontact")) {
-			ast_copy_string(peer->fullcontact, v->value, sizeof(peer->fullcontact));
-			peer->rt_fromcontact = TRUE;
+			/* Reconstruct field, because realtime separates our value at the ';' */
+			if (fullcontact->used > 0) {
+				ast_str_append(&fullcontact, 0, ";%s", v->value);
+			} else {
+				ast_str_set(&fullcontact, 0, "%s", v->value);
+			}
 		} else if (!strcasecmp(v->name, "secret")) 
 			ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
 		else if (!strcasecmp(v->name, "md5secret")) 
@@ -21182,6 +21187,11 @@
 		}
 	}
 
+	if (fullcontact->used > 0) {
+		ast_copy_string(peer->fullcontact, fullcontact->str, sizeof(peer->fullcontact));
+		peer->rt_fromcontact = TRUE;
+	}
+
 	if (srvlookup && peer->dnsmgr == NULL) {
 		char transport[MAXHOSTNAMELEN];
 		snprintf(transport, sizeof(transport), "_sip._%s", get_transport(peer->socket.type));

Modified: team/jpeeler/chan_dahdi/channels/chan_usbradio.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/channels/chan_usbradio.c?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/channels/chan_usbradio.c (original)
+++ team/jpeeler/chan_dahdi/channels/chan_usbradio.c Tue May 27 11:47:22 2008
@@ -35,14 +35,21 @@
 
 /*** MODULEINFO
 	<depend>ossaudio</depend>
-        <depend>usb</depend> 	 
+	<depend>usb</depend>
 	<defaultenabled>no</defaultenabled>
-        <member name="RADIO_RTX" displayname="Build RTX/DTX Radio Programming"> 	 
-        <defaultenabled>no</defaultenabled> 	 
-        </member> 	 
-        <member name="RADIO_XPMRX" displayname="Build Experimental Radio Protocols"> 	 
-        <defaultenabled>no</defaultenabled> 	 
-        </member>
+ ***/
+
+/*** MAKEOPTS
+<category name="MENUSELECT_CFLAGS" displayname="Compiler Flags" positive_output="yes" remove_on_change=".lastclean">
+	<member name="RADIO_RTX" displayname="Build RTX/DTX Radio Programming">
+		<defaultenabled>no</defaultenabled>
+		<depend>chan_usbradio</depend>
+	</member>
+	<member name="RADIO_XPMRX" displayname="Build Experimental Radio Protocols">
+		<defaultenabled>no</defaultenabled>
+		<depend>chan_usbradio</depend>
+	</member>
+</category>
  ***/
 
 // 20070918 1600 EDT sph at xelatec.com changing to rx driven streams
@@ -1769,7 +1776,7 @@
 		i16 i, tbuff[f->datalen];
 		for(i=0;i<f->datalen;i+=2)
 		{
-			tbuff[i]= ((i16*)(f->data))[i/2];
+			tbuff[i]= ((i16*)(f->data.ptr))[i/2];
 			tbuff[i+1]= o->txkeyed*M_Q13;
 		}
 		fwrite(tbuff,2,f->datalen,ftxcapraw);
@@ -1779,7 +1786,7 @@
 
 	// maw just take the data from the network and save it for PmrRx processing
 
-	PmrTx(o->pmrChan,(i16*)f->data);
+	PmrTx(o->pmrChan,(i16*)f->data.ptr);
 	
 	return 0;
 }
@@ -2047,7 +2054,7 @@
 		wf.subclass = AST_CONTROL_RADIO_KEY;
 		if(o->rxctcssdecode)  	
         {
-	        wf.data = o->rxctcssfreq;
+	        wf.data.ptr = o->rxctcssfreq;
 	        wf.datalen = strlen(o->rxctcssfreq) + 1;
 			TRACEO(1,("AST_CONTROL_RADIO_KEY text=%s\n",o->rxctcssfreq));
         }
@@ -2062,10 +2069,10 @@
 	f->subclass = AST_FORMAT_SLINEAR;
 	f->samples = FRAME_SIZE;
 	f->datalen = FRAME_SIZE * 2;
-	f->data = o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET;
+	f->data.ptr = o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET;
 	if (o->boost != BOOST_SCALE) {	/* scale and clip values */
 		int i, x;
-		int16_t *p = (int16_t *) f->data;
+		int16_t *p = (int16_t *) f->data.ptr;
 		for (i = 0; i < f->samples; i++) {
 			x = (p[i] * o->boost) / BOOST_SCALE;
 			if (x > 32767)

Modified: team/jpeeler/chan_dahdi/channels/chan_vpb.cc
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/channels/chan_vpb.cc?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/channels/chan_vpb.cc (original)
+++ team/jpeeler/chan_dahdi/channels/chan_vpb.cc Tue May 27 11:47:22 2008
@@ -2226,7 +2226,7 @@
 
 	/* Apply extra gain ! */
 	if( p->txswgain > MAX_VPB_GAIN )
-		a_gain_vector(p->txswgain - MAX_VPB_GAIN , (short*)frame->data, frame->datalen / sizeof(short));
+		a_gain_vector(p->txswgain - MAX_VPB_GAIN , (short*)frame->data.ptr, frame->datalen / sizeof(short));
 
 /*	ast_debug(1, "%s: vpb_write: Applied gain..\n", p->dev); */
 /*	ast_debug(1, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */
@@ -2234,9 +2234,9 @@
 	if ((p->read_state == 1) && (p->play_buf_time < 5)){
 		play_buf_time_start = ast_tvnow();
 /*		res = vpb_play_buf_sync(p->handle, (char *)frame->data, tdiff * 8 * 2); */
-		res = vpb_play_buf_sync(p->handle, (char *)frame->data, frame->datalen);
+		res = vpb_play_buf_sync(p->handle, (char *)frame->data.ptr, frame->datalen);
 		if(res == VPB_OK) {
-			short * data = (short*)frame->data;
+			short * data = (short*)frame->data.ptr;
 			ast_verb(6, "%s: vpb_write: Wrote chan (codec=%d) %d %d\n", p->dev, fmt, data[0], data[1]);
 		}
 		p->play_buf_time = ast_tvdiff_ms(ast_tvnow(), play_buf_time_start);
@@ -2392,7 +2392,7 @@
 			ast_verb(6, "%s: chanreads: applied gain\n", p->dev);
 
 			fr->subclass = afmt;
-			fr->data = readbuf;
+			fr->data.ptr = readbuf;
 			fr->datalen = readlen;
 			fr->frametype = AST_FRAME_VOICE;
 

Modified: team/jpeeler/chan_dahdi/configs/queues.conf.sample
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/configs/queues.conf.sample?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/configs/queues.conf.sample (original)
+++ team/jpeeler/chan_dahdi/configs/queues.conf.sample Tue May 27 11:47:22 2008
@@ -396,7 +396,10 @@
 ;
 ; It is important to ensure that channel drivers used for members are loaded
 ; before app_queue.so itself or they may be marked invalid until reload. This
-; can be accomplished by explicitly listing them in modules.conf before app_queue.so
+; can be accomplished by explicitly listing them in modules.conf before
+; app_queue.so.  Additionally, if you use Local channels as queue members, you
+; must also preload pbx_config.so (or pbx_ael.so, pbx_lua.so, or
+; pbx_realtime.so, depending on how your dialplan is configured).
 ;
 ;member => DAHDI/1
 ;member => DAHDI/2,10

Modified: team/jpeeler/chan_dahdi/include/asterisk/compat.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/include/asterisk/compat.h?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/include/asterisk/compat.h (original)
+++ team/jpeeler/chan_dahdi/include/asterisk/compat.h Tue May 27 11:47:22 2008
@@ -74,7 +74,7 @@
 #endif
 
 #if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
-int asprintf(char **str, const char *fmt, ...);
+int __attribute__ ((format (printf, 2, 3))) asprintf(char **str, const char *fmt, ...);
 #endif
 
 #ifndef HAVE_GETLOADAVG

Modified: team/jpeeler/chan_dahdi/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi/include/asterisk/lock.h?view=diff&rev=118379&r1=118378&r2=118379
==============================================================================
--- team/jpeeler/chan_dahdi/include/asterisk/lock.h (original)
+++ team/jpeeler/chan_dahdi/include/asterisk/lock.h Tue May 27 11:47:22 2008
@@ -50,7 +50,9 @@
 
 #include <pthread.h>
 #include <sys/param.h>
-
+#ifdef HAVE_BKTR
+#include <execinfo.h>
+#endif
 #include "asterisk/logger.h"
 
 /* internal macro to profile mutexes. Only computes the delay on
@@ -108,9 +110,15 @@
 
 #include <errno.h>
 
+#ifdef HAVE_BKTR
+#define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, 1, { NULL }, { 0 }, 0, { NULL }, { 0 }, {{{ 0 }}}, PTHREAD_MUTEX_INIT_VALUE }
+#define AST_MUTEX_INIT_VALUE_NOTRACKING \
+                             { PTHREAD_MUTEX_INIT_VALUE, 0, { NULL }, { 0 }, 0, { NULL }, { 0 }, {{{ 0 }}}, PTHREAD_MUTEX_INIT_VALUE }
+#else
 #define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, 1, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE }
 #define AST_MUTEX_INIT_VALUE_NOTRACKING \
                              { PTHREAD_MUTEX_INIT_VALUE, 0, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE }
+#endif
 
 #define AST_MAX_REENTRANCY 10
 
@@ -125,6 +133,9 @@
 	int reentrancy;
 	const char *func[AST_MAX_REENTRANCY];
 	pthread_t thread[AST_MAX_REENTRANCY];
+#ifdef HAVE_BKTR
+	struct ast_bt backtrace[AST_MAX_REENTRANCY];
+#endif
 	pthread_mutex_t reentr_mutex;
 };
 
@@ -149,12 +160,22 @@
  * on the lock.  ast_mark_lock_acquired() will mark it as held by this thread.
  */
 #if !defined(LOW_MEMORY)
+#ifdef HAVE_BKTR
+void ast_store_lock_info(enum ast_lock_type type, const char *filename,
+	int line_num, const char *func, const char *lock_name, void *lock_addr, struct ast_bt *bt);
+#else
 void ast_store_lock_info(enum ast_lock_type type, const char *filename,
 	int line_num, const char *func, const char *lock_name, void *lock_addr);
+#endif /* HAVE_BKTR */
+
+#else
+
+#ifdef HAVE_BKTR
+#define ast_store_lock_info(I,DONT,CARE,ABOUT,THE,PARAMETERS,BUD)
 #else
 #define ast_store_lock_info(I,DONT,CARE,ABOUT,THE,PARAMETERS)
-#endif
-
+#endif /* HAVE_BKTR */
+#endif /* !defined(LOW_MEMORY) */
 
 /*!
  * \brief Mark the last lock as acquired
@@ -181,12 +202,34 @@
  * be removed from the current thread's lock info struct.
  */
 #if !defined(LOW_MEMORY)
+#ifdef HAVE_BKTR
+void ast_remove_lock_info(void *lock_addr, struct ast_bt *bt);
+#else
 void ast_remove_lock_info(void *lock_addr);
+#endif /* HAVE_BKTR */
+#else
+#ifdef HAVE_BKTR
+#define ast_remove_lock_info(ignore,me)
 #else
 #define ast_remove_lock_info(ignore)
-#endif
-
-
+#endif /* HAVE_BKTR */
+#endif /* !defined(LOW_MEMORY) */
+
+#ifdef HAVE_BKTR
+static inline void __dump_backtrace(struct ast_bt *bt, int canlog)
+{
+	char **strings;
+
+	size_t i;
+
+	strings = backtrace_symbols(bt->addresses, bt->num_frames);
+
+	for (i = 0; i < bt->num_frames; i++)
+		__ast_mutex_logger("%s\n", strings[i]);
+
+	free(strings);
+}
+#endif
 
 /*!
  * \brief log info for the current lock with ast_log().
@@ -223,6 +266,9 @@
 		p_ast_mutex->lineno[i] = 0;
 		p_ast_mutex->func[i] = NULL;
 		p_ast_mutex->thread[i] = 0;
+#ifdef HAVE_BKTR
+		memset(&p_ast_mutex->backtrace[i], 0, sizeof(p_ast_mutex->backtrace[i]));
+#endif
 	}
 
 	p_ast_mutex->reentrancy = 0;
@@ -308,6 +354,9 @@
 		ast_reentrancy_lock(t);
 		__ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n",
 			    t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name);
+#ifdef HAVE_BKTR
+		__dump_backtrace(&t->backtrace[t->reentrancy-1], canlog);
+#endif
 		ast_reentrancy_unlock(t);
 		break;
 	}
@@ -325,6 +374,9 @@
 	t->func[0] = func;
 	t->reentrancy = 0;
 	t->thread[0] = 0;
+#ifdef HAVE_BKTR
+	memset(&t->backtrace[0], 0, sizeof(t->backtrace[0]));
+#endif
 	ast_reentrancy_unlock(t);
 	delete_reentrancy_cs(t);
 
@@ -336,6 +388,9 @@
 {
 	int res;
 	int canlog = strcmp(filename, "logger.c") & t->track;
+#ifdef HAVE_BKTR
+	struct ast_bt *bt = NULL;
+#endif
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
@@ -352,8 +407,17 @@
 	}
 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
 
-	if (t->track)
+	if (t->track) {
+#ifdef HAVE_BKTR
+		ast_reentrancy_lock(t);
+		ast_bt_get_addresses(&t->backtrace[t->reentrancy]);
+		bt = &t->backtrace[t->reentrancy];
+		ast_reentrancy_unlock(t);
+		ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex, bt);
+#else
 		ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
+#endif
+	}
 
 #ifdef DETECT_DEADLOCKS
 	{
@@ -373,9 +437,15 @@
 					__ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
 							   filename, lineno, func, (int) wait_time, mutex_name);
 					ast_reentrancy_lock(t);
+#ifdef HAVE_BKTR
+					__dump_backtrace(&t->backtrace[t->reentrancy], canlog);
+#endif
 					__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
 							   t->file[t->reentrancy-1], t->lineno[t->reentrancy-1],
 							   t->func[t->reentrancy-1], mutex_name);
+#ifdef HAVE_BKTR
+					__dump_backtrace(&t->backtrace[t->reentrancy-1], canlog);
+#endif
 					ast_reentrancy_unlock(t);
 					reported_wait = wait_time;
 				}
@@ -409,8 +479,20 @@
 		if (t->track)
 			ast_mark_lock_acquired(&t->mutex);
 	} else {
+#ifdef HAVE_BKTR
+		if (t->reentrancy) {
+			ast_reentrancy_lock(t);
+			bt = &t->backtrace[t->reentrancy-1];
+			ast_reentrancy_unlock(t);
+		} else {
+			bt = NULL;
+		}
+		if (t->track)
+			ast_remove_lock_info(&t->mutex, bt);
+#else
 		if (t->track)
 			ast_remove_lock_info(&t->mutex);
+#endif
 		__ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n",
 				   filename, lineno, func, strerror(res));
 		DO_THREAD_CRASH;
@@ -424,6 +506,9 @@
 {
 	int res;
 	int canlog = strcmp(filename, "logger.c") & t->track;
+#ifdef HAVE_BKTR
+	struct ast_bt *bt = NULL;
+#endif
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
@@ -440,8 +525,17 @@
 	}
 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
 
-	if (t->track)
+	if (t->track) {
+#ifdef HAVE_BKTR
+		ast_reentrancy_lock(t);
+		ast_bt_get_addresses(&t->backtrace[t->reentrancy]);
+		bt = &t->backtrace[t->reentrancy];
+		ast_reentrancy_unlock(t);
+		ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex, bt);
+#else
 		ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
+#endif
+	}
 
 	if (!(res = pthread_mutex_trylock(&t->mutex))) {
 		ast_reentrancy_lock(t);
@@ -470,6 +564,9 @@
 {
 	int res;
 	int canlog = strcmp(filename, "logger.c") & t->track;
+#ifdef HAVE_BKTR
+	struct ast_bt *bt = NULL;
+#endif
 
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
@@ -490,6 +587,9 @@
 				   filename, lineno, func, mutex_name);
 		__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
 				   t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name);
+#ifdef HAVE_BKTR
+		__dump_backtrace(&t->backtrace[t->reentrancy-1], canlog);
+#endif
 		DO_THREAD_CRASH;
 	}
 
@@ -505,11 +605,21 @@
 		t->func[t->reentrancy] = NULL;
 		t->thread[t->reentrancy] = 0;
 	}
+
+#ifdef HAVE_BKTR
+	if (t->reentrancy) {
+		bt = &t->backtrace[t->reentrancy - 1];
+	}
+#endif
 	ast_reentrancy_unlock(t);
 
-	if (t->track)
+	if (t->track) {
+#ifdef HAVE_BKTR
+		ast_remove_lock_info(&t->mutex, bt);
+#else
 		ast_remove_lock_info(&t->mutex);
-
+#endif
+	}
 	if ((res = pthread_mutex_unlock(&t->mutex))) {
 		__ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n", 
 				   filename, lineno, func, strerror(res));
@@ -549,6 +659,9 @@
 {
 	int res;
 	int canlog = strcmp(filename, "logger.c") & t->track;
+#ifdef HAVE_BKTR
+	struct ast_bt *bt = NULL;
+#endif
 
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS

[... 1613 lines stripped ...]



More information about the asterisk-commits mailing list