[asterisk-commits] branch oej/metermaids-trunk r11848 - in /team/oej/metermaids-trunk: ./ apps/ ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Mar 5 05:17:46 MST 2006


Author: oej
Date: Sun Mar  5 06:17:00 2006
New Revision: 11848

URL: http://svn.digium.com/view/asterisk?rev=11848&view=rev
Log:
Update to trunk

Added:
    team/oej/metermaids-trunk/configs/res_snmp.conf.sample
      - copied unchanged from r11817, trunk/configs/res_snmp.conf.sample
    team/oej/metermaids-trunk/doc/asterisk-mib.txt
      - copied unchanged from r11817, trunk/doc/asterisk-mib.txt
    team/oej/metermaids-trunk/doc/digium-mib.txt
      - copied unchanged from r11817, trunk/doc/digium-mib.txt
    team/oej/metermaids-trunk/doc/snmp.txt
      - copied unchanged from r11817, trunk/doc/snmp.txt
    team/oej/metermaids-trunk/funcs/func_curl.c
      - copied unchanged from r11817, trunk/funcs/func_curl.c
    team/oej/metermaids-trunk/res/res_snmp.c
      - copied unchanged from r11817, trunk/res/res_snmp.c
    team/oej/metermaids-trunk/res/snmp/
      - copied from r11817, trunk/res/snmp/
    team/oej/metermaids-trunk/res/snmp/agent.c
      - copied unchanged from r11817, trunk/res/snmp/agent.c
    team/oej/metermaids-trunk/res/snmp/agent.h
      - copied unchanged from r11817, trunk/res/snmp/agent.h
Removed:
    team/oej/metermaids-trunk/apps/app_curl.c
Modified:
    team/oej/metermaids-trunk/   (props changed)
    team/oej/metermaids-trunk/CREDITS
    team/oej/metermaids-trunk/Makefile
    team/oej/metermaids-trunk/README
    team/oej/metermaids-trunk/UPGRADE.txt
    team/oej/metermaids-trunk/apps/Makefile
    team/oej/metermaids-trunk/apps/app_directed_pickup.c
    team/oej/metermaids-trunk/apps/app_meetme.c
    team/oej/metermaids-trunk/apps/app_mixmonitor.c
    team/oej/metermaids-trunk/apps/app_rpt.c
    team/oej/metermaids-trunk/apps/app_sayunixtime.c
    team/oej/metermaids-trunk/apps/app_skel.c
    team/oej/metermaids-trunk/apps/app_sms.c
    team/oej/metermaids-trunk/apps/app_voicemail.c
    team/oej/metermaids-trunk/asterisk.c
    team/oej/metermaids-trunk/asterisk.sgml
    team/oej/metermaids-trunk/build_tools/make_build_h
    team/oej/metermaids-trunk/build_tools/make_svn_branch_name
    team/oej/metermaids-trunk/cdr.c
    team/oej/metermaids-trunk/cdr/cdr_csv.c
    team/oej/metermaids-trunk/cdr/cdr_manager.c
    team/oej/metermaids-trunk/cdr/cdr_odbc.c
    team/oej/metermaids-trunk/cdr/cdr_pgsql.c
    team/oej/metermaids-trunk/cdr/cdr_tds.c
    team/oej/metermaids-trunk/channel.c
    team/oej/metermaids-trunk/channels/Makefile
    team/oej/metermaids-trunk/channels/chan_iax2.c
    team/oej/metermaids-trunk/channels/chan_misdn.c
    team/oej/metermaids-trunk/channels/chan_sip.c
    team/oej/metermaids-trunk/channels/chan_vpb.c
    team/oej/metermaids-trunk/channels/chan_zap.c
    team/oej/metermaids-trunk/channels/misdn/Makefile
    team/oej/metermaids-trunk/channels/misdn/isdn_lib.c
    team/oej/metermaids-trunk/channels/misdn/isdn_msg_parser.c
    team/oej/metermaids-trunk/channels/misdn_config.c
    team/oej/metermaids-trunk/cli.c
    team/oej/metermaids-trunk/codecs/gsm/Makefile
    team/oej/metermaids-trunk/configs/cdr.conf.sample
    team/oej/metermaids-trunk/configs/iax.conf.sample
    team/oej/metermaids-trunk/configs/misdn.conf.sample
    team/oej/metermaids-trunk/configs/sip.conf.sample
    team/oej/metermaids-trunk/doc/00README.1st
    team/oej/metermaids-trunk/doc/enum.txt
    team/oej/metermaids-trunk/doc/misdn.txt
    team/oej/metermaids-trunk/formats/format_h264.c
    team/oej/metermaids-trunk/formats/format_pcm.c
    team/oej/metermaids-trunk/formats/format_pcm_alaw.c
    team/oej/metermaids-trunk/formats/msgsm.h
    team/oej/metermaids-trunk/frame.c
    team/oej/metermaids-trunk/funcs/Makefile
    team/oej/metermaids-trunk/funcs/func_cdr.c
    team/oej/metermaids-trunk/funcs/func_enum.c
    team/oej/metermaids-trunk/funcs/func_odbc.c
    team/oej/metermaids-trunk/funcs/func_strings.c
    team/oej/metermaids-trunk/include/asterisk/cdr.h
    team/oej/metermaids-trunk/include/asterisk/linkedlists.h
    team/oej/metermaids-trunk/include/asterisk/logger.h
    team/oej/metermaids-trunk/include/asterisk/sha1.h
    team/oej/metermaids-trunk/include/asterisk/strings.h
    team/oej/metermaids-trunk/indications.c
    team/oej/metermaids-trunk/io.c
    team/oej/metermaids-trunk/jitterbuf.c
    team/oej/metermaids-trunk/jitterbuf.h
    team/oej/metermaids-trunk/loader.c
    team/oej/metermaids-trunk/logger.c
    team/oej/metermaids-trunk/pbx/pbx_dundi.c
    team/oej/metermaids-trunk/res/Makefile
    team/oej/metermaids-trunk/res/res_agi.c
    team/oej/metermaids-trunk/res/res_config_odbc.c
    team/oej/metermaids-trunk/res/res_features.c
    team/oej/metermaids-trunk/res/res_monitor.c
    team/oej/metermaids-trunk/res/res_osp.c
    team/oej/metermaids-trunk/say.c
    team/oej/metermaids-trunk/translate.c
    team/oej/metermaids-trunk/utils.c

