[Asterisk-Dev] [PATCH] app_agi.c

Steven Critchfield critch at basesys.com
Fri Oct 17 04:02:20 MST 2003


Below is a patch we are running on our production machine.  The first
segment fixes a change that made offset recording fail by truncating all
files before we could seek.

The second segment fixes a return case where we do not properly close
the stream on the random error. 

Next on the list is to track down why we are receiving the random error.
[200 result=51 (randomerror) endpos=1868960 ]



pbx:/usr/src/asterisk# cvs diff -u apps/app_agi.c
Index: apps/app_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_agi.c,v
retrieving revision 1.12
diff -u -r1.12 app_agi.c
--- apps/app_agi.c      8 Sep 2003 16:48:06 -0000       1.12
+++ apps/app_agi.c      17 Oct 2003 11:20:55 -0000
@@ -515,7 +515,7 @@
        if (!res)
                res = ast_waitstream(chan, argv[4]);
        if (!res) {
-               fs = ast_writefile(argv[2], argv[3], NULL, O_CREAT | O_WRONLY, 0, 0644);
+               fs = ast_writefile(argv[2], argv[3], NULL, O_CREAT | O_WRONLY | (sample_offset ? O_APPEND : 0) , 0, 0644);
                if (!fs) {
                        res = -1;
                        fdprintf(agi->fd, "200 result=%d (writefile)\n", res);
@@ -589,8 +589,10 @@
                }
                fdprintf(agi->fd, "200 result=%d (timeout) endpos=%ld\n", res, sample_offset);
                ast_closestream(fs);
-       } else
+       } else {
                fdprintf(agi->fd, "200 result=%d (randomerror) endpos=%ld\n", res, sample_offset);
+               ast_closestream(fs);
+       }
 
         if (silence > 0) {
                 res = ast_set_read_format(chan, rfmt);

-- 
Steven Critchfield <critch at basesys.com>




More information about the asterisk-dev mailing list