[asterisk-commits] russell: branch russell/events r114457 - in /team/russell/events: ./ apps/ cd...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 21 18:05:09 CDT 2008


Author: russell
Date: Mon Apr 21 18:05:08 2008
New Revision: 114457

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114457
Log:
resolve conflicts, sync with trunk, kill some warnings ...

Added:
    team/russell/events/doc/chan_sip-perf-testing.txt
      - copied unchanged from r114456, trunk/doc/chan_sip-perf-testing.txt
    team/russell/events/include/asterisk/dlinkedlists.h
      - copied unchanged from r114456, trunk/include/asterisk/dlinkedlists.h
    team/russell/events/pbx/ael/ael-test/ael-ntest24/
      - copied from r114456, trunk/pbx/ael/ael-test/ael-ntest24/
    team/russell/events/pbx/ael/ael-test/ael-ntest24/extensions.ael
      - copied unchanged from r114456, trunk/pbx/ael/ael-test/ael-ntest24/extensions.ael
    team/russell/events/pbx/ael/ael-test/ref.ael-ntest24
      - copied unchanged from r114456, trunk/pbx/ael/ael-test/ref.ael-ntest24
    team/russell/events/tests/test_dlinklists.c
      - copied unchanged from r114456, trunk/tests/test_dlinklists.c
    team/russell/events/utils/refcounter.c
      - copied unchanged from r114456, trunk/utils/refcounter.c
Modified:
    team/russell/events/   (props changed)
    team/russell/events/CHANGES
    team/russell/events/Makefile
    team/russell/events/apps/app_authenticate.c
    team/russell/events/apps/app_chanspy.c
    team/russell/events/apps/app_dial.c
    team/russell/events/apps/app_directory.c
    team/russell/events/apps/app_externalivr.c
    team/russell/events/apps/app_festival.c
    team/russell/events/apps/app_ices.c
    team/russell/events/apps/app_meetme.c
    team/russell/events/apps/app_mp3.c
    team/russell/events/apps/app_nbscat.c
    team/russell/events/apps/app_queue.c
    team/russell/events/apps/app_setcallerid.c
    team/russell/events/apps/app_voicemail.c
    team/russell/events/apps/app_zapras.c
    team/russell/events/cdr/cdr_pgsql.c
    team/russell/events/channels/chan_h323.c
    team/russell/events/channels/chan_iax2.c
    team/russell/events/channels/chan_local.c
    team/russell/events/channels/chan_sip.c
    team/russell/events/channels/chan_skinny.c
    team/russell/events/channels/chan_unistim.c
    team/russell/events/channels/chan_zap.c
    team/russell/events/configs/res_ldap.conf.sample
    team/russell/events/configs/sip.conf.sample
    team/russell/events/contrib/scripts/astcli
    team/russell/events/contrib/scripts/autosupport
    team/russell/events/doc/CODING-GUIDELINES
    team/russell/events/doc/janitor-projects.txt
    team/russell/events/doc/tex/ael.tex
    team/russell/events/doc/tex/channelvariables.tex
    team/russell/events/include/asterisk/app.h
    team/russell/events/include/asterisk/astobj2.h
    team/russell/events/include/asterisk/dsp.h
    team/russell/events/include/asterisk/frame.h
    team/russell/events/include/asterisk/lock.h
    team/russell/events/include/asterisk/logger.h
    team/russell/events/include/asterisk/sched.h
    team/russell/events/main/app.c
    team/russell/events/main/ast_expr2.c
    team/russell/events/main/ast_expr2.fl
    team/russell/events/main/ast_expr2.h
    team/russell/events/main/ast_expr2.y
    team/russell/events/main/ast_expr2f.c
    team/russell/events/main/asterisk.c
    team/russell/events/main/astobj2.c
    team/russell/events/main/autoservice.c
    team/russell/events/main/callerid.c
    team/russell/events/main/channel.c
    team/russell/events/main/dsp.c
    team/russell/events/main/event.c
    team/russell/events/main/features.c
    team/russell/events/main/file.c
    team/russell/events/main/frame.c
    team/russell/events/main/logger.c
    team/russell/events/main/manager.c
    team/russell/events/main/pbx.c
    team/russell/events/main/rtp.c
    team/russell/events/main/sched.c
    team/russell/events/main/utils.c
    team/russell/events/pbx/ael/ael-test/ref.ael-ntest10
    team/russell/events/pbx/ael/ael-test/ref.ael-test1
    team/russell/events/pbx/ael/ael-test/ref.ael-test18
    team/russell/events/pbx/ael/ael-test/ref.ael-test19
    team/russell/events/pbx/ael/ael-test/ref.ael-test3
    team/russell/events/pbx/ael/ael-test/ref.ael-test5
    team/russell/events/pbx/ael/ael-test/ref.ael-test8
    team/russell/events/pbx/ael/ael-test/ref.ael-vtest13
    team/russell/events/pbx/ael/ael-test/ref.ael-vtest17
    team/russell/events/phoneprov/polycom.xml
    team/russell/events/phoneprov/polycom_line.xml
    team/russell/events/res/ais/evt.c
    team/russell/events/res/res_agi.c
    team/russell/events/res/res_config_ldap.c
    team/russell/events/res/res_http_post.c
    team/russell/events/res/res_jabber.c
    team/russell/events/res/res_musiconhold.c
    team/russell/events/res/res_phoneprov.c
    team/russell/events/res/res_xmlevents.c
    team/russell/events/utils/   (props changed)
    team/russell/events/utils/Makefile
    team/russell/events/utils/ael_main.c
    team/russell/events/utils/astman.c
    team/russell/events/utils/check_expr.c
    team/russell/events/utils/conf2ael.c
    team/russell/events/utils/hashtest.c
    team/russell/events/utils/hashtest2.c