Propchange: team/oej/metermaids-trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/oej/metermaids-trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/oej/metermaids-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Mar  5 06:17:00 2006
@@ -1,1 +1,1 @@
-/trunk:1-10648
+/trunk:1-11847

Modified: team/oej/metermaids-trunk/CREDITS
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/CREDITS?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/CREDITS (original)
+++ team/oej/metermaids-trunk/CREDITS Sun Mar  5 06:17:00 2006
@@ -59,8 +59,8 @@
 Jayson Vantuyl - Manager protocol changes, various other bugs.
 	jvantuyl at computingedge.net
 Thorsten Lockert - OpenBSD, FreeBSD ports, making MacOS X port run on 10.3,
-	dialplan include verification, route lookup on OpenBSD, various other
-	bugs. tholo at sigmasoft.com
+	dialplan include verification, route lookup on OpenBSD, SNMP agent
+	support (res_snmp), various other bugs. tholo at sigmasoft.com
 Brian West - ODBC support and Bug Marshaling  
 Josh Roberson - chan_zap reload support, Advanced Voicemail Features, other misc. patches,
 	and Bug Marshalling. - josh at asteriasgi.com, http://www.asteriasgi.com

Modified: team/oej/metermaids-trunk/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/Makefile?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/Makefile (original)
+++ team/oej/metermaids-trunk/Makefile Sun Mar  5 06:17:00 2006
@@ -32,6 +32,8 @@
   OSARCH=$(CROSS_ARCH)
   OSREV=$(CROSS_REV)
 endif
+
+PWD=$(shell pwd)
 
 # Remember the MAKELEVEL at the top
 MAKETOPLEVEL?=$(MAKELEVEL)
@@ -222,17 +224,22 @@
   MPG123TARG=linux
 endif
 
-PWD=$(shell pwd)
 GREP=grep
+ID=id
 
 ifeq ($(OSARCH),SunOS)
   GREP=/usr/xpg4/bin/grep
   M4=/usr/local/bin/m4
+  ID=/usr/xpg4/bin/id
 endif
 
 INCLUDE+=-Iinclude -I../include
 ASTCFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
 ASTCFLAGS+=$(OPTIMIZE)
+ASTCFLAGS+=# -Werror -Wunused
+ifeq ($(shell gcc -v 2>&1 | grep 'gcc version' | cut -f3 -d' ' | cut -f1 -d.),4)
+ASTCFLAGS+= -Wno-pointer-sign
+endif
 ASTOBJ=-o asterisk
 
 ifeq ($(findstring BSD,$(OSARCH)),BSD)
@@ -549,7 +556,7 @@
 	$(MAKE) -C stdtime clean
 
 datafiles: all
