[svn-commits] branch bweschke/bug_5374 r8819 - in /team/bweschke/bug_5374: ./ apps/ cdr/ ch...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sat Jan 28 07:27:04 MST 2006


Author: bweschke
Date: Sat Jan 28 08:26:51 2006
New Revision: 8819

URL: http://svn.digium.com/view/asterisk?rev=8819&view=rev
Log:
 Bring this branch up to date with /trunk


Removed:
    team/bweschke/bug_5374/ChangeLog
Modified:
    team/bweschke/bug_5374/   (props changed)
    team/bweschke/bug_5374/Makefile
    team/bweschke/bug_5374/apps/Makefile
    team/bweschke/bug_5374/apps/app_authenticate.c
    team/bweschke/bug_5374/apps/app_chanspy.c
    team/bweschke/bug_5374/apps/app_curl.c
    team/bweschke/bug_5374/apps/app_db.c
    team/bweschke/bug_5374/apps/app_dial.c
    team/bweschke/bug_5374/apps/app_dictate.c
    team/bweschke/bug_5374/apps/app_directory.c
    team/bweschke/bug_5374/apps/app_disa.c
    team/bweschke/bug_5374/apps/app_exec.c
    team/bweschke/bug_5374/apps/app_externalivr.c
    team/bweschke/bug_5374/apps/app_festival.c
    team/bweschke/bug_5374/apps/app_hasnewvoicemail.c
    team/bweschke/bug_5374/apps/app_image.c
    team/bweschke/bug_5374/apps/app_macro.c
    team/bweschke/bug_5374/apps/app_meetme.c
    team/bweschke/bug_5374/apps/app_mixmonitor.c
    team/bweschke/bug_5374/apps/app_osplookup.c
    team/bweschke/bug_5374/apps/app_page.c
    team/bweschke/bug_5374/apps/app_parkandannounce.c
    team/bweschke/bug_5374/apps/app_playback.c
    team/bweschke/bug_5374/apps/app_privacy.c
    team/bweschke/bug_5374/apps/app_queue.c
    team/bweschke/bug_5374/apps/app_random.c
    team/bweschke/bug_5374/apps/app_read.c
    team/bweschke/bug_5374/apps/app_readfile.c
    team/bweschke/bug_5374/apps/app_record.c
    team/bweschke/bug_5374/apps/app_sayunixtime.c
    team/bweschke/bug_5374/apps/app_senddtmf.c
    team/bweschke/bug_5374/apps/app_sendtext.c
    team/bweschke/bug_5374/apps/app_setcallerid.c
    team/bweschke/bug_5374/apps/app_skel.c
    team/bweschke/bug_5374/apps/app_sql_postgres.c
    team/bweschke/bug_5374/apps/app_stack.c
    team/bweschke/bug_5374/apps/app_talkdetect.c
    team/bweschke/bug_5374/apps/app_transfer.c
    team/bweschke/bug_5374/apps/app_url.c
    team/bweschke/bug_5374/apps/app_userevent.c
    team/bweschke/bug_5374/apps/app_verbose.c
    team/bweschke/bug_5374/apps/app_voicemail.c
    team/bweschke/bug_5374/apps/app_while.c
    team/bweschke/bug_5374/apps/app_zapras.c
    team/bweschke/bug_5374/ast_expr2.c
    team/bweschke/bug_5374/ast_expr2.h
    team/bweschke/bug_5374/ast_expr2f.c
    team/bweschke/bug_5374/asterisk.c
    team/bweschke/bug_5374/cdr/cdr_pgsql.c
    team/bweschke/bug_5374/channel.c
    team/bweschke/bug_5374/channels/chan_agent.c
    team/bweschke/bug_5374/channels/chan_features.c
    team/bweschke/bug_5374/channels/chan_iax2.c
    team/bweschke/bug_5374/channels/chan_sip.c
    team/bweschke/bug_5374/channels/chan_zap.c
    team/bweschke/bug_5374/configs/queues.conf.sample
    team/bweschke/bug_5374/configs/sip.conf.sample
    team/bweschke/bug_5374/contrib/scripts/safe_asterisk
    team/bweschke/bug_5374/funcs/func_db.c
    team/bweschke/bug_5374/funcs/func_rand.c
    team/bweschke/bug_5374/include/asterisk/channel.h
    team/bweschke/bug_5374/include/asterisk/stringfields.h
    team/bweschke/bug_5374/manager.c
    team/bweschke/bug_5374/pbx.c
    team/bweschke/bug_5374/res/Makefile
    team/bweschke/bug_5374/rtp.c
    team/bweschke/bug_5374/utils.c
    team/bweschke/bug_5374/utils/astman.c

Propchange: team/bweschke/bug_5374/
------------------------------------------------------------------------------
--- svnmerge-blocked (original)
+++ svnmerge-blocked Sat Jan 28 08:26:51 2006
@@ -1,1 +1,1 @@
-/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112
+/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112,8124,8134,8394,8412,8414,8418,8429,8433,8445,8562,8573,8600,8619,8666

Propchange: team/bweschke/bug_5374/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Jan 28 08:26:51 2006
@@ -1,1 +1,1 @@
-/trunk:1-8324
+/trunk:1-8807

Modified: team/bweschke/bug_5374/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/Makefile?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/Makefile (original)
+++ team/bweschke/bug_5374/Makefile Sat Jan 28 08:26:51 2006
@@ -106,7 +106,7 @@
 # Detect the busy signal looking only at tone lengths
 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
 BUSYDETECT+= #-DBUSYDETECT_TONEONLY
