[asterisk-commits] murf: branch murf/bug8386-1.4 r48451 - in /team/murf/bug8386-1.4: ./ apps/ bu...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Dec 13 07:34:04 MST 2006


Author: murf
Date: Wed Dec 13 08:34:03 2006
New Revision: 48451

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48451
Log:
Merged revisions 48316-48317,48323,48326,48349,48357,48362-48363,48372,48375,48377,48379,48381-48382,48391,48396,48399,48401,48404,48427,48435 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r48316 | oej | 2006-12-06 05:17:31 -0700 (Wed, 06 Dec 2006) | 2 lines

Block patch from 1.2

................
r48317 | oej | 2006-12-06 05:27:43 -0700 (Wed, 06 Dec 2006) | 2 lines

Don't send Contact on MESSAGE

................
r48323 | russell | 2006-12-06 09:15:45 -0700 (Wed, 06 Dec 2006) | 11 lines

Merged revisions 48322 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r48322 | russell | 2006-12-06 11:05:54 -0500 (Wed, 06 Dec 2006) | 3 lines

Fix the name of the rtignoreregexpire option in the sample configuration file.
(issue #8526, arkadia)

........

................
r48326 | oej | 2006-12-06 09:25:06 -0700 (Wed, 06 Dec 2006) | 2 lines

Issue #8258 - fix handling of 487 being retransmitted to Asterisk

................
r48349 | murf | 2006-12-07 08:33:32 -0700 (Thu, 07 Dec 2006) | 1 line

Here lies the fixes that killed bug 8423 -- OriginateSuccess and OriginateError incomplete channel name. May it rest in peace.
................
r48357 | russell | 2006-12-07 11:17:28 -0700 (Thu, 07 Dec 2006) | 11 lines

Merged revisions 48356 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r48356 | russell | 2006-12-07 13:14:13 -0500 (Thu, 07 Dec 2006) | 3 lines

Ensure that the file position is not incremented beyond the total number of
files available for playback.  (issue #8539, ulogic)

........

................
r48362 | russell | 2006-12-09 08:47:01 -0700 (Sat, 09 Dec 2006) | 13 lines

Blocked revisions 48361 via svnmerge

........
r48361 | russell | 2006-12-09 10:45:37 -0500 (Sat, 09 Dec 2006) | 6 lines

Use locking when accessing the registrations list.  This list is not actually
used very often, so the likelihood of there being a problem is pretty small,
but still possible.  For example, if the CLI command to list the registrations
was called at the same time that a reload was occurring and the registrations
list was getting destroyed and rebuilt, a crash could occur.

........

................
r48363 | russell | 2006-12-09 08:59:42 -0700 (Sat, 09 Dec 2006) | 8 lines

Use locking when accessing the registrations list.  This list is not actually
used very often, so the likelihood of there being a problem is pretty small,
but still possible.  For example, if the CLI command to list the registrations
was called at the same time that a reload was occurring and the registrations
list was getting destroyed and rebuilt, a crash could occur.

In passing, go ahead and convert this list to use the linked list macros.

................
r48372 | murf | 2006-12-09 20:04:18 -0700 (Sat, 09 Dec 2006) | 9 lines

Merged revisions 48371 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r48371 | murf | 2006-12-09 19:14:13 -0700 (Sat, 09 Dec 2006) | 1 line

This version applies the patch suggested by stevens in bug 7836 (make inbound channel RINGING state consistent with other channels).
........

................
r48375 | tilghman | 2006-12-10 17:47:21 -0700 (Sun, 10 Dec 2006) | 13 lines

Merged revisions 48374 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r48374 | tilghman | 2006-12-10 18:33:59 -0600 (Sun, 10 Dec 2006) | 5 lines

When doing a fork() and exec(), two problems existed (Issue 8086):
1) Ignored signals stayed ignored after the exec().
2) Signals could possibly fire between the fork() and exec(), causing Asterisk
signal handlers within the child to execute, which caused nasty race conditions.

........

................
r48377 | file | 2006-12-10 21:57:38 -0700 (Sun, 10 Dec 2006) | 2 lines

Don't access the conference structure after it has been freed.

................
r48379 | file | 2006-12-10 22:30:01 -0700 (Sun, 10 Dec 2006) | 2 lines