-	if [ x`whoami` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
+	if [ x`$(ID) -un` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
 	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
 	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/priv-callerintros
 	for x in sounds/digits/*.gsm; do \

Modified: team/oej/metermaids-trunk/README
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/README?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/README (original)
+++ team/oej/metermaids-trunk/README Sun Mar  5 06:17:00 2006
@@ -67,7 +67,7 @@
   In order to discover new features to use, please check the configuration
 examples in the /configs directory of the source code distribution. 
 To discover the major new features of Asterisk 1.2, please visit 
-http://www.astricon.net/asterisk1-2/
+http://edvina.net/asterisk1-2/
 
 * NEW INSTALLATIONS
 

Modified: team/oej/metermaids-trunk/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/UPGRADE.txt?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/UPGRADE.txt (original)
+++ team/oej/metermaids-trunk/UPGRADE.txt Sun Mar  5 06:17:00 2006
@@ -37,6 +37,9 @@
   functions.  You are encouraged to move towards the associated dialplan
   function, as these variables will be removed in a future release.
 
+* The CDR-CSV variables uniqueid, userfield, and basing time on GMT are now 
+  adjustable from cdr.conf, instead of recompiling.
+
 Functions:
 
 * The function ${CHECK_MD5()} has been deprecated in favor of using an
@@ -47,10 +50,8 @@
   modules.conf file then you will need to explicitly load the modules that
   contain the functions you want to use.
 
-* The ENUMLOOKUP() function no longer supplies a default zone for searching; instead,
-  it uses the default zone(s) defined in enum.conf. In addition, when the 'c'
-  option (for counting the number of records is specified), but the lookup fails
-  to match any records, the returned value will now be "0" instead of blank.
+* The ENUMLOOKUP() function with the 'c' option (for counting the number of records),
+  but the lookup fails to match any records, the returned value will now be "0" instead of blank.
 
 The SIP channel:
 

Modified: team/oej/metermaids-trunk/apps/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/apps/Makefile?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/apps/Makefile (original)
+++ team/oej/metermaids-trunk/apps/Makefile Sun Mar  5 06:17:00 2006
@@ -30,14 +30,6 @@
 
 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/osp/osp.h $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h),)
   MODS:=$(filter-out app_osplookup.so,$(MODS))
-endif
-
-ifneq ($(shell if [[ 0x`$(CROSS_COMPILE_BIN)curl-config --vernum` -ge 0x70907 ]]; then echo "OK" ; fi),)
-  CURLLIBS:=$(shell $(CROSS_COMPILE_BIN)curl-config --libs)
-endif
-
-ifeq (${CURLLIBS},)
-  MODS:=$(filter-out app_curl.so,$(MODS))
 endif
 
 ifneq (${WITH_SMDI},)
@@ -83,9 +75,6 @@
 
 uninstall:
 
-app_curl.so: app_curl.o
-	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CURLLIBS)
-
 look:	look.c
 	$(CC) -pipe -O6 -g look.c -o look -lncurses
 

Modified: team/oej/metermaids-trunk/apps/app_directed_pickup.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/apps/app_directed_pickup.c?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/apps/app_directed_pickup.c (original)
+++ team/oej/metermaids-trunk/apps/app_directed_pickup.c Sun Mar  5 06:17:00 2006
@@ -82,7 +82,7 @@
 		origin = ast_get_channel_by_exten_locked(exten, context);
 		if (origin) {
 			ast_cdr_getvar(origin->cdr, "dstchannel", &tmp, workspace,
-					sizeof(workspace), 0);
+					sizeof(workspace), 0, 0);
 			if (tmp) {
 				/* We have a possible channel... now we need to find it! */
 				target = ast_get_channel_by_name_locked(tmp);

Modified: team/oej/metermaids-trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/apps/app_meetme.c?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/apps/app_meetme.c (original)
+++ team/oej/metermaids-trunk/apps/app_meetme.c Sun Mar  5 06:17:00 2006
@@ -1558,7 +1558,7 @@
 					if (!user->listen.actual && 
 						((confflags & CONFFLAG_MONITOR) || 
 						 (user->adminflags & ADMINFLAG_MUTED) ||
-						 (user->talking && (confflags & CONFFLAG_OPTIMIZETALKER))
+						 (!user->talking && (confflags & CONFFLAG_OPTIMIZETALKER))
 						 )) {
 						int index;
 						for (index=0;index<AST_FRAME_BITS;index++)

Modified: team/oej/metermaids-trunk/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/apps/app_mixmonitor.c?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/apps/app_mixmonitor.c (original)
+++ team/oej/metermaids-trunk/apps/app_mixmonitor.c Sun Mar  5 06:17:00 2006
@@ -217,6 +217,17 @@
 	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_2 "Begin MixMonitor Recording %s\n", name);
 	
+	if (mixmonitor->post_process) {
+		char *p;
+
+		for (p = mixmonitor->post_process; *p ; p++) {
+			if (*p == '^' && *(p+1) == '{') {
+				*p = '$';
+			}
+		}
+		pbx_substitute_variables_helper(mixmonitor->chan, mixmonitor->post_process, post_process, sizeof(post_process) - 1);
+	}
+
 	while (1) {
 		struct ast_frame *next;
 		int write;
@@ -251,17 +262,6 @@
 		ast_mutex_unlock(&spy.lock);
 	}
 	
-	if (mixmonitor->post_process) {
-		char *p;
-
-		for (p = mixmonitor->post_process; *p ; p++) {
-			if (*p == '^' && *(p+1) == '{') {
-				*p = '$';
-			}
-		}
-		pbx_substitute_variables_helper(mixmonitor->chan, mixmonitor->post_process, post_process, sizeof(post_process) - 1);
-	}
-
 	stopmon(mixmonitor->chan, &spy);
 
 	if (option_verbose > 1)

Modified: team/oej/metermaids-trunk/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/apps/app_rpt.c?rev=11848&r1=11847&r2=11848&view=diff
==============================================================================
--- team/oej/metermaids-trunk/apps/app_rpt.c (original)
+++ team/oej/metermaids-trunk/apps/app_rpt.c Sun Mar  5 06:17:00 2006
@@ -20,8 +20,8 @@
 /*! \file
  *
  * \brief Radio Repeater / Remote Base program 
- *  version 0.39 12/19/05
- *
+ *  version 0.42 02/25/06
+ * 
  * \author Jim Dixon, WB6NIL <jim at lambdatel.com>
  *
  * \note Serious contributions by Steve RoDgers, WA6ZFT <hwstar at rodgers.sdcoxmail.com>
@@ -107,6 +107,9 @@
 /* maximum digits in DTMF buffer, and seconds after * for DTMF command timeout */
 
 #define	MAXDTMF 32
+#define	MAXMACRO 2048
+#define	MACROTIME 100
+#define	MACROPTIME 500
 #define	DTMF_TIMEOUT 3
 
 #define	DISC_TIME 10000  /* report disc after 10 seconds of no connect */
@@ -123,6 +126,7 @@
 
 #define	NODES "nodes"
 #define MEMORY "memory"
+#define MACRO "macro"
 #define	FUNCTIONS "functions"
 #define TELEMETRY "telemetry"
 #define MORSE "morse"
@@ -147,7 +151,7 @@
 enum{ID,PROC,TERM,COMPLETE,UNKEY,REMDISC,REMALREADY,REMNOTFOUND,REMGO,
 	CONNECTED,CONNFAIL,STATUS,TIMEOUT,ID1, STATS_TIME,
 	STATS_VERSION, IDTALKOVER, ARB_ALPHA, TEST_TONE, REV_PATCH,
-	TAILMSG};
+	TAILMSG, MACRO_NOTFOUND, MACRO_BUSY};
 
 enum {REM_SIMPLEX,REM_MINUS,REM_PLUS};
 
@@ -206,7 +210,7 @@
 #include "asterisk/say.h"
 #include "asterisk/localtime.h"
 
-static  char *tdesc = "Radio Repeater / Remote Base  version 0.39  12/19/2005";
+static  char *tdesc = "Radio Repeater / Remote Base  version 0.42  02/25/2006";
 
 static char *app = "Rpt";
 
@@ -247,7 +251,7 @@
 "            available to the phone user.\n"
 "\n";
 
-static int debug = 0;  /* Set this >0 for extra debug output */
+static int debug = 0;  /* FIXME Set this >0 for extra debug output */
 static int nrpts = 0;
 
 char *discstr = "!!DISCONNECT!!";
@@ -256,6 +260,7 @@
 
 struct	ast_config *cfg;
 
+STANDARD_LOCAL_USER;
 LOCAL_USER_DECL;
 
 #define	MSWAIT 200
@@ -362,15 +367,16 @@
 	char tonotify;
 	char enable;
 	char dtmfbuf[MAXDTMF];
+	char macrobuf[MAXMACRO];
 	char rem_dtmfbuf[MAXDTMF];
 	char cmdnode[50];
 	struct ast_channel *rxchannel,*txchannel;
 	struct ast_channel *pchannel,*txpchannel, *remchannel;
 	struct rpt_tele tele;
 	pthread_t rpt_call_thread,rpt_thread;
-	time_t rem_dtmf_time,dtmf_time_rem;
+	time_t dtmf_time,rem_dtmf_time,dtmf_time_rem;
 	int tailtimer,totimer,idtimer,txconf,conf,callmode,cidx,scantimer,tmsgtimer;
-	int mustid;
+	int mustid,tailid;
 	int politeid;
 	int dtmfidx,rem_dtmfidx;
 	long	retxtimer;
@@ -390,6 +396,7 @@
 	char funcchar;
 	char endchar;
 	char stopgen;
+	int macro_longest;
 	int phone_longestfunc;
 	int dphone_longestfunc;
 	int link_longestfunc;
@@ -403,8 +410,197 @@
 	int tailmessagen;
 	time_t disgorgetime;
 	time_t lastthreadrestarttime;
+	long	macrotimer;
+	char	*macro;
+	char	*startupmacro;
+	char	*memory;
 	char	nobusyout;
 } rpt_vars[MAXRPTS];	
