[asterisk-commits] tilghman: branch 1.6.2 r284280 - /branches/1.6.2/apps/app_festival.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 30 17:27:14 CDT 2010


Author: tilghman
Date: Mon Aug 30 17:27:06 2010
New Revision: 284280

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=284280
Log:
Fix 3 coding errors:
  1) After we close FD, we should not be trying to write to it.
  2) Call _exit(0), not exit(0), to avoid running shutdown routines in a child.
  3) Use endian, not processor, detection to ensure bytes are written in the correct order.

(closes issue #15706)
 Reported by: modelnine
 Patches: 
       asterisk-1.6.1.1-festival-debug.patch uploaded by modelnine (license 865)
 Tested by: gmartinez

Modified:
    branches/1.6.2/apps/app_festival.c

Modified: branches/1.6.2/apps/app_festival.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/apps/app_festival.c?view=diff&rev=284280&r1=284279&r2=284280
==============================================================================
--- branches/1.6.2/apps/app_festival.c (original)
+++ branches/1.6.2/apps/app_festival.c Mon Aug 30 17:27:06 2010
@@ -49,6 +49,7 @@
 #include "asterisk/utils.h"
 #include "asterisk/lock.h"
 #include "asterisk/app.h"
+#include "asterisk/endian.h"
 
 #define FESTIVAL_CONFIG "festival.conf"
 #define MAXLEN 180
@@ -127,7 +128,7 @@
 static int send_waveform_to_fd(char *waveform, int length, int fd)
 {
 	int res;
-#ifdef __PPC__ 
+#if __BYTE_ORDER == __BIG_ENDIAN
 	int x;
 	char c;
 #endif
@@ -142,20 +143,20 @@
 	ast_close_fds_above_n(0);
 	if (ast_opt_high_priority)
 		ast_set_priority(0);
-#ifdef __PPC__  
+#if __BYTE_ORDER == __BIG_ENDIAN
 	for (x = 0; x < length; x += 2) {
 		c = *(waveform + x + 1);
 		*(waveform + x + 1) = *(waveform + x);
 		*(waveform + x) = c;
 	}
 #endif
-	
-	if (write(fd, waveform, length) < 0) {
-		ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+
+	if (write(0, waveform, length) < 0) {
+		/* Cannot log -- all FDs are already closed */
 	}
 
 	close(fd);
-	exit(0);
+	_exit(0);
 }
 
 static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, int length, char *intkeys)




More information about the asterisk-commits mailing list