Use the correct API call to say a device state changed. (Yes, I'm a nub.)

................
r48381 | file | 2006-12-10 22:36:45 -0700 (Sun, 10 Dec 2006) | 2 lines

Merge in my latest RTP changes. Break out RTP and RTCP callback functions so they no longer share a common one.

................
r48382 | tilghman | 2006-12-10 22:37:09 -0700 (Sun, 10 Dec 2006) | 2 lines

STRFTIME() does not actually require an argument (issue 8540)

................
r48391 | file | 2006-12-11 14:31:23 -0700 (Mon, 11 Dec 2006) | 2 lines

Return non-existant callerid handling to that which it was before. In 1.4 and trunk callerid can be allocated but not have any contents so we have to use ast_strlen_zero before passing it to the relevant functions. (issue #8567 reported by pabelanger)

................
r48396 | mogorman | 2006-12-11 15:11:35 -0700 (Mon, 11 Dec 2006) | 12 lines

Merged revisions 48394 via svnmerge from 
https://svn.digium.com/svn/asterisk/branches/1.2

........
r48394 | mogorman | 2006-12-11 15:55:43 -0600 (Mon, 11 Dec 2006) | 4 lines

app_externalivr needs a real silence file, and additional
changes to add silence files into core instead of extra
patch provided by bug 8177 with minor additions.

........

................
r48399 | mogorman | 2006-12-11 16:02:10 -0700 (Mon, 11 Dec 2006) | 2 lines

new sounds package with 100% more silence

................
r48401 | file | 2006-12-11 21:13:48 -0700 (Mon, 11 Dec 2006) | 2 lines

Use S_OR in my previous app_voicemail. This is the way it should have been done.

................
r48404 | kpfleming | 2006-12-11 22:18:11 -0700 (Mon, 11 Dec 2006) | 2 lines

block addition of silence files... not needed here

................
r48427 | kpfleming | 2006-12-12 16:18:14 -0700 (Tue, 12 Dec 2006) | 2 lines

when making a release, we can always use wget and we can't run the configure script to find that out...

................
r48435 | murf | 2006-12-12 21:31:12 -0700 (Tue, 12 Dec 2006) | 1 line

a block to keep 48434 out of 1.4; the code works fine here
................

Modified:
    team/murf/bug8386-1.4/   (props changed)
    team/murf/bug8386-1.4/CHANGES
    team/murf/bug8386-1.4/UPGRADE.txt
    team/murf/bug8386-1.4/apps/app_externalivr.c
    team/murf/bug8386-1.4/apps/app_festival.c
    team/murf/bug8386-1.4/apps/app_ices.c
    team/murf/bug8386-1.4/apps/app_meetme.c
    team/murf/bug8386-1.4/apps/app_mp3.c
    team/murf/bug8386-1.4/apps/app_nbscat.c
    team/murf/bug8386-1.4/apps/app_voicemail.c
    team/murf/bug8386-1.4/apps/app_zapras.c
    team/murf/bug8386-1.4/build_tools/prep_tarball
    team/murf/bug8386-1.4/channels/chan_iax2.c
    team/murf/bug8386-1.4/channels/chan_sip.c
    team/murf/bug8386-1.4/channels/chan_zap.c
    team/murf/bug8386-1.4/configs/iax.conf.sample
    team/murf/bug8386-1.4/funcs/func_strings.c
    team/murf/bug8386-1.4/main/manager.c
    team/murf/bug8386-1.4/main/rtp.c
    team/murf/bug8386-1.4/res/res_agi.c
    team/murf/bug8386-1.4/res/res_musiconhold.c
    team/murf/bug8386-1.4/sounds/Makefile

Propchange: team/murf/bug8386-1.4/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Dec 13 08:34:03 2006
@@ -1,1 +1,1 @@
-/branches/1.4:1-48304
+/branches/1.4:1-48448

Modified: team/murf/bug8386-1.4/CHANGES
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/CHANGES?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/CHANGES (original)
+++ team/murf/bug8386-1.4/CHANGES Wed Dec 13 08:34:03 2006
@@ -337,3 +337,5 @@
          2. chan_modem_* and related modules are gone because the kernel support for those interfaces is old, buggy and unsupported
     * New Utils:
          1. aelparse -- compile .ael files outside of asterisk
+    * New manager events:
+         1. OriginateResponse event comes to replace OriginateSuccess and OriginateFailure

Modified: team/murf/bug8386-1.4/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/UPGRADE.txt?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/UPGRADE.txt (original)
+++ team/murf/bug8386-1.4/UPGRADE.txt Wed Dec 13 08:34:03 2006
@@ -247,6 +247,10 @@
   also been deprecated in favor of the already existing MeetmeTalking event
   with a "Status" of "on" or "off" added.
 
+* OriginateFailure and OriginateSuccess events were replaced by event
+  OriginateResponse with a header named "Response" to indicate success or
+  failure
+
 Variables:
 
 * The builtin variables ${CALLERID}, ${CALLERIDNAME}, ${CALLERIDNUM},

Modified: team/murf/bug8386-1.4/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/apps/app_externalivr.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/apps/app_externalivr.c (original)
+++ team/murf/bug8386-1.4/apps/app_externalivr.c Wed Dec 13 08:34:03 2006
@@ -40,6 +40,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
+#include <signal.h>
 
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
@@ -152,7 +153,7 @@
 		if (state->current) {
 			file_to_stream = state->current->filename;
 		} else {
-			file_to_stream = "silence-10";
+			file_to_stream = "silence/10";
 			u->playing_silence = 1;
 		}
 
@@ -261,9 +262,13 @@
 		.finishlist = AST_LIST_HEAD_INIT_VALUE,
 	};
 	struct ivr_localuser *u = &foo;
+	sigset_t fullset, oldset;
 
 	lu = ast_module_user_add(chan);
-	
+
+	sigfillset(&fullset);
+	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
 	u->abort_current_sound = 0;
 	u->chan = chan;
 	
@@ -311,6 +316,9 @@
 	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);
@@ -334,6 +342,8 @@
 		int ready_fd;
 		int waitfds[2] = { child_errors_fd, child_commands_fd };
 		struct ast_channel *rchan;
+
+		pthread_sigmask(SIG_SETMASK, &oldset, NULL);
 
 		close(child_stdin[0]);
 		child_stdin[0] = 0;