-# Enforce the detection of busy singal (get rid of false hangups)
+# Enforce the detection of busy signal (get rid of false hangups)
 # Don't use together with -DBUSYDETECT_TONEONLY
 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
 
@@ -381,6 +381,9 @@
 #These are used for all but Darwin
   ASTLINK=-Wl,-E 
   SOLINK=-shared -Xlinker -x
+  ifeq ($(findstring BSD,$(OSARCH)),BSD)
+    SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
+  endif
 endif
 
 ifeq ($(OSARCH),FreeBSD)

Modified: team/bweschke/bug_5374/apps/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/Makefile?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/Makefile (original)
+++ team/bweschke/bug_5374/apps/Makefile Sat Jan 28 08:26:51 2006
@@ -96,7 +96,7 @@
 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CURLLIBS)
 
 app_sql_postgres.o: app_sql_postgres.c
-	$(CC) -pipe -I/usr/local/pgsql/include $(CFLAGS) -c -o app_sql_postgres.o app_sql_postgres.c
+	$(CC) -pipe -I$(CROSS_COMPILE_TARGET)/usr/local/pgsql/include -I$(CROSS_COMPILE_TARGET)/usr/include/postgresql $(CFLAGS) -c -o app_sql_postgres.o app_sql_postgres.c
 
 app_sql_postgres.so: app_sql_postgres.o
 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -L/usr/local/pgsql/lib -lpq

Modified: team/bweschke/bug_5374/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_authenticate.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_authenticate.c (original)
+++ team/bweschke/bug_5374/apps/app_authenticate.c Sat Jan 28 08:26:51 2006
@@ -128,7 +128,10 @@
 		}
 	}
 	