Propchange: team/russell/events/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/russell/events/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/russell/events/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/russell/events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr 21 18:05:08 2008
@@ -1,1 +1,1 @@
-/trunk:1-114010
+/trunk:1-114456

Modified: team/russell/events/CHANGES
URL: http://svn.digium.com/view/asterisk/team/russell/events/CHANGES?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/CHANGES (original)
+++ team/russell/events/CHANGES Mon Apr 21 18:05:08 2008
@@ -29,12 +29,24 @@
    messages, if the "messagewrap" option is set to a true value.
  * Dial has a new option: F(context^extension^pri), which permits a callee to
    continue in the dialplan, at the specified label, if the caller hangs up.
+ * ChanSpy and ExtenSpy have a new option, 's' which suppresses speaking the
+   technology name (e.g. SIP, IAX, etc) of the channel being spied on.
 
 SIP Changes
 -----------
  * The ATTENDED_TRANSFER_COMPLETE_SOUND can now be set using setvar to cause a given
    audio file to be played upon completion of an attended transfer.
  * Added DNS manager support to registrations for peers referencing peer entries.
+   DNS manager runs in the background which allows DNS lookups to be run asynchronously 
+   as well as periodically updating the IP address. These properties allow for
+   better performance as well as recovery in the event of an IP change.
+ * Performance improvements via using hash tables (astobj2) and doubly-linked lists to improve 
+   load/reload of large numbers of peers/users by ~40x (for large lists of peers.
+   Initially, we saw 4x improvement in call setup/destruction, but at the time
+   of merging, this gain has disappeared; further research will be done to try
+   and restore this performance improvement. Astobj2 refcounting is now used
+   for users, peers, and dialogs.  Users are encouraged to assist in regression
+   testing and problem reporting!
 
 IAX Changes
 -----------
@@ -155,6 +167,10 @@
   * Added a CLI command, "devstate change", which allows you to set custom device
      states from the func_devstate module that provides the DEVICE_STATE() function
      and handling of the "Custom:" devices.
+  * New CLI command: "sip show sched" which shows all ast_sched entries for sip,
+    sorted into the different possible callbacks, with the number of entries
+    currently scheduled for each. Gives you a feel for how busy the sip channel
+    driver is.
 
 SIP changes
 -----------
@@ -257,6 +273,9 @@
      SIP call to Voicemail by putting a Local channel in the middle.  This
      feature is enabled by using the 'j' option in the Dial string to the Local
      channel in conjunction with the existing 'n' option for local channels.
+  * A 'b' option has been added which causes chan_local to return the actual channel
+     that is behind it when queried. This is useful for transfer scenarios as the
+     actual channel will be transferred, not the Local channel.
 
 Zaptel channel driver (chan_zap) Changes
 ----------------------------------------
@@ -411,6 +430,8 @@
      for the "meetme" command.
   * Added the ability to specify the music on hold class used to play into the
      conference when there is only one member and the M option is used.
+  * Added MEETME_INFO dialplan function which provides a way to query
+     various properties of a Meetme conference.
 
 Other Dialplan Application Changes
 ----------------------------------
@@ -483,6 +504,17 @@
      first pass at conversion.
   * aelparse will now read extensions.conf to see if a referenced
      macro or context is there before issueing a warning.
+  * AEL parser sets a local channel variable ~~EXTEN~~, to 
+    preserve the value of ${EXTEN} thru switch statements.
+  * New operator in $[...] expressions: the ~~ operator serves
+    as a concatenation operator. AT THE MOMENT, it is really only
+    necessary and useful in AEL, especially in if() expressions.
+    Operation: ${a} ~~ ${b|  with force both a and b to strings, strip 
+    any enclosing double-quotes, and evaluate to the value of a
+    concatenated with the value of b.  For example if a is set to
+    "xyz"  and b has the value "abc", then ${a} ~~ ${b| would
+    evaluate to xyzabc .
+
 
 Call Features (res_features) Changes
 ------------------------------------
@@ -612,6 +644,18 @@
   * A new option when starting a remote asterisk (rasterisk, asterisk -r) for
      specifying which socket to use to connect to the running Asterisk daemon
      (-s)
+  * Performance enhancements to the sched facility, which is used in
+    the channel drivers, etc. Added hashtabs and doubly-linked lists
+    to speed up deletion; start at the beginning or end of list to
+    speed up insertion.
+  * Added Doubly-linked lists after the fashion of linkedlists.h. They are in
+    dlinkedlists.h. Doubly-linked lists feature fast deletion times.
+    Added regression tests to the tests/ dir, also.
+  * Added a refcount trace feature to astobj2 for those trying to balance
+    object creation, deletion; work, play; space and time. See the
+    notes in astobj2.h. Also, see utils/refcounter as well, as a
+    quick way to find unbalanced refcounts in what could be a sea
+    of objects that were balanced.
   * Added logging to 'make update' command.  See update.log
   * Added strictrtp option to rtp.conf. If enabled this will drop RTP packets that
      do not come from the remote party.

Modified: team/russell/events/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/events/Makefile?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/Makefile (original)
+++ team/russell/events/Makefile Mon Apr 21 18:05:08 2008
@@ -498,7 +498,7 @@
 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
 
-bininstall: _all
+installdirs:
 	mkdir -p $(DESTDIR)$(MODULES_DIR)
 	mkdir -p $(DESTDIR)$(ASTSBINDIR)
 	mkdir -p $(DESTDIR)$(ASTETCDIR)
@@ -510,6 +510,8 @@
 	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
 	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
 	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
+
+bininstall: _all installdirs $(SUBDIRS_INSTALL)
 	$(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
 	$(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
 	$(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
@@ -571,7 +573,7 @@
 	@exit 1
 endif
 
-install: badshell datafiles bininstall $(SUBDIRS_INSTALL)
+install: badshell datafiles bininstall
 	@if [ -x /usr/sbin/asterisk-post-install ]; then \
 		/usr/sbin/asterisk-post-install $(DESTDIR) . ; \
 	fi
@@ -867,4 +869,4 @@
 asterisk.pdf:
 	$(MAKE) -C doc/tex asterisk.pdf
 
-.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) badshell main/version.c include/asterisk/version.h
+.PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) badshell main/version.c include/asterisk/version.h installdirs

Modified: team/russell/events/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_authenticate.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_authenticate.c (original)
+++ team/russell/events/apps/app_authenticate.c Mon Apr 21 18:05:08 2008
@@ -126,9 +126,7 @@
 			/* Compare against a fixed password */
 			if (!strcmp(passwd, arglist.password))
 				break;
-		}
-
-		if (ast_test_flag(&flags,OPT_DATABASE)) {
+		} else if (ast_test_flag(&flags,OPT_DATABASE)) {
 			char tmp[256];
 			/* Compare against a database key */
 			if (!ast_db_get(arglist.password + 1, passwd, tmp, sizeof(tmp))) {

Modified: team/russell/events/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_chanspy.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_chanspy.c (original)
+++ team/russell/events/apps/app_chanspy.c Mon Apr 21 18:05:08 2008
@@ -77,6 +77,8 @@
 "    r[(basename)] - Record the session to the monitor spool directory. An\n"
 "                    optional base for the filename may be specified. The\n"
 "                    default is 'chanspy'.\n"
+"    s             - Skip the playback of the channel type (i.e. SIP, IAX, etc) when\n"
+"                    speaking the selected channel name.\n"
 "    v([value])    - Adjust the initial volume in the range from -4 to 4. A\n"
 "                    negative value refers to a quieter setting.\n"
 "    w             - Enable 'whisper' mode, so the spying channel can talk to\n"
@@ -117,6 +119,8 @@
 "    r[(basename)] - Record the session to the monitor spool directory. An\n"
 "                    optional base for the filename may be specified. The\n"
 "                    default is 'chanspy'.\n"
+"    s             - Skip the playback of the channel type (i.e. SIP, IAX, etc) when\n"
+"                    speaking the selected channel name.\n"
 "    v([value])    - Adjust the initial volume in the range from -4 to 4. A\n"
 "                    negative value refers to a quieter setting.\n"
 "    w             - Enable 'whisper' mode, so the spying channel can talk to\n"
@@ -143,6 +147,7 @@
 	OPTION_READONLY  = (1 << 7),    /* Don't mix the two channels */
 	OPTION_EXIT      = (1 << 8),    /* Exit to a valid single digit extension */
 	OPTION_ENFORCED  = (1 << 9),    /* Enforced mode */
+	OPTION_NOTECH    = (1 << 10),   /* Skip technology name playback */
 } chanspy_opt_flags;
 
 enum {
@@ -164,6 +169,7 @@
 	AST_APP_OPTION_ARG('e', OPTION_ENFORCED, OPT_ARG_ENFORCED),
 	AST_APP_OPTION('o', OPTION_READONLY),
 	AST_APP_OPTION('X', OPTION_EXIT),
+	AST_APP_OPTION('s', OPTION_NOTECH),
 });
 
 
@@ -496,30 +502,29 @@
 	const struct ast_channel *last, const char *spec,
 	const char *exten, const char *context, struct chanspy_ds *chanspy_ds)
 {
-	struct ast_channel *this;
+	struct ast_channel *next;
 
 redo:
 	if (!ast_strlen_zero(spec))
-		this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
-
+		next = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
 	else if (!ast_strlen_zero(exten))
-		this = ast_walk_channel_by_exten_locked(last, exten, context);
+		next = ast_walk_channel_by_exten_locked(last, exten, context);
 	else
-		this = ast_channel_walk_locked(last);
-
-	if (!this)
+		next = ast_channel_walk_locked(last);
+
+	if (!next)
 		return NULL;
 
-	if (!strncmp(this->name, "Zap/pseudo", 10)) {
-		ast_channel_unlock(this);
+	if (!strncmp(next->name, "Zap/pseudo", 10)) {
+		ast_channel_unlock(next);
 		goto redo;
-	} else if (this == chan) {
-		last = this;
-		ast_channel_unlock(this);
+	} else if (next == chan) {
+		last = next;
+		ast_channel_unlock(next);
 		goto redo;
 	}
 
-	return setup_chanspy_ds(this, chanspy_ds);
+	return setup_chanspy_ds(next, chanspy_ds);
 }
 
 static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
@@ -615,7 +620,6 @@
 			char *ext;
 			char *form_enforced;
 			int ienf = !myenforced;
-			struct ast_channel *peer;
 
 			peer = peer_chanspy_ds->chan;
 
@@ -709,16 +713,20 @@
 			peer = NULL;
 
 			if (!ast_test_flag(flags, OPTION_QUIET)) {
-				if (ast_fileexists(peer_name, NULL, NULL) != -1) {
-					res = ast_streamfile(chan, peer_name, chan->language);
-					if (!res)
-						res = ast_waitstream(chan, "");
-					if (res) {
-						chanspy_ds_free(peer_chanspy_ds);
-						break;
+				if (!ast_test_flag(flags, OPTION_NOTECH)) {
+					if (ast_fileexists(peer_name, NULL, NULL) != -1) {
+						res = ast_streamfile(chan, peer_name, chan->language);
+						if (!res) {
+							res = ast_waitstream(chan, "");
+						}
+						if (res) {
+							chanspy_ds_free(peer_chanspy_ds);
+							break;
+						}
+					} else {
+						res = ast_say_character_str(chan, peer_name, "", chan->language);
 					}
-				} else
-					res = ast_say_character_str(chan, peer_name, "", chan->language);
+				}
 				if ((num = atoi(ptr)))
 					ast_say_digits(chan, atoi(ptr), "", chan->language);
 			}
@@ -830,7 +838,7 @@
 	}
 
 	if (recbase) {
-		char filename[512];
+		char filename[PATH_MAX];
 
 		snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
 		if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {
@@ -909,7 +917,7 @@
 	}
 
 	if (recbase) {
-		char filename[512];
+		char filename[PATH_MAX];
 
 		snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
 		if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {

Modified: team/russell/events/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_dial.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_dial.c (original)
+++ team/russell/events/apps/app_dial.c Mon Apr 21 18:05:08 2008
@@ -1600,8 +1600,14 @@
 	time(&start_time);
 	peer = wait_for_answer(chan, outgoing, &to, peerflags, &pa, &num, &result);
 
-	ast_channel_datastore_remove(chan, datastore);
-	ast_channel_datastore_free(datastore);
+	/* The ast_channel_datastore_remove() function could fail here if the
+	 * datastore was moved to another channel during a masquerade. If this is
+	 * the case, don't free the datastore here because later, when the channel
+	 * to which the datastore was moved hangs up, it will attempt to free this
+	 * datastore again, causing a crash
+	 */
+	if (!ast_channel_datastore_remove(chan, datastore))
+		ast_channel_datastore_free(datastore);
 	if (!peer) {
 		if (result) {
 			res = result;

Modified: team/russell/events/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_directory.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_directory.c (original)
+++ team/russell/events/apps/app_directory.c Mon Apr 21 18:05:08 2008
@@ -858,14 +858,23 @@
 		if (!ast_strlen_zero(dirintro) && !res) {
 			res = ast_stream_and_wait(chan, dirintro, AST_DIGIT_ANY);
 		} else if (!res) {
-			res = ast_stream_and_wait(chan, "dir-welcome", AST_DIGIT_ANY) ||
-				ast_stream_and_wait(chan, "dir-pls-enter", AST_DIGIT_ANY) ||
-				ast_stream_and_wait(chan, digits, AST_DIGIT_ANY) ||
-				ast_stream_and_wait(chan, 
+			/* Stop playing sounds as soon as we have a digit. */
+			res = ast_stream_and_wait(chan, "dir-welcome", AST_DIGIT_ANY);
+			if (!res) {
+				res = ast_stream_and_wait(chan, "dir-pls-enter", AST_DIGIT_ANY);
+			}
+			if (!res) {
+				res = ast_stream_and_wait(chan, digits, AST_DIGIT_ANY);
+			}
+			if (!res) {
+				res = ast_stream_and_wait(chan, 
 					which == FIRST ? "dir-first" :
 					which == LAST ? "dir-last" :
-					"dir-firstlast", AST_DIGIT_ANY) ||
+					"dir-firstlast", AST_DIGIT_ANY);
+			}
+			if (!res) {
 				ast_stream_and_wait(chan, "dir-usingkeypad", AST_DIGIT_ANY);
+			}
 		}
 		ast_stopstream(chan);
 		if (!res)

Modified: team/russell/events/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_externalivr.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_externalivr.c (original)
+++ team/russell/events/apps/app_externalivr.c Mon Apr 21 18:05:08 2008
@@ -319,13 +319,9 @@
 		.finishlist = AST_LIST_HEAD_INIT_VALUE,
 	};
 	struct ivr_localuser *u = &foo;
-	sigset_t fullset, oldset;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(cmd)[32];
 	);
-
-	sigfillset(&fullset);
-	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
 
 	u->abort_current_sound = 0;
 	u->chan = chan;
@@ -405,7 +401,7 @@
 			gen_active = 1;
 		}
 	
-		pid = fork();
+		pid = ast_safe_fork(0);
 		if (pid < 0) {
 			ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno));
 			goto exit;
@@ -413,19 +409,13 @@
 	
 		if (!pid) {
 			/* child process */
-			int i;
-	
-			signal(SIGPIPE, SIG_DFL);
-			pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
-	
 			if (ast_opt_high_priority)
 				ast_set_priority(0);
 	
 			dup2(child_stdin[0], STDIN_FILENO);
 			dup2(child_stdout[1], STDOUT_FILENO);
 			dup2(child_stderr[1], STDERR_FILENO);
-			for (i = STDERR_FILENO + 1; i < 1024; i++)
-				close(i);
+			ast_close_fds_above_n(STDERR_FILENO);
 			execv(args.cmd[0], args.cmd);
 			fprintf(stderr, "Failed to execute '%s': %s\n", args.cmd[0], strerror(errno));
 			_exit(1);

Modified: team/russell/events/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_festival.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_festival.c (original)
+++ team/russell/events/apps/app_festival.c Mon Apr 21 18:05:08 2008
@@ -117,30 +117,20 @@
 static int send_waveform_to_fd(char *waveform, int length, int fd)
 {
 	int res;
-	int x;
 #ifdef __PPC__ 
 	char c;
 #endif
-	sigset_t fullset, oldset;
-
-	sigfillset(&fullset);
-	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
-
-	res = fork();
+
+	res = ast_safe_fork(0);
 	if (res < 0)
 		ast_log(LOG_WARNING, "Fork failed\n");
 	if (res) {
-		pthread_sigmask(SIG_SETMASK, &oldset, NULL);
 		return res;
 	}
-	for (x = 0; x < 256; x++) {
-		if (x != fd)
-			close(x);
-	}
+	dup2(fd, 0);
+	ast_close_fds_above_n(0);
 	if (ast_opt_high_priority)
 		ast_set_priority(0);
-	signal(SIGPIPE, SIG_DFL);
-	pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
 #ifdef __PPC__  
 	for (x = 0; x < length; x += 2) {
 		c = *(waveform + x + 1);

Modified: team/russell/events/apps/app_ices.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_ices.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_ices.c (original)
+++ team/russell/events/apps/app_ices.c Mon Apr 21 18:05:08 2008
@@ -43,6 +43,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/translate.h"
+#include "asterisk/app.h"
 
 #define ICES "/usr/bin/ices"
 #define LOCAL_ICES "/usr/local/bin/ices"
@@ -60,31 +61,18 @@
 static int icesencode(char *filename, int fd)
 {
 	int res;
-	int x;
-	sigset_t fullset, oldset;
 
-	sigfillset(&fullset);
-	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
-
-	res = fork();
+	res = ast_safe_fork(0);
 	if (res < 0) 
 		ast_log(LOG_WARNING, "Fork failed\n");
 	if (res) {
-		pthread_sigmask(SIG_SETMASK, &oldset, NULL);
 		return res;
 	}
-
-	/* Stop ignoring PIPE */
-	signal(SIGPIPE, SIG_DFL);
-	pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
 
 	if (ast_opt_high_priority)
 		ast_set_priority(0);
 	dup2(fd, STDIN_FILENO);
-	for (x=STDERR_FILENO + 1;x<1024;x++) {
-		if ((x != STDIN_FILENO) && (x != STDOUT_FILENO))
-			close(x);
-	}
+	ast_close_fds_above_n(STDERR_FILENO);
 	/* Most commonly installed in /usr/local/bin */
 	execl(ICES, "ices", filename, (char *)NULL);
 	/* But many places has it in /usr/bin */
@@ -183,7 +171,7 @@
 		}
 	}
 	close(fds[1]);
-	
+
 	if (pid > -1)
 		kill(pid, SIGKILL);
 	if (!res && oreadformat)

Modified: team/russell/events/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_meetme.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_meetme.c (original)
+++ team/russell/events/apps/app_meetme.c Mon Apr 21 18:05:08 2008
@@ -1694,8 +1694,17 @@
 	ast_mutex_unlock(&conf->playlock);
 
 	if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) {
+		char destdir[PATH_MAX];
+
+		snprintf(destdir, sizeof(destdir), "%s/meetme", ast_config_AST_SPOOL_DIR);
+
+		if (ast_mkdir(destdir, 0777) != 0) {
+			ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", destdir, strerror(errno));
+			goto outrun;
+		}
+
 		snprintf(user->namerecloc, sizeof(user->namerecloc),
-			 "%s/meetme/meetme-username-%s-%d", ast_config_AST_SPOOL_DIR,
+			 "%s/meetme-username-%s-%d", destdir,
 			 conf->confno, user->user_no);
 		if (confflags & CONFFLAG_INTROUSERNOREVIEW)
 			res = ast_play_and_record(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE), 0, NULL);
@@ -5516,6 +5525,88 @@
 	return res;
 }
 
+static int acf_meetme_info_eval(char *keyword, struct ast_conference *conf)
+{
+	if (!strcasecmp("lock", keyword)) {
+		return conf->locked;
+	} else if (!strcasecmp("parties", keyword)) {
+		return conf->users;
+	} else if (!strcasecmp("activity", keyword)) {
+		time_t now;
+		now = time(NULL);
+		return (now - conf->start);
+	} else if (!strcasecmp("dynamic", keyword)) {
+		return conf->isdynamic;
+	} else {
+		return -1;
+	}
+
+}
+
+static int acf_meetme_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+	struct ast_conference *conf;
+	char *parse;
+	int result = -2; /* only non-negative numbers valid, -1 is used elsewhere */
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(keyword);
+		AST_APP_ARG(confno);
+	);
+
+	if (ast_strlen_zero(data)) {
+		ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires two arguments\n");
+		return -1;
+	}
+
+	parse = ast_strdupa(data);
+	AST_STANDARD_APP_ARGS(args, parse);
+
+	if (ast_strlen_zero(args.keyword)) {
+		ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a keyword\n");
+		return -1;
+	}
+
+	if (ast_strlen_zero(args.confno)) {
+		ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a conference number\n");
+		return -1;
+	}
+
+	AST_LIST_LOCK(&confs);
+	AST_LIST_TRAVERSE(&confs, conf, list) {
+		if (!strcmp(args.confno, conf->confno)) {
+			result = acf_meetme_info_eval(args.keyword, conf);
+			break;
+		}
+	}
+	AST_LIST_UNLOCK(&confs);
+
+	if (result > -1) {
+		snprintf(buf, len, "%d", result);
+	} else if (result == -1) {
+		snprintf(buf, len, "%s %s", "Error: invalid keyword:", args.keyword);
+	} else if (result == -2) {
+		snprintf(buf, len, "Error: conference (%s) not found", args.confno);
+	}
+
+	return 0;
+}
+
+
+static struct ast_custom_function meetme_info_acf = {
+	.name = "MEETME_INFO",
+	.synopsis = "Query a given conference of various properties.",
+	.syntax = "MEETME_INFO(<keyword>,<confno>)",
+	.read = acf_meetme_info,
+	.desc =
+"Returns information from a given keyword. (For booleans 1-true, 0-false)\n"
+"  Options:\n"
+"    lock     - boolean of whether the corresponding conference is locked\n" 
+"    parties  - number of parties in a given conference\n"
+"    activity - duration of conference in seconds\n"
+"    dynamic  - boolean of whether the corresponding coference is dynamic\n",
+};
+
+
 static int load_config(int reload)
 {
 	load_config_meetme();
@@ -5549,6 +5640,8 @@
 	ast_devstate_prov_del("SLA");
 	
 	sla_destroy();
+	
+	res |= ast_custom_function_unregister(&meetme_info_acf);
 
 	return res;
 }
@@ -5578,6 +5671,8 @@
 	res |= ast_devstate_prov_add("Meetme", meetmestate);
 	res |= ast_devstate_prov_add("SLA", sla_state);
 
+	res |= ast_custom_function_register(&meetme_info_acf);
+
 	return res;
 }
 

Modified: team/russell/events/apps/app_mp3.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_mp3.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_mp3.c (original)
+++ team/russell/events/apps/app_mp3.c Mon Apr 21 18:05:08 2008
@@ -39,6 +39,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/translate.h"
+#include "asterisk/app.h"
 
 #define LOCAL_MPG_123 "/usr/local/bin/mpg123"
 #define MPG_123 "/usr/bin/mpg123"
@@ -56,29 +57,19 @@
 static int mp3play(char *filename, int fd)
 {
 	int res;
-	int x;
-	sigset_t fullset, oldset;
-
-	sigfillset(&fullset);
-	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
-
-	res = fork();
+
+	res = ast_safe_fork(0);
 	if (res < 0) 
 		ast_log(LOG_WARNING, "Fork failed\n");
 	if (res) {
-		pthread_sigmask(SIG_SETMASK, &oldset, NULL);
 		return res;
 	}
 	if (ast_opt_high_priority)
 		ast_set_priority(0);
-	signal(SIGPIPE, SIG_DFL);
-	pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
 
 	dup2(fd, STDOUT_FILENO);
-	for (x=STDERR_FILENO + 1;x<256;x++) {
-		if (x != STDOUT_FILENO)
-			close(x);
-	}
+	ast_close_fds_above_n(STDERR_FILENO);
+
 	/* Execute mpg123, but buffer if it's a net connection */
 	if (!strncasecmp(filename, "http://", 7)) {
 		/* Most commonly installed in /usr/local/bin */
@@ -96,7 +87,8 @@
 		/* As a last-ditch effort, try to use PATH */
 	    execlp("mpg123", "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
 	}
-	ast_log(LOG_WARNING, "Execute of mpg123 failed\n");
+	/* Can't use ast_log since FD's are closed */
+	fprintf(stderr, "Execute of mpg123 failed\n");
 	_exit(0);
 }
 

Modified: team/russell/events/apps/app_nbscat.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_nbscat.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_nbscat.c (original)
+++ team/russell/events/apps/app_nbscat.c Mon Apr 21 18:05:08 2008
@@ -41,6 +41,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/translate.h"
+#include "asterisk/app.h"
 
 #define LOCAL_NBSCAT "/usr/local/bin/nbscat8k"
 #define NBSCAT "/usr/bin/nbscat8k"
@@ -61,34 +62,25 @@
 static int NBScatplay(int fd)
 {
 	int res;
-	int x;
-	sigset_t fullset, oldset;
-
-	sigfillset(&fullset);
-	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
-
-	res = fork();
-	if (res < 0) 
+
+	res = ast_safe_fork(0);
+	if (res < 0) {
 		ast_log(LOG_WARNING, "Fork failed\n");
+	}
+
 	if (res) {
-		pthread_sigmask(SIG_SETMASK, &oldset, NULL);
 		return res;
 	}
-	signal(SIGPIPE, SIG_DFL);
-	pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
 
 	if (ast_opt_high_priority)
 		ast_set_priority(0);
 
 	dup2(fd, STDOUT_FILENO);
-	for (x = STDERR_FILENO + 1; x < 1024; x++) {
-		if (x != STDOUT_FILENO)
-			close(x);
-	}
+	ast_close_fds_above_n(STDERR_FILENO);
 	/* Most commonly installed in /usr/local/bin */
 	execl(NBSCAT, "nbscat8k", "-d", (char *)NULL);
 	execl(LOCAL_NBSCAT, "nbscat8k", "-d", (char *)NULL);
-	ast_log(LOG_WARNING, "Execute of nbscat8k failed\n");
+	fprintf(stderr, "Execute of nbscat8k failed\n");
 	_exit(0);
 }
 

Modified: team/russell/events/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_queue.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_queue.c (original)
+++ team/russell/events/apps/app_queue.c Mon Apr 21 18:05:08 2008
@@ -939,7 +939,6 @@
 	q->monfmt[0] = '\0';
 	q->reportholdtime = 0;
 	q->wrapuptime = 0;
-	q->autofill = 0;
 	q->joinempty = 0;
 	q->leavewhenempty = 0;
 	q->memberdelay = 0;
@@ -1532,7 +1531,11 @@
 				*tmp++ = '-';
 		} else
 			tmp_name = v->name;
-		queue_set_param(q, tmp_name, v->value, -1, 0);
+
+		if (!ast_strlen_zero(v->value)) {
+			/* Don't want to try to set the option if the value is empty */
+			queue_set_param(q, tmp_name, v->value, -1, 0);
+		}
 	}
 
 	/* Temporarily set realtime members dead so we can detect deleted ones. 
@@ -3252,8 +3255,13 @@
 	if (use_weight)
 		ao2_unlock(queues);
 	lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT), forwardsallowed);
-	if (datastore) {
-		ast_channel_datastore_remove(qe->chan, datastore);
+	/* The ast_channel_datastore_remove() function could fail here if the
+	 * datastore was moved to another channel during a masquerade. If this is
+	 * the case, don't free the datastore here because later, when the channel
+	 * to which the datastore was moved hangs up, it will attempt to free this
+	 * datastore again, causing a crash
+	 */
+	if (datastore && !ast_channel_datastore_remove(qe->chan, datastore)) {
 		ast_channel_datastore_free(datastore);
 	}
 	ao2_lock(qe->parent);