Modified: team/murf/bug8386-1.4/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/apps/app_festival.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/apps/app_festival.c (original)
+++ team/murf/bug8386-1.4/apps/app_festival.c Wed Dec 13 08:34:03 2006
@@ -130,19 +130,26 @@
 #ifdef __PPC__ 
 	char c;
 #endif
+	sigset_t fullset, oldset;
+
+	sigfillset(&fullset);
+	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
 
         res = fork();
         if (res < 0)
                 ast_log(LOG_WARNING, "Fork failed\n");
-        if (res)
+        if (res) {
+		pthread_sigmask(SIG_SETMASK, &oldset, NULL);
                 return res;
+	}
         for (x=0;x<256;x++) {
                 if (x != fd)
                         close(x);
         }
 	if (ast_opt_high_priority)
 		ast_set_priority(0);
-
+	signal(SIGPIPE, SIG_DFL);
+	pthread_sigmask(SIG_UNBLOCK, &fullset, NULL);
 /*IAS */
 #ifdef __PPC__  
 	for( x=0; x<length; x+=2)

Modified: team/murf/bug8386-1.4/apps/app_ices.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/apps/app_ices.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/apps/app_ices.c (original)
+++ team/murf/bug8386-1.4/apps/app_ices.c Wed Dec 13 08:34:03 2006
@@ -65,15 +65,27 @@
 {
 	int res;
 	int x;
+	sigset_t fullset, oldset;
+
+	sigfillset(&fullset);
+	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
 	res = fork();
 	if (res < 0) 
 		ast_log(LOG_WARNING, "Fork failed\n");
-	if (res)
+	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<256;x++) {
+	for (x=STDERR_FILENO + 1;x<1024;x++) {
 		if ((x != STDIN_FILENO) && (x != STDOUT_FILENO))
 			close(x);
 	}
@@ -84,7 +96,7 @@
 	/* As a last-ditch effort, try to use PATH */
 	execlp("ices", "ices", filename, (char *)NULL);
 	ast_log(LOG_WARNING, "Execute of ices failed\n");
-	return -1;
+	_exit(0);
 }
 
 static int ices_exec(struct ast_channel *chan, void *data)

Modified: team/murf/bug8386-1.4/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/apps/app_meetme.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/apps/app_meetme.c (original)
+++ team/murf/bug8386-1.4/apps/app_meetme.c Wed Dec 13 08:34:03 2006
@@ -1927,6 +1927,13 @@
 			conf->markedusers--;
 		/* Remove ourselves from the list */
 		AST_LIST_REMOVE(&conf->userlist, user, list);
+
+		/* Change any states */
+		if (!conf->users)
+			ast_device_state_changed("meetme:%s", conf->confno);
+		if (confflags & (CONFFLAG_SLA_STATION|CONFFLAG_SLA_TRUNK))
+			ast_device_state_changed("SLA:%s", conf->confno + 4);
+
 		if (AST_LIST_EMPTY(&conf->userlist)) {
 			/* close this one when no more users and no references*/
 			if (!conf->refcount)
@@ -1935,12 +1942,6 @@
 		/* Return the number of seconds the user was in the conf */
 		snprintf(meetmesecs, sizeof(meetmesecs), "%d", (int) (time(NULL) - user->jointime));
 		pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs);
-
-		/* This device changed state now */
-		if (!conf->users)	/* If there are no more members */
-			ast_device_state_changed("meetme:%s", conf->confno);
-		if (confflags & (CONFFLAG_SLA_STATION|CONFFLAG_SLA_TRUNK))
-			ast_device_state_changed("SLA:%s", conf->confno + 4);
 	}
 	free(user);
 	AST_LIST_UNLOCK(&confs);

Modified: team/murf/bug8386-1.4/apps/app_mp3.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/apps/app_mp3.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/apps/app_mp3.c (original)
+++ team/murf/bug8386-1.4/apps/app_mp3.c Wed Dec 13 08:34:03 2006
@@ -64,15 +64,25 @@
 {
 	int res;
 	int x;
+	sigset_t fullset, oldset;
+
+	sigfillset(&fullset);
+	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
 	res = fork();
 	if (res < 0) 
 		ast_log(LOG_WARNING, "Fork failed\n");
-	if (res)
+	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=0;x<256;x++) {
+	for (x=STDERR_FILENO + 1;x<256;x++) {
 		if (x != STDOUT_FILENO)
 			close(x);
 	}
@@ -94,7 +104,7 @@
 	    execlp("mpg123", "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
 	}
 	ast_log(LOG_WARNING, "Execute of mpg123 failed\n");
-	return -1;
+	_exit(0);
 }
 
 static int timed_read(int fd, void *data, int datalen, int timeout)