-	argcopy = ast_strdupa(data);
+	if (!(argcopy = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(arglist,argcopy);
 	

Modified: team/bweschke/bug_5374/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_chanspy.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_chanspy.c (original)
+++ team/bweschke/bug_5374/apps/app_chanspy.c Sat Jan 28 08:26:51 2006
@@ -383,7 +383,8 @@
 	struct ast_flags flags;
 	signed char zero_volume = 0;
 
-	args = ast_strdupa(data);
+	if (!(args = ast_strdupa(data)))
+		return -1;
 
 	LOCAL_USER_ADD(u);
 

Modified: team/bweschke/bug_5374/apps/app_curl.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_curl.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_curl.c (original)
+++ team/bweschke/bug_5374/apps/app_curl.c Sat Jan 28 08:26:51 2006
@@ -128,7 +128,10 @@
 
 	LOCAL_USER_ACF_ADD(u);
 
-	info = ast_strdupa(data);
+	if (!(info = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return buf;
+	}
 
 	AST_STANDARD_APP_ARGS(args, info);	
 	

Modified: team/bweschke/bug_5374/apps/app_db.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_db.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_db.c (original)
+++ team/bweschke/bug_5374/apps/app_db.c Sat Jan 28 08:26:51 2006
@@ -75,7 +75,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	argv = ast_strdupa(data);
+	if (!(argv = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return 0;
+	}
 
 	if (strchr(argv, '/')) {
 		family = strsep(&argv, "/");
@@ -116,7 +119,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	argv = ast_strdupa(data);
+	if (!(argv = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return 0;
+	}
 
 	if (strchr(argv, '/')) {
 		family = strsep(&argv, "/");

Modified: team/bweschke/bug_5374/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_dial.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_dial.c (original)
+++ team/bweschke/bug_5374/apps/app_dial.c Sat Jan 28 08:26:51 2006
@@ -262,19 +262,20 @@
    use it not only for keeping track of what is in use but
    also for keeping track of who we're dialing. */
 
-struct localuser {
+struct dial_localuser {
 	struct ast_channel *chan;
 	unsigned int flags;
 	int forwards;
-	struct localuser *next;
+	struct dial_localuser *next;
 };
 
 LOCAL_USER_DECL;
-
-static void hanguptree(struct localuser *outgoing, struct ast_channel *exception)
+STANDARD_LOCAL_USER;
+
+static void hanguptree(struct dial_localuser *outgoing, struct ast_channel *exception)
 {
 	/* Hang up a tree of stuff */
-	struct localuser *oo;
+	struct dial_localuser *oo;
 	while (outgoing) {
 		/* Hangup any existing lines we have open */
 		if (outgoing->chan && (outgoing->chan != exception))
@@ -366,9 +367,9 @@
 			   dst->uniqueid);
 }
 
-static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, struct ast_flags *peerflags, int *sentringing, char *status, size_t statussize, int busystart, int nochanstart, int congestionstart, int priority_jump, int *result)
+static struct ast_channel *wait_for_answer(struct ast_channel *in, struct dial_localuser *outgoing, int *to, struct ast_flags *peerflags, int *sentringing, char *status, size_t statussize, int busystart, int nochanstart, int congestionstart, int priority_jump, int *result)
 {
-	struct localuser *o;
+	struct dial_localuser *o;
 	int found;
 	int numlines;
 	int numbusy = busystart;
@@ -657,6 +658,7 @@
 					ast_hangup(o->chan);
 					o->chan = NULL;
 					ast_clear_flag(o, DIAL_STILLGOING);
+					HANDLE_CAUSE(in->hangupcause, in);
 				}
 			}
 			o = o->next;
@@ -735,7 +737,7 @@
 	char *tech, *number, *rest, *cur;
 	char privcid[256];
 	char privintro[1024];
-	struct localuser *outgoing=NULL, *tmp;
+	struct dial_localuser *outgoing=NULL, *tmp;
 	struct ast_channel *peer;
 	int to;
 	int numbusy = 0;
@@ -786,7 +788,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	parse = ast_strdupa(data);
+	if (!(parse = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 	
 	AST_STANDARD_APP_ARGS(args, parse);
 
@@ -1623,7 +1628,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	announce = ast_strdupa(data);	
+	if (!(announce = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 	
 	memset(&peerflags, 0, sizeof(peerflags));
 

Modified: team/bweschke/bug_5374/apps/app_dictate.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_dictate.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_dictate.c (original)
+++ team/bweschke/bug_5374/apps/app_dictate.c Sat Jan 28 08:26:51 2006
@@ -110,7 +110,8 @@
 	
 	snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
 	if (!ast_strlen_zero(data)) {
-		parse = ast_strdupa(data);
+		if (!(parse = ast_strdupa(data)))
+			return -1;
 		AST_STANDARD_APP_ARGS(args, parse);
 	} else
 		args.argc = 0;

Modified: team/bweschke/bug_5374/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_directory.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_directory.c (original)
+++ team/bweschke/bug_5374/apps/app_directory.c Sat Jan 28 08:26:51 2006
@@ -431,7 +431,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	parse = ast_strdupa(data);
+	if (!(parse = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1; 
+	}
 
 	AST_STANDARD_APP_ARGS(args, parse);
 		

Modified: team/bweschke/bug_5374/apps/app_disa.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_disa.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_disa.c (original)
+++ team/bweschke/bug_5374/apps/app_disa.c Sat Jan 28 08:26:51 2006
@@ -161,7 +161,10 @@
 	ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
 	ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
 
-	tmp = ast_strdupa(data);
+	if (!(tmp = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}	
 
 	AST_STANDARD_APP_ARGS(args, tmp);
 

Modified: team/bweschke/bug_5374/apps/app_exec.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_exec.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_exec.c (original)
+++ team/bweschke/bug_5374/apps/app_exec.c Sat Jan 28 08:26:51 2006
@@ -73,9 +73,7 @@
 
 	/* Check and parse arguments */
 	if (data) {
-		s = ast_strdupa(data);
-		appname = strsep(&s, "(");
-		if (s) {
+		if ((s = ast_strdupa(data))) {
 			endargs = strrchr(s, ')');
 			if (endargs)
 				*endargs = '\0';
@@ -89,7 +87,17 @@
 				ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
 				res = -1;
 			}
-		}
+			if (appname) {
+				app = pbx_findapp(appname);
+				if (app) {
+					res = pbx_exec(chan, app, args, 1);
+				} else {
+					ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
+					res = -1;
+				}
+			}
+		} else
+			res = -1;
 	}
 
 	LOCAL_USER_REMOVE(u);

Modified: team/bweschke/bug_5374/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_externalivr.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_externalivr.c (original)
+++ team/bweschke/bug_5374/apps/app_externalivr.c Sat Jan 28 08:26:51 2006
@@ -75,9 +75,8 @@
 	char filename[1];
 };
 
-struct localuser {
+struct ivr_localuser {
 	struct ast_channel *chan;
-	struct localuser *next;
 	AST_LIST_HEAD(playlist, playlist_entry) playlist;
 	AST_LIST_HEAD(finishlist, playlist_entry) finishlist;
 	int abort_current_sound;
@@ -86,9 +85,10 @@
 };
 
 LOCAL_USER_DECL;
+STANDARD_LOCAL_USER;
 
 struct gen_state {
-	struct localuser *u;
+	struct ivr_localuser *u;
 	struct ast_filestream *stream;
 	struct playlist_entry *current;
 	int sample_queue;
@@ -111,7 +111,7 @@
 
 static void *gen_alloc(struct ast_channel *chan, void *params)
 {
-	struct localuser *u = params;
+	struct ivr_localuser *u = params;
 	struct gen_state *state;
 	
 	if (!(state = ast_calloc(1, sizeof(*state))))
@@ -143,7 +143,7 @@
 /* caller has the playlist locked */
 static int gen_nextfile(struct gen_state *state)
 {
-	struct localuser *u = state->u;
+	struct ivr_localuser *u = state->u;
 	char *file_to_stream;
 	
 	u->abort_current_sound = 0;
@@ -175,7 +175,7 @@
 static struct ast_frame *gen_readframe(struct gen_state *state)
 {
 	struct ast_frame *f = NULL;
-	struct localuser *u = state->u;
+	struct ivr_localuser *u = state->u;
 	
 	if (u->abort_current_sound ||
 	    (u->playing_silence && AST_LIST_FIRST(&u->playlist))) {
@@ -234,7 +234,7 @@
 {
 	struct playlist_entry *entry;
 	
-	if (!(entry = ast_calloc(1, sizeof(*entry) + strlen(filename) + 10)))
+	if (!(entry = ast_calloc(1, sizeof(*entry) + strlen(filename) + 10))) /* XXX why 10 ? */
 		return NULL;
 
 	strcpy(entry->filename, filename);
@@ -244,7 +244,7 @@
 
 static int app_exec(struct ast_channel *chan, void *data)
 {
-	struct localuser *u = NULL;
+	struct localuser *lu = NULL;
 	struct playlist_entry *entry;
 	const char *args = data;
 	int child_stdin[2] = { 0,0 };
@@ -259,8 +259,11 @@
 	FILE *child_commands = NULL;
 	FILE *child_errors = NULL;
 	FILE *child_events = NULL;
-
-	LOCAL_USER_ADD(u);
+	struct ivr_localuser foo, *u = &foo;
+
+	bzero(u, sizeof(*u));
+
+	LOCAL_USER_ADD(lu);
 	
 	AST_LIST_HEAD_INIT(&u->playlist);
 	AST_LIST_HEAD_INIT(&u->finishlist);
@@ -268,10 +271,14 @@
 	
 	if (ast_strlen_zero(args)) {
 		ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n");
-		goto exit;
-	}
-
-	buf = ast_strdupa(data);
+		LOCAL_USER_REMOVE(lu);
+		return -1;	
+	}
+
+	if (!(buf = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(lu);
+		return -1;
+	}
 
 	argc = ast_app_separate_args(buf, '|', argv, sizeof(argv) / sizeof(argv[0]));
 
@@ -539,7 +546,7 @@
 	while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list)))
 		free(entry);
 
-	LOCAL_USER_REMOVE(u);
+	LOCAL_USER_REMOVE(lu);
 
 	return res;
 }

Modified: team/bweschke/bug_5374/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_festival.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_festival.c (original)
+++ team/bweschke/bug_5374/apps/app_festival.c Sat Jan 28 08:26:51 2006
@@ -339,7 +339,11 @@
 		festivalcommand = "(tts_textasterisk \"%s\" 'file)(quit)\n";
 	}
 	
-	data = ast_strdupa(vdata);
+	if (!(data = ast_strdupa(vdata))) {
+		ast_config_destroy(cfg);
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	intstr = strchr(data, '|');
 	if (intstr) {	

Modified: team/bweschke/bug_5374/apps/app_hasnewvoicemail.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_hasnewvoicemail.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_hasnewvoicemail.c (original)
+++ team/bweschke/bug_5374/apps/app_hasnewvoicemail.c Sat Jan 28 08:26:51 2006
@@ -129,7 +129,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	input = ast_strdupa((char *)data);
+	if (!(input = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(args, input);
 
@@ -188,7 +191,10 @@
 
 	buf[0] = '\0';
 
-	argsstr = ast_strdupa(data);
+	if (!(argsstr = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return buf;
+	}
 
 	AST_STANDARD_APP_ARGS(args, argsstr);
 

Modified: team/bweschke/bug_5374/apps/app_image.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_image.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_image.c (original)
+++ team/bweschke/bug_5374/apps/app_image.c Sat Jan 28 08:26:51 2006
@@ -78,7 +78,10 @@
 	
 	LOCAL_USER_ADD(u);
 
-	parse = ast_strdupa(data);
+	if (!(parse = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(args, parse);
 

Modified: team/bweschke/bug_5374/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_macro.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_macro.c (original)
+++ team/bweschke/bug_5374/apps/app_macro.c Sat Jan 28 08:26:51 2006
@@ -307,7 +307,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	expr = ast_strdupa(data);
+	if (!(expr = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	if ((label_a = strchr(expr, '?'))) {
 		*label_a = '\0';

Modified: team/bweschke/bug_5374/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_meetme.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_meetme.c (original)
+++ team/bweschke/bug_5374/apps/app_meetme.c Sat Jan 28 08:26:51 2006
@@ -136,7 +136,7 @@
 
 LOCAL_USER_DECL;
 
-static struct ast_conference {
+struct ast_conference {
 	ast_mutex_t playlock;				/* Conference specific lock (players) */
 	ast_mutex_t listenlock;				/* Conference specific lock (listeners) */
 	char confno[AST_MAX_EXTENSION];		/* Conference */
@@ -161,8 +161,10 @@
 	struct ast_frame *transframe[32];
 	struct ast_frame *origframe;
 	struct ast_trans_pvt *transpath[32];
-	struct ast_conference *next;
-} *confs;
+	AST_LIST_ENTRY(ast_conference) list;
+};
+
+static AST_LIST_HEAD_STATIC(confs, ast_conference);
 
 struct volume {
 	int desired;				/* Desired volume adjustment */
@@ -202,8 +204,6 @@
 	VOL_UP,
 	VOL_DOWN,
 };
-
-AST_MUTEX_DEFINE_STATIC(conflock);
 
 static int admin_exec(struct ast_channel *chan, void *data);
 static struct ast_frame null_frame = { AST_FRAME_NULL, };
@@ -432,7 +432,7 @@
 	if (!chan->_softhangup)
 		res = ast_autoservice_start(chan);
 
-	ast_mutex_lock(&conflock);
+	AST_LIST_LOCK(&confs);
 
 	switch(sound) {
 	case ENTER:
@@ -454,7 +454,7 @@
 		careful_write(conf->fd, (unsigned char *)data2, len << 1, 1);
 	}
 
-	ast_mutex_unlock(&conflock);
+	AST_LIST_UNLOCK(&confs);
 
 	if (!res) 
 		ast_autoservice_stop(chan);
@@ -465,9 +465,9 @@
 	struct ast_conference *cnf;
 	struct zt_confinfo ztc;
 
-	ast_mutex_lock(&conflock);
-
-	for (cnf = confs; cnf; cnf = cnf->next) {
+	AST_LIST_LOCK(&confs);
+
+	AST_LIST_TRAVERSE(&confs, cnf, list) {
 		if (!strcmp(confno, cnf->confno)) 
 			break;
 	}
@@ -532,12 +532,11 @@
 			cnf->locked = 0;
 			if (option_verbose > 2)
 				ast_verbose(VERBOSE_PREFIX_3 "Created MeetMe conference %d for conference '%s'\n", cnf->zapconf, cnf->confno);
-			cnf->next = confs;
-			confs = cnf;
+			AST_LIST_INSERT_HEAD(&confs, cnf, list);
 		} 
 	}
  cnfout:
-	ast_mutex_unlock(&conflock);
+	AST_LIST_UNLOCK(&confs);
 	return cnf;
 }
 
@@ -576,13 +575,12 @@
 	if (argc == 1) {
 		/* 'MeetMe': List all the conferences */	
 		now = time(NULL);
-		cnf = confs;
-		if (!cnf) {
+		if (AST_LIST_EMPTY(&confs)) {
 			ast_cli(fd, "No active MeetMe conferences.\n");
 			return RESULT_SUCCESS;
 		}
 		ast_cli(fd, header_format, "Conf Num", "Parties", "Marked", "Activity", "Creation");
-		while(cnf) {
+		AST_LIST_TRAVERSE(&confs, cnf, list) {
 			if (cnf->markedusers == 0)
 				strcpy(cmdline, "N/A ");
 			else 
@@ -594,7 +592,6 @@
 			ast_cli(fd, data_format, cnf->confno, cnf->users, cmdline, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static");
 
 			total += cnf->users; 	
-			cnf = cnf->next;
 		}
 		ast_cli(fd, "* Total number of MeetMe users: %d\n", total);
 		return RESULT_SUCCESS;
@@ -643,21 +640,18 @@
 		}	
 	} else if(strcmp(argv[1], "list") == 0) {
 		/* List all the users in a conference */
-		if (!confs) {
+		if (AST_LIST_EMPTY(&confs)) {
 			ast_cli(fd, "No active conferences.\n");
 			return RESULT_SUCCESS;	
 		}
-		cnf = confs;
 		/* Find the right conference */
-		while(cnf) {
+		AST_LIST_TRAVERSE(&confs, cnf, list) {
 			if (strcmp(cnf->confno, argv[2]) == 0)
 				break;
-			if (cnf->next) {
-				cnf = cnf->next;	
-			} else {
-				ast_cli(fd, "No such conference: %s.\n",argv[2]);
-				return RESULT_SUCCESS;
-			}
+		}
+		if (!cnf) {
+			ast_cli(fd, "No such conference: %s.\n",argv[2]);
+			return RESULT_SUCCESS;
 		}
 		/* Show all the users */
 		for (user = cnf->firstuser; user; user = user->nextuser){
@@ -709,16 +703,14 @@
 		}
 	} else if (pos == 2) {
 		/* Conference Number */
-		ast_mutex_lock(&conflock);
-		cnf = confs;
-		while(cnf) {
+		AST_LIST_LOCK(&confs);
+		AST_LIST_TRAVERSE(&confs, cnf, list) {
 			if (!strncasecmp(word, cnf->confno, strlen(word))) {
 				if (++which > state)
 					break;
 			}
-			cnf = cnf->next;
-		}
-		ast_mutex_unlock(&conflock);
+		}
+		AST_LIST_UNLOCK(&confs);
 		return cnf ? strdup(cnf->confno) : NULL;
 	} else if (pos == 3) {
 		/* User Number || Conf Command option*/
@@ -727,7 +719,7 @@
 				return strdup("all");
 			}
 			which++;
-			ast_mutex_lock(&conflock);
+			AST_LIST_LOCK(&confs);
 
 			/* TODO: Find the conf number from the cmdline (ignore spaces) <- test this and make it fail-safe! */
 			myline = ast_strdupa(line);
@@ -736,7 +728,7 @@
 					;
 			}
 			
-			for (cnf = confs; cnf; cnf = cnf->next) {
+			AST_LIST_TRAVERSE(&confs, cnf, list) {
 				if (!strcmp(confno, cnf->confno))
 				    break;
 			}
@@ -751,7 +743,7 @@
 					}
 				}
 			}
-			ast_mutex_unlock(&conflock);
+			AST_LIST_UNLOCK(&confs);
 			return usr ? strdup(usrno) : NULL;
 		}
 	}
@@ -798,32 +790,18 @@
    We assume that this was called while holding conflock. */
 static int conf_free(struct ast_conference *conf)
 {
-	struct ast_conference *prev = NULL, *cur = confs;
 	int x;
 	
-	while (cur) {
-		if (cur == conf) {
-			if (prev)
-				prev->next = conf->next;
-			else
-				confs = conf->next;
-			break;
-		}
-		prev = cur;
-		cur = cur->next;
-	}
-
-	if (!cur)
-		ast_log(LOG_WARNING, "Conference not found\n");
+	AST_LIST_REMOVE(&confs, conf, list);
 
 	if (conf->recording == MEETME_RECORD_ACTIVE) {
 		conf->recording = MEETME_RECORD_TERMINATE;
-		ast_mutex_unlock(&conflock);
+		AST_LIST_UNLOCK(&confs);
 		while (1) {
-			ast_mutex_lock(&conflock);
+			AST_LIST_LOCK(&confs);
 			if (conf->recording == MEETME_RECORD_OFF)
 				break;
-			ast_mutex_unlock(&conflock);
+			AST_LIST_UNLOCK(&confs);
 		}
 	}
 
@@ -1561,7 +1539,7 @@
 					if (ioctl(fd, ZT_SETCONF, &ztc)) {
 						ast_log(LOG_WARNING, "Error setting conference\n");
 						close(fd);
-						ast_mutex_unlock(&conflock);
+						AST_LIST_UNLOCK(&confs);
 						goto outrun;
 					}
 
@@ -1643,7 +1621,7 @@
 
 	reset_volumes(user);
 
-	ast_mutex_lock(&conflock);
+	AST_LIST_LOCK(&confs);
 	if (!(confflags & CONFFLAG_QUIET) && !(confflags & CONFFLAG_MONITOR) && !(confflags & CONFFLAG_ADMIN))
 		conf_play(chan, conf, LEAVE);
 
@@ -1658,10 +1636,10 @@
 			ast_filedelete(user->namerecloc, NULL);
 		}
 	}
-	ast_mutex_unlock(&conflock);
+	AST_LIST_UNLOCK(&confs);
 
  outrun:
-	ast_mutex_lock(&conflock);
+	AST_LIST_LOCK(&confs);
 
 	if (dsp)
 		ast_dsp_free(dsp);
@@ -1727,7 +1705,7 @@
 		pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs);
 	}
 	free(user);
-	ast_mutex_unlock(&conflock);
+	AST_LIST_UNLOCK(&confs);
 
 	return ret;
 }
@@ -1745,12 +1723,12 @@
 	);
 
 	/* Check first in the conference list */
-	ast_mutex_lock(&conflock);
-	for (cnf = confs; cnf; cnf = cnf->next) {
+	AST_LIST_LOCK(&confs);
+	AST_LIST_TRAVERSE(&confs, cnf, list) {
 		if (!strcmp(confno, cnf->confno)) 
 			break;
 	}
-	ast_mutex_unlock(&conflock);
+	AST_LIST_UNLOCK(&confs);
 
 	if (!cnf) {
 		if (dynamic) {
@@ -1778,7 +1756,8 @@
 				if (strcasecmp(var->name, "conf"))
 					continue;
 				
-				parse = ast_strdupa(var->value);
+				if (!(parse = ast_strdupa(var->value)))
+					return NULL;
 				
 				AST_STANDARD_APP_ARGS(args, parse);
 				if (!strcasecmp(args.confno, confno)) {
@@ -1834,7 +1813,10 @@
 
 	LOCAL_USER_ADD(u);
 	
-	localdata = ast_strdupa(data);
+	if (!(localdata = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(args, localdata);
 	
@@ -1924,15 +1906,15 @@
 			struct ast_variable *var;
 			int confno_int;
 
-			ast_mutex_lock(&conflock);
-			for (cnf = confs; cnf; cnf = cnf->next) {
+			AST_LIST_LOCK(&confs);
+			AST_LIST_TRAVERSE(&confs, cnf, list) {
 				if (sscanf(cnf->confno, "%d", &confno_int) == 1) {
 					/* Disqualify in use conference */
 					if (confno_int >= 0 && confno_int < 1024)
 						map[confno_int]++;
 				}
 			}
-			ast_mutex_unlock(&conflock);
+			AST_LIST_UNLOCK(&confs);
 
 			/* We only need to load the config file for static and empty_no_pin (otherwise we don't care) */
 			if ((empty_no_pin) || (!dynamic)) {
@@ -1954,17 +1936,15 @@
 								}
 								if (!dynamic) {
 									/* For static:  run through the list and see if this conference is empty */
-									ast_mutex_lock(&conflock);
-									cnf = confs;
-									while (cnf) {
+									AST_LIST_LOCK(&confs);
+									AST_LIST_TRAVERSE(&confs, cnf, list) {
 										if (!strcmp(confno_tmp, cnf->confno)) {
 											/* The conference exists, therefore it's not empty */
 											found = 1;
 											break;
 										}
-										cnf = cnf->next;
 									}
-									ast_mutex_unlock(&conflock);
+									AST_LIST_UNLOCK(&confs);
 									if (!found) {
 										/* At this point, we have a confno_tmp (static conference) that is empty */
 										if ((empty_no_pin && ((!stringp) || (stringp && (stringp[0] == '\0')))) || (!empty_no_pin)) {
@@ -1978,8 +1958,6 @@
 										}
 									}
 								}
-							} else {
-								ast_log(LOG_ERROR, "Out of memory\n");
 							}
 						}
 						var = var->next;
@@ -2082,11 +2060,11 @@
 							res = -1;
 							allowretry = 0;
 							/* see if we need to get rid of the conference */
-							ast_mutex_lock(&conflock);
+							AST_LIST_LOCK(&confs);
 							if (!cnf->users) {
 								conf_free(cnf);	
 							}
-							ast_mutex_unlock(&conflock);
+							AST_LIST_UNLOCK(&confs);
 							break;
 						}
 
@@ -2143,7 +2121,7 @@
 	
 	LOCAL_USER_ADD(u);
 
-	ast_mutex_lock(&conflock);
+	AST_LIST_LOCK(&confs);
 	/* The param has the conference number the user and the command to execute */
 	if (!ast_strlen_zero(data)) {		
 		params = ast_strdupa((char *) data);
@@ -2152,11 +2130,11 @@
 
 		if (!args.command) {
 			ast_log(LOG_WARNING, "MeetmeAdmin requires a command!\n");
-			ast_mutex_unlock(&conflock);
+			AST_LIST_UNLOCK(&confs);
 			LOCAL_USER_REMOVE(u);
 			return -1;
 		}
-		for (cnf = confs; cnf; cnf = cnf->next) {
+		AST_LIST_TRAVERSE(&confs, cnf, list) {
 			if (!strcmp(cnf->confno, args.confno))
 				break;
 		}
@@ -2242,7 +2220,7 @@
 			ast_log(LOG_NOTICE, "Conference Number not found\n");
 		}
 	}
-	ast_mutex_unlock(&conflock);
+	AST_LIST_UNLOCK(&confs);
 
 	LOCAL_USER_REMOVE(u);
 	
@@ -2270,8 +2248,8 @@
 	cnf->recording = MEETME_RECORD_ACTIVE;
 	while (ast_waitfor(cnf->lchan, -1) > -1) {
 		if (cnf->recording == MEETME_RECORD_TERMINATE) {
-			ast_mutex_lock(&conflock);
-			ast_mutex_unlock(&conflock);
+			AST_LIST_LOCK(&confs);
+			AST_LIST_UNLOCK(&confs);
 			break;
 		}
 		if (!s && cnf->recordingfilename && (cnf->recordingfilename != oldrecordingfilename)) {

Modified: team/bweschke/bug_5374/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_mixmonitor.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_mixmonitor.c (original)
+++ team/bweschke/bug_5374/apps/app_mixmonitor.c Sat Jan 28 08:26:51 2006
@@ -333,7 +333,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	parse = ast_strdupa(data);
+	if (!(parse = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(args, parse);
 	

Modified: team/bweschke/bug_5374/apps/app_osplookup.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_osplookup.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_osplookup.c (original)
+++ team/bweschke/bug_5374/apps/app_osplookup.c Sat Jan 28 08:26:51 2006
@@ -138,7 +138,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	temp = ast_strdupa(data);
+	if (!(temp = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(args, temp);
 
@@ -196,7 +199,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	temp = ast_strdupa(data);
+	if (!(temp = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(args, temp);
 
@@ -265,7 +271,10 @@
 
 	LOCAL_USER_ADD(u);
 
-	temp = ast_strdupa(data);
+	if (!(temp = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	AST_STANDARD_APP_ARGS(args, temp);
 

Modified: team/bweschke/bug_5374/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_page.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_page.c (original)
+++ team/bweschke/bug_5374/apps/app_page.c Sat Jan 28 08:26:51 2006
@@ -163,7 +163,10 @@
 		return -1;
 	};
 
-	options = ast_strdupa(data);
+	if (!(options = ast_strdupa(data))) {
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
 
 	tmp = strsep(&options, "|");
 	if (options)

Modified: team/bweschke/bug_5374/apps/app_parkandannounce.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_parkandannounce.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_parkandannounce.c (original)
+++ team/bweschke/bug_5374/apps/app_parkandannounce.c Sat Jan 28 08:26:51 2006
@@ -59,12 +59,21 @@
 
 static char *descrip =
 "  ParkAndAnnounce(announce:template|timeout|dial|[return_context]):\n"
-"Park a call into the parkinglot and announce the call over the console.\n"
-"announce template: colon separated list of files to announce, the word PARKED\n"
-"                   will be replaced by a say_digits of the ext the call is parked in\n"
-"timeout: time in seconds before the call returns into the return context.\n"
-"dial: The app_dial style resource to call to make the announcement. Console/dsp calls the console.\n"
-"return_context: the goto style label to jump the call back into after timeout. default=prio+1\n";
+"Park a call into the parkinglot and announce the call to another channel.\n"
+"\n"
+"announce template: Colon-separated list of files to announce.  The word PARKED\n"
+"                   will be replaced by a say_digits of the extension in which\n"
+"                   the call is parked.\n"
+"timeout:           Time in seconds before the call returns into the return\n"
+"                   context.\n"
+"dial:              The app_dial style resource to call to make the\n"
+"                   announcement.  Console/dsp calls the console.\n"
+"return_context:    The goto-style label to jump the call back into after\n"
+"                   timeout.  Default <priority+1>.\n"
+"\n"
+"The variable ${PARKEDAT} will contain the parking extension into which the\n"
+"call was placed.  Use with the Local channel to allow the dialplan to make\n"
+"use of this information.\n";
 
 
 STANDARD_LOCAL_USER;
@@ -79,6 +88,7 @@
 	char *working, *context, *exten, *priority, *dial, *dialtech, *dialstr;
 	char *template, *tpl_working, *tpl_current;
 	char *tmp[100];
+	char buf[13];
 	int looptemp=0,i=0;
 	char *s,*orig_s;
 
@@ -183,8 +193,10 @@
 
 	/* Now place the call to the extention */
 
+	snprintf(buf, sizeof(buf), "%d", lot);
 	memset(&oh, 0, sizeof(oh));
 	oh.parent_channel = chan;
+	oh.vars = ast_variable_new("_PARKEDAT", buf);
 	dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh);
 
 	if(dchan) {

Modified: team/bweschke/bug_5374/apps/app_playback.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_playback.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_playback.c (original)
+++ team/bweschke/bug_5374/apps/app_playback.c Sat Jan 28 08:26:51 2006
@@ -89,7 +89,8 @@
 		return -1;
 	}
 
-	tmp = ast_strdupa(data);
+	if (!(tmp = ast_strdupa(data)))
+		return -1;	
 
 	LOCAL_USER_ADD(u);
 	AST_STANDARD_APP_ARGS(args, tmp);

Modified: team/bweschke/bug_5374/apps/app_privacy.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_privacy.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_privacy.c (original)
+++ team/bweschke/bug_5374/apps/app_privacy.c Sat Jan 28 08:26:51 2006
@@ -117,7 +117,10 @@
 
 		if (!ast_strlen_zero((char *)data))
 		{
-			parse = ast_strdupa(data);
+			if (!(parse = ast_strdupa(data))) {
+				LOCAL_USER_REMOVE(u);
+				return -1;
+			}
 			
 			AST_STANDARD_APP_ARGS(args, parse);
 

Modified: team/bweschke/bug_5374/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_queue.c?rev=8819&r1=8818&r2=8819&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_queue.c (original)
+++ team/bweschke/bug_5374/apps/app_queue.c Sat Jan 28 08:26:51 2006
@@ -367,11 +367,10 @@
 	
 	struct member *members;		/*!< Head of the list of members */
 	struct queue_ent *head;		/*!< Head of the list of callers */
-	struct ast_call_queue *next;	/*!< Next call queue */
+	AST_LIST_ENTRY(ast_call_queue) list;	/*!< Next call queue */
 };
 
-static struct ast_call_queue *queues = NULL;
-AST_MUTEX_DEFINE_STATIC(qlock);
+static AST_LIST_HEAD_STATIC(queues, ast_call_queue);
 
 static int set_member_paused(char *queuename, char *interface, int paused);
 
@@ -481,8 +480,8 @@
 	}
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
-	ast_mutex_lock(&qlock);
-	for (q = queues; q; q = q->next) {
+	AST_LIST_LOCK(&queues);
+	AST_LIST_TRAVERSE(&queues, q, list) {
 		ast_mutex_lock(&q->lock);
 		cur = q->members;
 		while(cur) {
@@ -508,7 +507,7 @@
 		}
 		ast_mutex_unlock(&q->lock);
 	}
-	ast_mutex_unlock(&qlock);
+	AST_LIST_UNLOCK(&queues);
 	free(sc);
 	return NULL;
 }
@@ -788,26 +787,48 @@
 	}
 }
 
+static void free_members(struct ast_call_queue *q, int all)
+{
+	/* Free non-dynamic members */
+	struct member *curm, *next, *prev = NULL;
+
+	for (curm = q->members; curm; curm = next) {
+		next = curm->next;
+		if (all || !curm->dynamic) {
+			if (prev)
+				prev->next = next;
+			else
+				q->members = next;
+			free(curm);
+		} else 
+			prev = curm;
+	}
+}
+
+static void destroy_queue(struct ast_call_queue *q)
+{
+	free_members(q, 1);
+	ast_mutex_destroy(&q->lock);
+	free(q);
+}
 
 /*!\brief Reload a single queue via realtime.
    \return Return the queue, or NULL if it doesn't exist.
-   \note Should be called with the global qlock locked.
-   When found, the queue is returned with q->lock locked. */
+   \note Should be called with the global qlock locked. */
 static struct ast_call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
 {
 	struct ast_variable *v;
-	struct ast_call_queue *q, *prev_q = NULL;
+	struct ast_call_queue *q;
 	struct member *m, *prev_m, *next_m;
 	char *interface;
 	char *tmp, *tmp_name;
 	char tmpbuf[64];	/* Must be longer than the longest queue param name. */
 
 	/* Find the queue in the in-core list (we will create a new one if not found). */
-	for (q = queues; q; q = q->next) {
+	AST_LIST_TRAVERSE(&queues, q, list) {
 		if (!strcasecmp(q->name, queuename)) {
 			break;
 		}
-		prev_q = q;
 	}
 
 	/* Static queues override realtime. */
@@ -818,6 +839,7 @@
 				ast_mutex_unlock(&q->lock);
 				return NULL;
 			} else {
+				ast_mutex_unlock(&q->lock);
 				return q;
 			}
 		}
@@ -838,13 +860,9 @@
 			/* Delete if unused (else will be deleted when last caller leaves). */
 			if (!q->count) {
 				/* Delete. */
-				if (!prev_q) {
-					queues = q->next;
-				} else {
-					prev_q->next = q->next;
-				}
+				AST_LIST_REMOVE(&queues, q, list);
 				ast_mutex_unlock(&q->lock);
-				free(q);
+				destroy_queue(q);
 			} else
 				ast_mutex_unlock(&q->lock);
 		}
@@ -858,8 +876,7 @@
 		ast_mutex_lock(&q->lock);
 		clear_queue(q);
 		q->realtime = 1;
-		q->next = queues;
-		queues = q;
+		AST_LIST_INSERT_HEAD(&queues, q, list);
 	}
 	init_queue(q);		/* Ensure defaults for all parameters not set explicitly. */
 
@@ -911,13 +928,60 @@
 		m = next_m;
 	}
 
+	ast_mutex_unlock(&q->lock);
+
 	return q;
 }
 

[... 10860 lines stripped ...]


More information about the svn-commits mailing list