Modified: team/russell/events/apps/app_setcallerid.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_setcallerid.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_setcallerid.c (original)
+++ team/russell/events/apps/app_setcallerid.c Mon Apr 21 18:05:08 2008
@@ -68,7 +68,11 @@
 		deprecated = 1;
 		ast_log(LOG_WARNING, "SetCallerPres is deprecated.  Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
 	}
-	pres = ast_parse_caller_presentation(data);
+
+	/* For interface consistency, permit the argument to be specified as a number */
+	if (sscanf(data, "%d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
+		pres = ast_parse_caller_presentation(data);
+	}
 
 	if (pres < 0) {
 		ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",

Modified: team/russell/events/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_voicemail.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_voicemail.c (original)
+++ team/russell/events/apps/app_voicemail.c Mon Apr 21 18:05:08 2008
@@ -6636,7 +6636,7 @@
 			res = say_and_wait(chan, dcnum, chan->language);
 		if (!res && lastnum) {
 			if (lastnum == 1) 
-				res = ast_play_and_wait(chan, "digits/ru/odno");
+				res = ast_play_and_wait(chan, "digits/odno");
 			else
 				res = say_and_wait(chan, lastnum, chan->language);
 		}
@@ -6655,7 +6655,7 @@
 			res = say_and_wait(chan, dcnum, chan->language);
 		if (!res && lastnum) {
 			if (lastnum == 1) 
-				res = ast_play_and_wait(chan, "digits/ru/odno");
+				res = ast_play_and_wait(chan, "digits/odno");
 			else
 				res = say_and_wait(chan, lastnum, chan->language);
 		}

Modified: team/russell/events/apps/app_zapras.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/apps/app_zapras.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/apps/app_zapras.c (original)
+++ team/russell/events/apps/app_zapras.c Mon Apr 21 18:05:08 2008
@@ -50,6 +50,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
+#include "asterisk/app.h"
 
 static char *app = "ZapRAS";
 
@@ -69,29 +70,17 @@
 static pid_t spawn_ras(struct ast_channel *chan, char *args)
 {
 	pid_t pid;
-	int x;	
 	char *c;
 
 	char *argv[PPP_MAX_ARGS];
 	int argc = 0;
 	char *stringp=NULL;
-	sigset_t fullset, oldset;
-
-	sigfillset(&fullset);
-	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
 
 	/* Start by forking */
-	pid = fork();
+	pid = ast_safe_fork(1);
 	if (pid) {
-		pthread_sigmask(SIG_SETMASK, &oldset, NULL);
 		return pid;
 	}
-
-	/* Restore original signal handlers */
-	for (x=0;x<NSIG;x++)
-		signal(x, SIG_DFL);
-
-	pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
 
 	/* Execute RAS on File handles */
 	dup2(chan->fds[0], STDIN_FILENO);
@@ -101,8 +90,7 @@
 		ast_set_priority(0);
 
 	/* Close other file descriptors */
-	for (x=STDERR_FILENO + 1;x<1024;x++) 
-		close(x);
+	ast_close_fds_above_n(STDERR_FILENO);
 
 	/* Reset all arguments */
 	memset(argv, 0, sizeof(argv));
@@ -185,6 +173,7 @@
 			break;
 		}
 	}
+	ast_safe_fork_cleanup();
 }
 
 static int zapras_exec(struct ast_channel *chan, void *data)