Modified: team/murf/bug8386-1.4/apps/app_nbscat.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/apps/app_nbscat.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/apps/app_nbscat.c (original)
+++ team/murf/bug8386-1.4/apps/app_nbscat.c Wed Dec 13 08:34:03 2006
@@ -68,16 +68,26 @@
 {
 	int res;
 	int x;
+	sigset_t fullset, oldset;
+
+	sigfillset(&fullset);
+	pthread_sigmask(SIG_BLOCK, &fullset, &oldset);
+
 	res = fork();
 	if (res < 0) 
 		ast_log(LOG_WARNING, "Fork failed\n");
-	if (res)
+	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=0;x<256;x++) {
+	for (x = STDERR_FILENO + 1; x < 1024; x++) {
 		if (x != STDOUT_FILENO)
 			close(x);
 	}
@@ -85,7 +95,7 @@
 	execl(NBSCAT, "nbscat8k", "-d", (char *)NULL);
 	execl(LOCAL_NBSCAT, "nbscat8k", "-d", (char *)NULL);
 	ast_log(LOG_WARNING, "Execute of nbscat8k failed\n");
-	return -1;
+	_exit(0);
 }
 
 static int timed_read(int fd, void *data, int datalen)

Modified: team/murf/bug8386-1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/apps/app_voicemail.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/apps/app_voicemail.c (original)
+++ team/murf/bug8386-1.4/apps/app_voicemail.c Wed Dec 13 08:34:03 2006
@@ -2407,7 +2407,7 @@
 		ast_log(LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn);
 		return -1;
 	} else {
-		make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, chan->cid.cid_num, chan->cid.cid_name, fn, fmt, duration, 1, chan, NULL, 1);
+		make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), fn, fmt, duration, 1, chan, NULL, 1);
 		/* read mail file to memory */		
 		len = ftell(p);
 		rewind(p);
@@ -2641,7 +2641,7 @@
 		ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context);
 	}
 	ast_unlock_path(todir);
-	notify_new_message(chan, recip, recipmsgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
+	notify_new_message(chan, recip, recipmsgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL));
 	
 	return 0;
 }
@@ -3058,7 +3058,7 @@
 				chan->exten,
 				chan->priority,
 				chan->name,
-				ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"),
+				ast_callerid_merge(callerid, sizeof(callerid), S_OR(chan->cid.cid_name, NULL), S_OR(chan->cid.cid_num, NULL), "Unknown"),
 				date, (long)time(NULL),
 				category ? category : ""); 
 		} else
@@ -3124,7 +3124,7 @@
 #endif
 					if (ast_fileexists(fn, NULL, NULL)) {
 						STORE(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, fmt, duration, vms);
-						notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
+						notify_new_message(chan, vmu, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL));
 						DISPOSE(dir, msgnum);
 					}
 				}
@@ -4117,7 +4117,7 @@
 				int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
 				attach_user_voicemail = ast_test_flag(vmtmp, VM_ATTACH);
 				/* NULL category for IMAP storage */
-				sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, vms->fn, fmt, duration, attach_user_voicemail, chan, NULL);
+				sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vms->fn, fmt, duration, attach_user_voicemail, chan, NULL);
 #else
 				copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt);
 #endif

Modified: team/murf/bug8386-1.4/apps/app_zapras.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/apps/app_zapras.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/apps/app_zapras.c (original)
+++ team/murf/bug8386-1.4/apps/app_zapras.c Wed Dec 13 08:34:03 2006
@@ -82,11 +82,23 @@
 	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();
-	if (pid)
+	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);
@@ -98,10 +110,6 @@
 	/* Close other file descriptors */
 	for (x=STDERR_FILENO + 1;x<1024;x++) 
 		close(x);
-
-	/* Restore original signal handlers */
-	for (x=0;x<NSIG;x++)
-		signal(x, SIG_DFL);
 
 	/* Reset all arguments */
 	memset(argv, 0, sizeof(argv));

Modified: team/murf/bug8386-1.4/build_tools/prep_tarball
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/build_tools/prep_tarball?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/build_tools/prep_tarball (original)
+++ team/murf/bug8386-1.4/build_tools/prep_tarball Wed Dec 13 08:34:03 2006
@@ -5,4 +5,4 @@
 #
 # It will be executed from the top-level directory of the project.
 
-make -C sounds all MENUSELECT_CORE_SOUNDS=CORE-SOUNDS-EN-GSM MENUSELECT_MOH=MOH-FREEPLAY-WAV
+make -C sounds all MENUSELECT_CORE_SOUNDS=CORE-SOUNDS-EN-GSM MENUSELECT_MOH=MOH-FREEPLAY-WAV WGET=wget

Modified: team/murf/bug8386-1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/channels/chan_iax2.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/channels/chan_iax2.c (original)
+++ team/murf/bug8386-1.4/channels/chan_iax2.c Wed Dec 13 08:34:03 2006
@@ -426,11 +426,11 @@
 	int messages;				/*!< Message count, low 8 bits = new, high 8 bits = old */
 	int callno;				/*!< Associated call number if applicable */
 	struct sockaddr_in us;			/*!< Who the server thinks we are */
-	struct iax2_registry *next;
 	struct ast_dnsmgr_entry *dnsmgr;	/*!< DNS refresh manager */
+	AST_LIST_ENTRY(iax2_registry) entry;
 };
 
-static struct iax2_registry *registrations;
+static AST_LIST_HEAD_STATIC(registrations, iax2_registry);
 
 /* Don't retry more frequently than every 10 ms, or less frequently than every 5 seconds */
 #define MIN_RETRY_TIME		100
@@ -4242,9 +4242,9 @@
 	char perceived[80];
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
-	AST_LIST_LOCK(&peers);
 	ast_cli(fd, FORMAT2, "Host", "dnsmgr", "Username", "Perceived", "Refresh", "State");