+
+
+#ifdef	APP_RPT_LOCK_DEBUG
+
+#warning COMPILING WITH LOCK-DEBUGGING ENABLED!!
+
+#define	MAXLOCKTHREAD 100
+
+#define rpt_mutex_lock(x) _rpt_mutex_lock(x,myrpt,__LINE__)
+#define rpt_mutex_unlock(x) _rpt_mutex_unlock(x,myrpt,__LINE__)
+
+struct lockthread
+{
+	pthread_t id;
+	int lockcount;
+	int lastlock;
+	int lastunlock;
+} lockthreads[MAXLOCKTHREAD];
+
+
+struct by_lightning
+{
+	int line;
+	struct timeval tv;
+	struct rpt *rpt;
+	struct lockthread lockthread;
+} lock_ring[32];
+
+
+int lock_ring_index = 0;
+
+AST_MUTEX_DEFINE_STATIC(locklock);
+
+static struct lockthread *get_lockthread(pthread_t id)
+{
+int	i;
+
+	for(i = 0; i < MAXLOCKTHREAD; i++)
+	{
+		if (lockthreads[i].id == id) return(&lockthreads[i]);
+	}
+	return(NULL);
+}
+
+static struct lockthread *put_lockthread(pthread_t id)
+{
+int	i;
+
+	for(i = 0; i < MAXLOCKTHREAD; i++)
+	{
+		if (lockthreads[i].id == id)
+			return(&lockthreads[i]);
+	}
+	for(i = 0; i < MAXLOCKTHREAD; i++)
+	{
+		if (!lockthreads[i].id)
+		{
+			lockthreads[i].lockcount = 0;
+			lockthreads[i].lastlock = 0;
+			lockthreads[i].lastunlock = 0;
+			lockthreads[i].id = id;
+			return(&lockthreads[i]);
+		}
+	}
+	return(NULL);
+}
+
+
+static void rpt_mutex_spew(void)
+{
+	struct by_lightning lock_ring_copy[32];
+	int lock_ring_index_copy;
+	int i,j;
+	long long diff;
+	char a[100];
+	struct timeval lasttv;
+
+	ast_mutex_lock(&locklock);
+	memcpy(&lock_ring_copy, &lock_ring, sizeof(lock_ring_copy));
+	lock_ring_index_copy = lock_ring_index;
+	ast_mutex_unlock(&locklock);
+
+	lasttv.tv_sec = lasttv.tv_usec = 0;
+	for(i = 0 ; i < 32 ; i++)
+	{
+		j = (i + lock_ring_index_copy) % 32;
+		strftime(a,sizeof(a) - 1,"%m/%d/%Y %H:%M:%S",
+			localtime(&lock_ring_copy[j].tv.tv_sec));
+		diff = 0;
+		if(lasttv.tv_sec)
+		{
+			diff = (lock_ring_copy[j].tv.tv_sec - lasttv.tv_sec)
+				* 1000000;
+			diff += (lock_ring_copy[j].tv.tv_usec - lasttv.tv_usec);
+		}
+		lasttv.tv_sec = lock_ring_copy[j].tv.tv_sec;
+		lasttv.tv_usec = lock_ring_copy[j].tv.tv_usec;
+		if (!lock_ring_copy[j].tv.tv_sec) continue;
+		if (lock_ring_copy[j].line < 0)
+		{
+			ast_log(LOG_NOTICE,"LOCKDEBUG [#%d] UNLOCK app_rpt.c:%d node %s pid %x diff %lld us at %s.%06d\n",
+				i - 31,-lock_ring_copy[j].line,lock_ring_copy[j].rpt->name,(int) lock_ring_copy[j].lockthread.id,diff,a,(int)lock_ring_copy[j].tv.tv_usec);
+		}
+		else
+		{
+			ast_log(LOG_NOTICE,"LOCKDEBUG [#%d] LOCK app_rpt.c:%d node %s pid %x diff %lld us at %s.%06d\n",
+				i - 31,lock_ring_copy[j].line,lock_ring_copy[j].rpt->name,(int) lock_ring_copy[j].lockthread.id,diff,a,(int)lock_ring_copy[j].tv.tv_usec);
+		}
+	}
+}
+
+
+static void _rpt_mutex_lock(ast_mutex_t *lockp, struct rpt *myrpt, int line)
+{
+struct lockthread *t;
+pthread_t id;
+
+	id = pthread_self();
+	ast_mutex_lock(&locklock);
+	t = put_lockthread(id);
+	if (!t)
+	{
+		ast_mutex_unlock(&locklock);
+		return;
+	}
+	if (t->lockcount)
+	{
+		int lastline = t->lastlock;
+		ast_mutex_unlock(&locklock);
+		ast_log(LOG_NOTICE,"rpt_mutex_lock: Double lock request line %d node %s pid %x, last lock was line %d\n",line,myrpt->name,(int) t->id,lastline);
+		rpt_mutex_spew();
+		return;
+	}
+	t->lastlock = line;
+	t->lockcount = 1;
+	gettimeofday(&lock_ring[lock_ring_index].tv, NULL);
+	lock_ring[lock_ring_index].rpt = myrpt;
+	memcpy(&lock_ring[lock_ring_index].lockthread,t,sizeof(struct lockthread));
+	lock_ring[lock_ring_index++].line = line;
+	if(lock_ring_index == 32)
+		lock_ring_index = 0;
+	ast_mutex_unlock(&locklock);
+	ast_mutex_lock(lockp);
+}
+
+
+static void _rpt_mutex_unlock(ast_mutex_t *lockp, struct rpt *myrpt, int line)
+{
+struct lockthread *t;
+pthread_t id;
+
+	id = pthread_self();
+	ast_mutex_lock(&locklock);
+	t = put_lockthread(id);
+	if (!t)
+	{
+		ast_mutex_unlock(&locklock);
+		return;
+	}
+	if (!t->lockcount)
+	{
+		int lastline = t->lastunlock;
+		ast_mutex_unlock(&locklock);
+		ast_log(LOG_NOTICE,"rpt_mutex_lock: Double un-lock request line %d node %s pid %x, last un-lock was line %d\n",line,myrpt->name,(int) t->id,lastline);
+		rpt_mutex_spew();
+		return;
+	}
+	t->lastunlock = line;
+	t->lockcount = 0;
+	gettimeofday(&lock_ring[lock_ring_index].tv, NULL);
+	lock_ring[lock_ring_index].rpt = myrpt;
+	memcpy(&lock_ring[lock_ring_index].lockthread,t,sizeof(struct lockthread));
+	lock_ring[lock_ring_index++].line = -line;
+	if(lock_ring_index == 32)
+		lock_ring_index = 0;
+	ast_mutex_unlock(&locklock);
+	ast_mutex_unlock(lockp);
+}
+
+#else  /* APP_RPT_LOCK_DEBUG */
+
+#define rpt_mutex_lock(x) ast_mutex_lock(x)
+#define rpt_mutex_unlock(x) ast_mutex_unlock(x)
+
+#endif  /* APP_RPT_LOCK_DEBUG */
 
 /*
 * CLI extensions
@@ -412,15 +608,32 @@
 
 /* Debug mode */
 static int rpt_do_debug(int fd, int argc, char *argv[]);