Modified: team/russell/events/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/cdr/cdr_pgsql.c?view=diff&rev=114457&r1=114456&r2=114457
==============================================================================
--- team/russell/events/cdr/cdr_pgsql.c (original)
+++ team/russell/events/cdr/cdr_pgsql.c Mon Apr 21 18:05:08 2008
@@ -66,6 +66,8 @@
 	char *name;
 	char *type;
 	int len;
+	unsigned int notnull:1;
+	unsigned int hasdefault:1;
 	AST_RWLIST_ENTRY(columns) list;
 };
 
@@ -118,8 +120,8 @@
 			connected = 1;
 		} else {
 			pgerror = PQerrorMessage(conn);
-			ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s.  Calls will not be logged!\n", pghostname);
-			ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
+			ast_log(LOG_ERROR, "Unable to connect to database server %s.  Calls will not be logged!\n", pghostname);
+			ast_log(LOG_ERROR, "Reason: %s\n", pgerror);
 			PQfinish(conn);
 			conn = NULL;
 		}
@@ -138,8 +140,17 @@
 		AST_RWLIST_TRAVERSE(&psql_columns, cur, list) {
 			/* For fields not set, simply skip them */
 			ast_cdr_getvar(cdr, cur->name, &value, buf, sizeof(buf), 0, 0);
-			if (!value)
+			if (!value) {
+				if (cur->notnull && !cur->hasdefault) {
+					/* Field is NOT NULL (but no default), must include it anyway */
+					LENGTHEN_BUF1(strlen(cur->name));
+					lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name);
+					LENGTHEN_BUF2(3);
+					strcat(sql2, "'',");
+					lensql2 += 3;
+				}
 				continue;
+			}
 			
 			LENGTHEN_BUF1(strlen(cur->name));
 			lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name);
@@ -253,7 +264,7 @@
 		strcat(sql + lensql, sql2);
 		ast_verb(11, "[%s]\n", sql);
 
-		ast_debug(2, "cdr_pgsql: inserting a CDR record.\n");
+		ast_debug(2, "inserting a CDR record.\n");
 
 		/* Test to be sure we're still connected... */
 		/* If we're connected, and connection is working, good. */
@@ -261,15 +272,15 @@
 		if (PQstatus(conn) == CONNECTION_OK) {
 			connected = 1;
 		} else {

[... 16054 lines stripped ...]



More information about the asterisk-commits mailing list