-	for (reg = registrations;reg;reg = reg->next) {
+	AST_LIST_LOCK(&registrations);
+	AST_LIST_TRAVERSE(&registrations, reg, entry) {
 		snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
 		if (reg->us.sin_addr.s_addr) 
 			snprintf(perceived, sizeof(perceived), "%s:%d", ast_inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
@@ -4254,7 +4254,7 @@
 					(reg->dnsmgr) ? "Y" : "N", 
 					reg->username, perceived, reg->refresh, regstate2str(reg->regstate));
 	}
-	AST_LIST_UNLOCK(&peers);
+	AST_LIST_UNLOCK(&registrations);
 	return RESULT_SUCCESS;
 #undef FORMAT
 #undef FORMAT2
@@ -5413,9 +5413,9 @@
 	reg->refresh = IAX_DEFAULT_REG_EXPIRE;
 	reg->addr.sin_family = AF_INET;
 	reg->addr.sin_port = porta ? htons(atoi(porta)) : htons(IAX_DEFAULT_PORTNO);
-	reg->next = registrations;
-	reg->callno = 0;
-	registrations = reg;
+	AST_LIST_LOCK(&registrations);
+	AST_LIST_INSERT_HEAD(&registrations, reg, entry);
+	AST_LIST_UNLOCK(&registrations);
 	
 	return 0;
 }
@@ -8622,35 +8622,32 @@
 
 static void delete_users(void)
 {
-	struct iax2_user *user = NULL;
-	struct iax2_peer *peer = NULL;
-	struct iax2_registry *reg, *regl;
+	struct iax2_user *user;
+	struct iax2_peer *peer;
+	struct iax2_registry *reg;
 
 	AST_LIST_LOCK(&users);
 	AST_LIST_TRAVERSE(&users, user, entry)
 		ast_set_flag(user, IAX_DELME);
 	AST_LIST_UNLOCK(&users);
 
-	for (reg = registrations;reg;) {
-		regl = reg;
-		reg = reg->next;
-		if (regl->expire > -1) {
-			ast_sched_del(sched, regl->expire);
-		}
-		if (regl->callno) {
-			/* XXX Is this a potential lock?  I don't think so, but you never know */
-			ast_mutex_lock(&iaxsl[regl->callno]);
-			if (iaxs[regl->callno]) {
-				iaxs[regl->callno]->reg = NULL;
-				iax2_destroy(regl->callno);
+	AST_LIST_LOCK(&registrations);
+	while ((reg = AST_LIST_REMOVE_HEAD(&registrations, entry))) {
+		if (reg->expire > -1)
+			ast_sched_del(sched, reg->expire);
+		if (reg->callno) {
+			ast_mutex_lock(&iaxsl[reg->callno]);
+			if (iaxs[reg->callno]) {
+				iaxs[reg->callno]->reg = NULL;
+				iax2_destroy(reg->callno);
 			}
-			ast_mutex_unlock(&iaxsl[regl->callno]);
-		}
-		if (regl->dnsmgr)
-			ast_dnsmgr_release(regl->dnsmgr);
-		free(regl);
-	}
-	registrations = NULL;
+			ast_mutex_unlock(&iaxsl[reg->callno]);
+		}
+		if (reg->dnsmgr)
+			ast_dnsmgr_release(reg->dnsmgr);
+		free(reg);
+	}
+	AST_LIST_UNLOCK(&registrations);
 
 	AST_LIST_LOCK(&peers);
 	AST_LIST_TRAVERSE(&peers, peer, entry)
@@ -9092,7 +9089,7 @@
 {
 	char *config = "iax.conf";
 	struct iax2_registry *reg;
-	struct iax2_peer *peer = NULL;
+	struct iax2_peer *peer;
 
 	strcpy(accountcode, "");
 	strcpy(language, "");
@@ -9105,11 +9102,13 @@
 	ast_clear_flag((&globalflags), IAX_USEJITTERBUF);	
 	ast_clear_flag((&globalflags), IAX_FORCEJITTERBUF);	
 	delete_users();
-	set_config(config,1);
+	set_config(config, 1);
 	prune_peers();
 	prune_users();
-	for (reg = registrations; reg; reg = reg->next)
+	AST_LIST_LOCK(&registrations);
+	AST_LIST_TRAVERSE(&registrations, reg, entry)
 		iax2_do_register(reg);
+	AST_LIST_UNLOCK(&registrations);
 	/* Qualify hosts, too */
 	AST_LIST_LOCK(&peers);
 	AST_LIST_TRAVERSE(&peers, peer, entry)
@@ -10024,8 +10023,11 @@
 		ast_netsock_release(netsock);
 	}
 
-	for (reg = registrations; reg; reg = reg->next)
+	AST_LIST_LOCK(&registrations);
+	AST_LIST_TRAVERSE(&registrations, reg, entry)
 		iax2_do_register(reg);
+	AST_LIST_UNLOCK(&registrations);	
+
 	AST_LIST_LOCK(&peers);
 	AST_LIST_TRAVERSE(&peers, peer, entry) {
 		if (peer->sockfd < 0)

Modified: team/murf/bug8386-1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/channels/chan_sip.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/channels/chan_sip.c (original)
+++ team/murf/bug8386-1.4/channels/chan_sip.c Wed Dec 13 08:34:03 2006
@@ -5629,9 +5629,10 @@
 		add_header(req, "From", ot);
 		add_header(req, "To", of);
 	}
-	/* Do not add Contact for BYE and Cancel requests */
-	if (sipmethod != SIP_BYE && sipmethod != SIP_CANCEL)
+	/* Do not add Contact for MESSAGE, BYE and Cancel requests */
+	if (sipmethod != SIP_BYE && sipmethod != SIP_CANCEL && sipmethod != SIP_MESSAGE)
 		add_header(req, "Contact", p->our_contact);
+
 	copy_header(req, orig, "Call-ID");
 	add_header(req, "CSeq", tmp);
 
@@ -11747,7 +11748,16 @@
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 		break;
-
+	case 487: /* Cancelled transaction */
+		/* We have sent CANCEL on an outbound INVITE 
+			This transaction is already scheduled to be killed by sip_hangup().
+		*/
+		transmit_request(p, SIP_ACK, seqno, 0, 0);
+		if (p->owner && !ast_test_flag(req, SIP_PKT_IGNORE))
+			ast_queue_hangup(p->owner);
+		else if (!ast_test_flag(req, SIP_PKT_IGNORE))
+			update_call_counter(p, DEC_CALL_LIMIT);
+		break;
 	case 491: /* Pending */
 		/* we really should have to wait a while, then retransmit */
 			/* We should support the retry-after at some point */
@@ -11759,6 +11769,7 @@
 		break;
 
 	case 501: /* Not implemented */
+		transmit_request(p, SIP_ACK, seqno, 0, 0);
 		if (p->owner)
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
 		break;
@@ -12165,6 +12176,10 @@
 				/* Guessing that this is not an important request */
 			}
 			break;
+		case 487:
+			if (sipmethod == SIP_INVITE)
+				handle_response_invite(p, resp, rest, req, seqno);
+			break;
 		case 491: /* Pending */
 			if (sipmethod == SIP_INVITE)
 				handle_response_invite(p, resp, rest, req, seqno);
@@ -12209,12 +12224,6 @@
 				case 603: /* Decline */
 					if (p->owner)
 						ast_queue_control(p->owner, AST_CONTROL_BUSY);
-					break;
-				case 487:	/* Response on INVITE that has been CANCELled */
-					/* channel now destroyed - dec the inUse counter */
-					if (owner)
-						ast_queue_hangup(p->owner);
-					update_call_counter(p, DEC_CALL_LIMIT);
 					break;
 				case 482: /*
 					\note SIP is incapable of performing a hairpin call, which

Modified: team/murf/bug8386-1.4/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/channels/chan_zap.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/channels/chan_zap.c (original)
+++ team/murf/bug8386-1.4/channels/chan_zap.c Wed Dec 13 08:34:03 2006
@@ -3508,8 +3508,11 @@
 		   stop if now if appropriate */
 		if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner))
 			ast_queue_control(p->subs[SUB_THREEWAY].owner, AST_CONTROL_UNHOLD);