+static int rpt_do_dump(int fd, int argc, char *argv[]);
+static int rpt_do_frog(int fd, int argc, char *argv[]);
 
 static char debug_usage[] =
 "Usage: rpt debug level {0-7}\n"
 "       Enables debug messages in app_rpt\n";
-                                                                                                                                
+
+static char dump_usage[] =
+"Usage: rpt dump <nodename>\n"
+"       Dumps struct debug info to log\n";
+
+static char frog_usage[] =
+"Usage: frog [warp_factor]\n"
+"       Performs frog-in-a-blender calculations (Jacobsen Corollary)\n";
+
 static struct ast_cli_entry  cli_debug =
-        { { "rpt", "debug", "level" }, rpt_do_debug, "Enable app_rpt debugging", debug_usage };
-
-
+        { { "rpt", "debug", "level" }, rpt_do_debug, 
+		"Enable app_rpt debugging", debug_usage };
+
+static struct ast_cli_entry  cli_dump =
+        { { "rpt", "dump" }, rpt_do_dump,
+		"Dump app_rpt structs for debugging", dump_usage };
+
+static struct ast_cli_entry  cli_frog =
+        { { "frog" }, rpt_do_frog,
+		"Perform frog-in-a-blender calculations", frog_usage };
 
 /*
 * Telemetry defaults
@@ -460,6 +673,7 @@
 static int function_status(struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink);
 static int function_cop(struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink);
 static int function_remote(struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink);
+static int function_macro(struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink);
 /*
 * Function table
 */
@@ -470,7 +684,8 @@
 	{"autopatchdn", function_autopatchdn},
 	{"ilink", function_ilink},
 	{"status", function_status},
-	{"remote", function_remote}
+	{"remote", function_remote},
+	{"macro", function_macro}
 } ;
 	
 static int finddelim(char *str,char *strp[])
@@ -542,8 +757,49 @@
         debug = newlevel;                                                                                                                          
         return RESULT_SUCCESS;
 }
+
+/*
+* Dump rpt struct debugging onto console
+*/
                                                                                                                                  