-		if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RINGING) {
+		if (p->subs[SUB_REAL].owner->_state == AST_STATE_RINGING) {
 			ast_indicate(ast_bridged_channel(p->subs[SUB_REAL].owner), AST_CONTROL_RINGING);
+		}
+		if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RING) {
+			tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, ZT_TONE_RINGTONE);
 		}
 		if (p->subs[SUB_REAL].owner->cdr) {
 			/* Move CDR from second channel to current one */
@@ -3533,8 +3536,12 @@
 		unalloc_sub(p, SUB_THREEWAY);
 	} else if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
 		ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
-		if (p->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)
+		if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RINGING) {
 			ast_indicate(ast_bridged_channel(p->subs[SUB_THREEWAY].owner), AST_CONTROL_RINGING);
+		}
+		if (p->subs[SUB_REAL].owner->_state == AST_STATE_RING) {
+			tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE);
+		}
 		if (p->subs[SUB_THREEWAY].owner->cdr) {
 			/* Move CDR from second channel to current one */
 			p->subs[SUB_REAL].owner->cdr = 

Modified: team/murf/bug8386-1.4/configs/iax.conf.sample
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/configs/iax.conf.sample?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/configs/iax.conf.sample (original)
+++ team/murf/bug8386-1.4/configs/iax.conf.sample Wed Dec 13 08:34:03 2006
@@ -258,7 +258,7 @@
 			; If set to an integer, friends expire within this number of
 			; seconds instead of the registration interval.
 
-;rtignoreexpire=yes	; When reading a peer from Realtime, if the peer's registration
+;rtignoreregexpire=yes	; When reading a peer from Realtime, if the peer's registration
 			; has expired based on its registration interval, used the stored
 			; address information regardless. (yes|no)
 

Modified: team/murf/bug8386-1.4/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/funcs/func_strings.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/funcs/func_strings.c (original)
+++ team/murf/bug8386-1.4/funcs/func_strings.c Wed Dec 13 08:34:03 2006
@@ -421,12 +421,6 @@
 
 	buf[0] = '\0';
 
-	if (ast_strlen_zero(parse)) {
-		ast_log(LOG_ERROR,
-				"Asterisk function STRFTIME() requires an argument.\n");
-		return -1;
-	}
-
 	AST_STANDARD_APP_ARGS(args, parse);
 
 	ast_get_time_t(args.epoch, &epochi, time(NULL), NULL);

Modified: team/murf/bug8386-1.4/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/main/manager.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/main/manager.c (original)
+++ team/murf/bug8386-1.4/main/manager.c Wed Dec 13 08:34:03 2006
@@ -1567,6 +1567,7 @@
 	int res;
 	int reason = 0;
 	struct ast_channel *chan = NULL;
+	char requested_channel[AST_CHANNEL_NAME];
 
 	if (!ast_strlen_zero(in->app)) {
 		res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1, 
@@ -1578,13 +1579,15 @@
 			S_OR(in->cid_num, NULL), 
 			S_OR(in->cid_name, NULL),
 			in->vars, in->account, &chan);
-	}   
-	
+	}
+
+	if (!chan)
+		snprintf(requested_channel, AST_CHANNEL_NAME, "%s/%s", in->tech, in->data);	
 	/* Tell the manager what happened with the channel */
-	manager_event(EVENT_FLAG_CALL,
-		res ? "OriginateFailure" : "OriginateSuccess",
+	manager_event(EVENT_FLAG_CALL, "OriginateResponse",
 		"%s"
-		"Channel: %s/%s\r\n"
+		"Response: %s\r\n"
+		"Channel: %s\r\n"
 		"Context: %s\r\n"
 		"Exten: %s\r\n"
 		"Reason: %d\r\n"
@@ -1592,7 +1595,7 @@
 		"CallerID: %s\r\n"		/* This parameter is deprecated and will be removed post-1.4 */
 		"CallerIDNum: %s\r\n"
 		"CallerIDName: %s\r\n",
-		in->idtext, in->tech, in->data, in->context, in->exten, reason, 
+		in->idtext, res ? "Failure" : "Success", chan ? chan->name : requested_channel, in->context, in->exten, reason, 
 		chan ? chan->uniqueid : "<null>",
 		S_OR(in->cid_num, "<unknown>"),
 		S_OR(in->cid_num, "<unknown>"),

Modified: team/murf/bug8386-1.4/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/main/rtp.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/main/rtp.c (original)
+++ team/murf/bug8386-1.4/main/rtp.c Wed Dec 13 08:34:03 2006
@@ -2840,7 +2840,7 @@
 	return AST_BRIDGE_FAILED;
 }
 
-/*! \brief P2P RTP/RTCP Callback */
+/*! \brief P2P RTP Callback */
 static int p2p_rtp_callback(int *id, int fd, short events, void *cbdata)
 {
 	int res = 0, hdrlen = 12;
@@ -2848,7 +2848,6 @@
 	socklen_t len;
 	unsigned int *header;
 	struct ast_rtp *rtp = cbdata;
-	int is_rtp = 0, is_rtcp = 0;
 
 	if (!rtp)
 		return 1;
@@ -2859,42 +2858,54 @@
 
 	header = (unsigned int *)(rtp->rawdata + AST_FRIENDLY_OFFSET);
 
-	/* Determine what this file descriptor is for */
-	if (rtp->s == fd)
-		is_rtp = 1;
-	else if (rtp->rtcp && rtp->rtcp->s == fd)
-		is_rtcp = 1;
-
 	/* If NAT support is turned on, then see if we need to change their address */
-	if (rtp->nat) {
-		/* If this is for RTP, check that - if it's for RTCP, check that */
-		if (is_rtp) {
-			if ((rtp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
-			    (rtp->them.sin_port != sin.sin_port)) {
-				rtp->them = sin;
-				rtp->rxseqno = 0;
-				ast_set_flag(rtp, FLAG_NAT_ACTIVE);
-				if (option_debug || rtpdebug)
-					ast_log(LOG_DEBUG, "P2P RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
-			}
-		} else if (is_rtcp) {
-			if ((rtp->rtcp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
-			    (rtp->rtcp->them.sin_port != sin.sin_port)) {
-				rtp->rtcp->them = sin;
-				if (option_debug || rtpdebug)
-					ast_log(LOG_DEBUG, "P2P RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
-			}
-		}
-	}
-
-	/* If this came from the RTP stream, write out via RTP - if it's RTCP, write out via RTCP */
-	if (ast_rtp_get_bridged(rtp)) {
-		if (is_rtp)
-			bridge_p2p_rtp_write(rtp, header, res, hdrlen);
-		else if (is_rtcp)
-			bridge_p2p_rtcp_write(rtp, header, res);
-	}
-
+	if ((rtp->nat) && 
+	    ((rtp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
+	     (rtp->them.sin_port != sin.sin_port))) {
+		rtp->them = sin;
+		rtp->rxseqno = 0;
+		ast_set_flag(rtp, FLAG_NAT_ACTIVE);
+		if (option_debug || rtpdebug)
+			ast_log(LOG_DEBUG, "P2P RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
+	}
+
+	/* Write directly out to other RTP stream if bridged */
+	if (ast_rtp_get_bridged(rtp))
+		bridge_p2p_rtp_write(rtp, header, res, hdrlen);
+
+	return 1;
+}
+
+/*! \brief P2P RTCP Callback */
+static int p2p_rtcp_callback(int *id, int fd, short events, void *cbdata)
+{
+	int res = 0;
+	struct sockaddr_in sin;
+	socklen_t len;
+	unsigned int *header;
+	struct ast_rtp *rtp = cbdata;
+	struct ast_rtcp *rtcp = NULL;
+
+	if (!rtp || !(rtcp = rtp->rtcp))
+		return 1;
+
+	len = sizeof(sin);
+	if ((res = recvfrom(fd, rtp->rawdata + AST_FRIENDLY_OFFSET, sizeof(rtp->rawdata) - AST_FRIENDLY_OFFSET, 0, (struct sockaddr *)&sin, &len)) < 0)
+		return 1;
+
+	header = (unsigned int *)(rtp->rawdata + AST_FRIENDLY_OFFSET);
+	
+	if ((rtp->nat) &&
+	    ((rtcp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
+	     (rtcp->them.sin_port != sin.sin_port))) {
+		rtcp->them = sin;
+		if (option_debug || rtpdebug)
+			ast_log(LOG_DEBUG, "P2P RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtcp->them.sin_addr), ntohs(rtcp->them.sin_port));
+	}
+	
+	if (ast_rtp_get_bridged(rtp))
+		bridge_p2p_rtcp_write(rtp, header, res);
+	
 	return 1;
 }
 
@@ -2920,7 +2931,7 @@
 	/* Now, fire up callback mode */
 	iod[0] = ast_io_add(rtp->io, fds[0], p2p_rtp_callback, AST_IO_IN, rtp);
 	if (fds[1] >= 0)
-		iod[1] = ast_io_add(rtp->io, fds[1], p2p_rtp_callback, AST_IO_IN, rtp);
+		iod[1] = ast_io_add(rtp->io, fds[1], p2p_rtcp_callback, AST_IO_IN, rtp);
 
 	return 1;
 }
@@ -2929,17 +2940,22 @@
 static int p2p_callback_disable(struct ast_channel *chan, struct ast_rtp *rtp, int *fds, int **iod)
 {
 	ast_channel_lock(chan);
+
 	/* Remove the callback from the IO context */
 	ast_io_remove(rtp->io, iod[0]);
+
 	if (iod[1])
 		ast_io_remove(rtp->io, iod[1]);
+
 	/* Restore file descriptors */
 	chan->fds[0] = fds[0];
 	chan->fds[1] = fds[1];
 	ast_channel_unlock(chan);
+
 	/* Restore callback mode if previously used */
 	if (ast_test_flag(rtp, FLAG_CALLBACK_MODE))
 	    rtp->ioid = ast_io_add(rtp->io, rtp->s, rtpread, AST_IO_IN, rtp);
+
 	return 0;
 }
 

Modified: team/murf/bug8386-1.4/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8386-1.4/res/res_agi.c?view=diff&rev=48451&r1=48450&r2=48451
==============================================================================
--- team/murf/bug8386-1.4/res/res_agi.c (original)
+++ team/murf/bug8386-1.4/res/res_agi.c Wed Dec 13 08:34:03 2006
@@ -240,7 +240,7 @@
 	int audio[2];
 	int x;
 	int res;
-	sigset_t signal_set;
+	sigset_t signal_set, old_set;
 	
 	if (!strncasecmp(script, "agi://", 6))
 		return launch_netscript(script, argv, fds, efd, opid);
@@ -282,11 +282,14 @@
 			return AGI_RESULT_FAILURE;
 		}
 	}
-	ast_replace_sigchld();
+
+	/* Block SIGHUP during the fork - prevents a race */
+	sigfillset(&signal_set);
+	pthread_sigmask(SIG_BLOCK, &signal_set, &old_set);
 	pid = fork();
 	if (pid < 0) {
 		ast_log(LOG_WARNING, "Failed to fork(): %s\n", strerror(errno));
-		ast_unreplace_sigchld();
+		pthread_sigmask(SIG_SETMASK, &old_set, NULL);
 		return AGI_RESULT_FAILURE;
 	}
 	if (!pid) {
@@ -314,9 +317,18 @@
 		} else {
 			close(STDERR_FILENO + 1);
 		}
-		
+
+		/* Before we unblock our signals, return our trapped signals back to the defaults */
+		signal(SIGHUP, SIG_DFL);
+		signal(SIGCHLD, SIG_DFL);
+		signal(SIGINT, SIG_DFL);
+		signal(SIGURG, SIG_DFL);
+		signal(SIGTERM, SIG_DFL);
+		signal(SIGPIPE, SIG_DFL);
+		signal(SIGXFSZ, SIG_DFL);
+
 		/* unblock important signal handlers */
-		if (sigfillset(&signal_set) || pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL)) {
+		if (pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL)) {
 			ast_log(LOG_WARNING, "unable to unblock signals for AGI script: %s\n", strerror(errno));
 			_exit(1);
 		}
@@ -332,6 +344,7 @@
 		fflush(stdout);
 		_exit(1);
 	}
+	pthread_sigmask(SIG_SETMASK, &old_set, NULL);
 	if (option_verbose > 2) 
 		ast_verbose(VERBOSE_PREFIX_3 "Launched AGI Script %s\n", script);
 	fds[0] = toast[0];
@@ -348,7 +361,6 @@
 
 	*opid = pid;
 	return AGI_RESULT_SUCCESS;
-		
 }
 
 static void setup_env(struct ast_channel *chan, char *request, int fd, int enhanced)


[... 68 lines stripped ...]


More information about the asterisk-commits mailing list