-
+static int rpt_do_dump(int fd, int argc, char *argv[])
+{
+	int i;
+
+        if (argc != 3)
+                return RESULT_SHOWUSAGE;
+
+	for(i = 0; i < nrpts; i++)
+	{
+		if (!strcmp(argv[2],rpt_vars[i].name))
+		{
+			rpt_vars[i].disgorgetime = time(NULL) + 10; /* Do it 10 seconds later */
+		        ast_cli(fd, "app_rpt struct dump requested for node %s\n",argv[2]);
+		        return RESULT_SUCCESS;
+		}
+	}
+	return RESULT_FAILURE;
+}
+
+/*
+* Perform frong-in-a-blender calculations (Jacobsen Corollary) 
+*/
+                                                                                                                                 
+static int rpt_do_frog(int fd, int argc, char *argv[])
+{
+	double warpone = 75139293848.398696166028333356763;
+	double warpfactor = 1.0;
+
+        if (argc > 2) return RESULT_SHOWUSAGE;
+	if ((argc > 1) && (sscanf(argv[1],"%lf",&warpfactor) != 1))
+                return RESULT_SHOWUSAGE;
+
+        ast_cli(fd, "A frog in a blender with a base diameter of 3 inches going\n");
+        ast_cli(fd, "%lf RPM will be travelling at warp factor %lf,\n",
+		warpfactor * warpfactor * warpfactor * warpone,warpfactor);
+	ast_cli(fd,"based upon the Jacobsen Frog Corollary.\n");
+	return RESULT_FAILURE;
+}
 
 static int play_tone_pair(struct ast_channel *chan, int f1, int f2, int duration, int amplitude)
 {
@@ -1028,35 +1284,37 @@
 time_t t;
 struct tm localtm;
 
-
 	/* get a pointer to myrpt */
 	myrpt = mytele->rpt;
 
 	/* Snag copies of a few key myrpt variables */
-	ast_mutex_lock(&myrpt->lock);
+	rpt_mutex_lock(&myrpt->lock);
+	insque((struct qelem *)mytele, (struct qelem *)myrpt->tele.next); /* Moved from rpt_telemetry() */
 	nodename = ast_strdupa(myrpt->name);
 	ident = ast_strdupa(myrpt->ident);
-	ast_mutex_unlock(&myrpt->lock);
-	
+	rpt_mutex_unlock(&myrpt->lock);
 	
 	/* allocate a pseudo-channel thru asterisk */
-	if (!(mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
+	mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+	if (!mychannel)
 	{
 		fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
-		ast_mutex_lock(&myrpt->lock);
+		rpt_mutex_lock(&myrpt->lock);
 		remque((struct qelem *)mytele);
-		ast_mutex_unlock(&myrpt->lock);
+		ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
+		rpt_mutex_unlock(&myrpt->lock);
 		free(mytele);		
 		pthread_exit(NULL);
 	}
-	ast_mutex_lock(&myrpt->lock);
+	rpt_mutex_lock(&myrpt->lock);
 	mytele->chan = mychannel; /* Save a copy of the channel so we can access it externally if need be */
-	ast_mutex_unlock(&myrpt->lock);
+	rpt_mutex_unlock(&myrpt->lock);
 	
 	/* make a conference for the tx */
 	ci.chan = 0;
-	/* If there's an ID queued, only connect the ID audio to the local tx conference so 
-		linked systems can't hear it */
+	/* If there's an ID queued, or tail message queued, */
+	/* only connect the ID audio to the local tx conference so */
+	/* linked systems can't hear it */
 	ci.confno = (((mytele->mode == ID) || (mytele->mode == IDTALKOVER) || (mytele->mode == UNKEY) || 
 		(mytele->mode == TAILMSG)) ?
 		 	myrpt->txconf : myrpt->conf);
@@ -1065,9 +1323,10 @@
 	if (ioctl(mychannel->fds[0],ZT_SETCONF,&ci) == -1)
 	{
 		ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
-		ast_mutex_lock(&myrpt->lock);
+		rpt_mutex_lock(&myrpt->lock);
 		remque((struct qelem *)mytele);
-		ast_mutex_unlock(&myrpt->lock);
+		rpt_mutex_unlock(&myrpt->lock);
+		ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 		free(mytele);		
 		ast_hangup(mychannel);
 		pthread_exit(NULL);
@@ -1110,6 +1369,16 @@
 		wait_interval(myrpt, DLY_TELEM, mychannel);
 		res = telem_lookup(mychannel, myrpt->name, "functcomplete");
 		break;
+	    case MACRO_NOTFOUND:
+		/* wait a little bit */
+		wait_interval(myrpt, DLY_TELEM, mychannel);
+		res = ast_streamfile(mychannel, "rpt/macro_notfound", mychannel->language);
+		break;
+	    case MACRO_BUSY:
+		/* wait a little bit */
+		wait_interval(myrpt, DLY_TELEM, mychannel);
+		res = ast_streamfile(mychannel, "rpt/macro_busy", mychannel->language);
+		break;
 	    case UNKEY:
 
 		/*
@@ -1117,9 +1386,9 @@
 		*/
 
 		x = get_wait_interval(myrpt, DLY_UNKEY);
-		ast_mutex_lock(&myrpt->lock);
+		rpt_mutex_lock(&myrpt->lock);
 		myrpt->unkeytocttimer = x; /* Must be protected as it is changed below */
-		ast_mutex_unlock(&myrpt->lock);
+		rpt_mutex_unlock(&myrpt->lock);
 
 		/*
 		* If there's one already queued, don't do another
@@ -1129,12 +1398,12 @@
 		unkeys_queued = 0;
                 if (tlist != &myrpt->tele)
                 {
-                        ast_mutex_lock(&myrpt->lock);
+                        rpt_mutex_lock(&myrpt->lock);
                         while(tlist != &myrpt->tele){
                                 if (tlist->mode == UNKEY) unkeys_queued++;
                                 tlist = tlist->next;
                         }
-                        ast_mutex_unlock(&myrpt->lock);
+                        rpt_mutex_unlock(&myrpt->lock);
 		}
 		if( unkeys_queued > 1){
 			imdone = 1;
@@ -1143,7 +1412,6 @@
 
 		/* Wait for the telemetry timer to expire */
 		/* Periodically check the timer since it can be re-initialized above */
-
 		while(myrpt->unkeytocttimer)
 		{
 			int ctint;
@@ -1152,15 +1420,14 @@
 			else
 				ctint = myrpt->unkeytocttimer;
 			ast_safe_sleep(mychannel, ctint);
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 			if(myrpt->unkeytocttimer < ctint)
 				myrpt->unkeytocttimer = 0;
 			else
 				myrpt->unkeytocttimer -= ctint;
-			ast_mutex_unlock(&myrpt->lock);
-		}
-	
-
+			rpt_mutex_unlock(&myrpt->lock);
+		}
+	
 		/*
 		* Now, the carrier on the rptr rx should be gone. 
 		* If it re-appeared, then forget about sending the CT
@@ -1176,7 +1443,7 @@
 		l = myrpt->links.next;
 		if (l != &myrpt->links)
 		{
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 			while(l != &myrpt->links)
 			{
 				if (l->name[0] == '0')
@@ -1191,7 +1458,7 @@
 				}
 				l = l->next;
 			}
-			ast_mutex_unlock(&myrpt->lock);
+			rpt_mutex_unlock(&myrpt->lock);
 		}
 		if (haslink)
 		{
@@ -1217,7 +1484,6 @@
 			if(res)
 			 	ast_log(LOG_WARNING, "telem_lookup:ctx failed on %s\n", mychannel->name);		
 		}	
-			
 		if (hasremote && (!myrpt->cmdnode[0]))
 		{
 			/* set for all to hear */
@@ -1228,9 +1494,10 @@
 			if (ioctl(mychannel->fds[0],ZT_SETCONF,&ci) == -1)
 			{
 				ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
-				ast_mutex_lock(&myrpt->lock);
+				rpt_mutex_lock(&myrpt->lock);
 				remque((struct qelem *)mytele);
-				ast_mutex_unlock(&myrpt->lock);
+				rpt_mutex_unlock(&myrpt->lock);
+				ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 				free(mytele);		
 				ast_hangup(mychannel);
 				pthread_exit(NULL);
@@ -1301,7 +1568,7 @@
 		hastx = 0;
 		linkbase.next = &linkbase;
 		linkbase.prev = &linkbase;
-		ast_mutex_lock(&myrpt->lock);
+		rpt_mutex_lock(&myrpt->lock);
 		/* make our own list of links */
 		l = myrpt->links.next;
 		while(l != &myrpt->links)
@@ -1310,12 +1577,14 @@
 			{
 				l = l->next;
 				continue;
-			}			
-			if (!(m = ast_malloc(sizeof(*m))))
+			}
+			m = malloc(sizeof(struct rpt_link));
+			if (!m)
 			{
-				ast_mutex_lock(&myrpt->lock);
+				ast_log(LOG_WARNING, "Cannot alloc memory on %s\n", mychannel->name);
 				remque((struct qelem *)mytele);
-				ast_mutex_unlock(&myrpt->lock);
+				rpt_mutex_unlock(&myrpt->lock);
+				ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 				free(mytele);		
 				ast_hangup(mychannel);
 				pthread_exit(NULL);
@@ -1325,7 +1594,7 @@
 			insque((struct qelem *)m,(struct qelem *)linkbase.next);
 			l = l->next;
 		}
-		ast_mutex_unlock(&myrpt->lock);
+		rpt_mutex_unlock(&myrpt->lock);
 		res = ast_streamfile(mychannel, "rpt/node", mychannel->language);
 		if (!res) 
 			res = ast_waitstream(mychannel, "");
@@ -1534,7 +1803,7 @@
 		}
 	}
 	ast_stopstream(mychannel);
-	ast_mutex_lock(&myrpt->lock);
+	rpt_mutex_lock(&myrpt->lock);
 	if (mytele->mode == TAILMSG)
 	{
 		if (!res)
@@ -1548,9 +1817,20 @@
 		}
 	}
 	remque((struct qelem *)mytele);
-	ast_mutex_unlock(&myrpt->lock);
+	rpt_mutex_unlock(&myrpt->lock);
 	free(mytele);		
 	ast_hangup(mychannel);
+#ifdef  APP_RPT_LOCK_DEBUG
+	{
+		struct lockthread *t;
+
+		sleep(5);
+		ast_mutex_lock(&locklock);
+		t = get_lockthread(pthread_self());
+		if (t) memset(t,0,sizeof(struct lockthread));
+		ast_mutex_unlock(&locklock);
+	}			
+#endif
 	pthread_exit(NULL);
 }
 
@@ -1558,16 +1838,21 @@
 {
 struct rpt_tele *tele;
 struct rpt_link *mylink = (struct rpt_link *) data;
+int res;
 pthread_attr_t attr;
-	
-	if (!(tele = ast_calloc(1, sizeof(*tele))))
-	{
+
+	tele = malloc(sizeof(struct rpt_tele));
+	if (!tele)
+	{
+		ast_log(LOG_WARNING, "Unable to allocate memory\n");
 		pthread_exit(NULL);
 		return;
 	}
+	/* zero it out */
+	memset((char *)tele,0,sizeof(struct rpt_tele));
 	tele->rpt = myrpt;
 	tele->mode = mode;
-	ast_mutex_lock(&myrpt->lock);
+	rpt_mutex_lock(&myrpt->lock);
 	if((mode == CONNFAIL) || (mode == REMDISC) || (mode == CONNECTED)){
 		memset(&tele->mylink,0,sizeof(struct rpt_link));
 		if (mylink){
@@ -1578,11 +1863,12 @@
 		strncpy(tele->param, (char *) data, TELEPARAMSIZE - 1);
 		tele->param[TELEPARAMSIZE - 1] = 0;
 	}
-	insque((struct qelem *)tele,(struct qelem *)myrpt->tele.next); 
-	ast_mutex_unlock(&myrpt->lock);
+	rpt_mutex_unlock(&myrpt->lock);
         pthread_attr_init(&attr);
         pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-	ast_pthread_create(&tele->threadid,&attr,rpt_tele_thread,(void *) tele);
+	res = ast_pthread_create(&tele->threadid,&attr,rpt_tele_thread,(void *) tele);
+	if(res < 0)
+		ast_log(LOG_WARNING, "Could not create telemetry thread: %s",strerror(res));
 	return;
 }
 
@@ -1597,7 +1883,8 @@
 
 	myrpt->mydtmf = 0;
 	/* allocate a pseudo-channel thru asterisk */
-	if (!(mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
+	mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+	if (!mychannel)
 	{
 		fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
 		pthread_exit(NULL);
@@ -1615,7 +1902,8 @@
 		pthread_exit(NULL);
 	}
 	/* allocate a pseudo-channel thru asterisk */
-	if (!(genchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL)))
+	genchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+	if (!genchannel)
 	{
 		fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
 		ast_hangup(mychannel);
@@ -1681,9 +1969,9 @@
 		{
 			ast_hangup(mychannel);
 			ast_hangup(genchannel);
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 			myrpt->callmode = 0;
-			ast_mutex_unlock(&myrpt->lock);
+			rpt_mutex_unlock(&myrpt->lock);
 			pthread_exit(NULL);
 		}
 	}
@@ -1694,9 +1982,9 @@
 	{
 		ast_hangup(mychannel);
 		ast_hangup(genchannel);
-		ast_mutex_lock(&myrpt->lock);
+		rpt_mutex_lock(&myrpt->lock);
 		myrpt->callmode = 0;
-		ast_mutex_unlock(&myrpt->lock);
+		rpt_mutex_unlock(&myrpt->lock);
 		pthread_exit(NULL);			
 	}
 
@@ -1730,23 +2018,23 @@
 		ast_log(LOG_WARNING, "Unable to start PBX!!\n");
 		ast_hangup(mychannel);
 		ast_hangup(genchannel);
-		ast_mutex_lock(&myrpt->lock);
+		rpt_mutex_lock(&myrpt->lock);
 	 	myrpt->callmode = 0;
-		ast_mutex_unlock(&myrpt->lock);
+		rpt_mutex_unlock(&myrpt->lock);
 		pthread_exit(NULL);
 	}
 	usleep(10000);
-	ast_mutex_lock(&myrpt->lock);
+	rpt_mutex_lock(&myrpt->lock);
 	myrpt->callmode = 3;
 	while(myrpt->callmode)
 	{
 		if ((!mychannel->pbx) && (myrpt->callmode != 4))
 		{
 			myrpt->callmode = 4;
-			ast_mutex_unlock(&myrpt->lock);
+			rpt_mutex_unlock(&myrpt->lock);
 			/* start congestion tone */
 			tone_zone_play_tone(genchannel->fds[0],ZT_TONE_CONGESTION);
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 		}
 		if (myrpt->mydtmf)
 		{
@@ -1757,22 +2045,22 @@
 			wf.data = NULL;
 			wf.datalen = 0;
 			wf.samples = 0;
-			ast_mutex_unlock(&myrpt->lock);
+			rpt_mutex_unlock(&myrpt->lock);
 			ast_write(genchannel,&wf); 
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 			myrpt->mydtmf = 0;
 		}
-		ast_mutex_unlock(&myrpt->lock);
+		rpt_mutex_unlock(&myrpt->lock);
 		usleep(MSWAIT * 1000);
-		ast_mutex_lock(&myrpt->lock);
-	}
-	ast_mutex_unlock(&myrpt->lock);
+		rpt_mutex_lock(&myrpt->lock);
+	}
+	rpt_mutex_unlock(&myrpt->lock);
 	tone_zone_play_tone(genchannel->fds[0],-1);
 	if (mychannel->pbx) ast_softhangup(mychannel,AST_SOFTHANGUP_DEV);
 	ast_hangup(genchannel);
-	ast_mutex_lock(&myrpt->lock);
+	rpt_mutex_lock(&myrpt->lock);
 	myrpt->callmode = 0;
-	ast_mutex_unlock(&myrpt->lock);
+	rpt_mutex_unlock(&myrpt->lock);
 	pthread_exit(NULL);
 }
 
@@ -1857,7 +2145,7 @@
 			s = tmp;
 			s1 = strsep(&s,",");
 			s2 = strsep(&s,",");
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 			l = myrpt->links.next;
 			/* try to find this one in queue */
 			while(l != &myrpt->links){
@@ -1877,7 +2165,7 @@
 				strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
 				l->retries = MAX_RETRIES + 1;
 				l->disced = 1;
-				ast_mutex_unlock(&myrpt->lock);
+				rpt_mutex_unlock(&myrpt->lock);
 				wf.frametype = AST_FRAME_TEXT;
 				wf.subclass = 0;
 				wf.offset = 0;
@@ -1894,7 +2182,7 @@
 				rpt_telemetry(myrpt, COMPLETE, NULL);
 				return DC_COMPLETE;
 			}
-			ast_mutex_unlock(&myrpt->lock);	
+			rpt_mutex_unlock(&myrpt->lock);	
 			return DC_COMPLETE;
 		case 2: /* Link Monitor */
 			if ((digitbuf[0] == '0') && (myrpt->lastlinknode[0]))
@@ -1909,7 +2197,7 @@
 			s = tmp;
 			s1 = strsep(&s,",");
 			s2 = strsep(&s,",");
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 			l = myrpt->links.next;
 			/* try to find this one in queue */
 			while(l != &myrpt->links){
@@ -1928,24 +2216,27 @@
 			{
 				/* if already in this mode, just ignore */
 				if ((!l->mode) || (!l->chan)) {
-					ast_mutex_unlock(&myrpt->lock);
+					rpt_mutex_unlock(&myrpt->lock);
 					rpt_telemetry(myrpt,REMALREADY,NULL);
 					return DC_COMPLETE;
 					
 				}
-				ast_mutex_unlock(&myrpt->lock);
+				rpt_mutex_unlock(&myrpt->lock);
 				if (l->chan) ast_softhangup(l->chan,AST_SOFTHANGUP_DEV);
 				l->retries = MAX_RETRIES + 1;
 				l->disced = 2;
 				modechange = 1;
 			} else
-				ast_mutex_unlock(&myrpt->lock);
+				rpt_mutex_unlock(&myrpt->lock);
 			strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
-			/* establish call in monitor mode */			
-			if (!(l = ast_calloc(1, sizeof(*l)))) {
+			/* establish call in monitor mode */
+			l = malloc(sizeof(struct rpt_link));
+			if (!l){
+				ast_log(LOG_WARNING, "Unable to malloc\n");
 				return DC_ERROR;
 			}
 			/* zero the silly thing */
+			memset((char *)l,0,sizeof(struct rpt_link));
 			snprintf(deststr, sizeof(deststr), "IAX2/%s", s1);
 			tele = strchr(deststr,'/');
 			if (!tele){
@@ -1981,7 +2272,8 @@
 				return DC_ERROR;
 			}
 			/* allocate a pseudo-channel thru asterisk */
-			if (!(l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL))) {
+			l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+			if (!l->pchan){
 				fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
 				ast_hangup(l->chan);
 				free(l);
@@ -2002,10 +2294,10 @@
 				free(l);
 				return DC_ERROR;
 			}
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 			/* insert at end of queue */
 			insque((struct qelem *)l,(struct qelem *)myrpt->links.next);
-			ast_mutex_unlock(&myrpt->lock);
+			rpt_mutex_unlock(&myrpt->lock);
 			rpt_telemetry(myrpt,COMPLETE,NULL);
 			return DC_COMPLETE;
 		case 3: /* Link transceive */
@@ -2021,7 +2313,7 @@
 			s = tmp;
 			s1 = strsep(&s,",");
 			s2 = strsep(&s,",");
-			ast_mutex_lock(&myrpt->lock);
+			rpt_mutex_lock(&myrpt->lock);
 			l = myrpt->links.next;
 			/* try to find this one in queue */

[... 6837 lines stripped ...]


More information about the asterisk-commits mailing list