diff options
author | russell <russell@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-08-15 22:14:21 +0000 |
---|---|---|
committer | russell <russell@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2006-08-15 22:14:21 +0000 |
commit | c370e90f86d16d7d8c1669316c8ee2d884e95ef0 (patch) | |
tree | 6de3e8cb7ad219a380c50b3a8f603cfa8a5990e2 /fxotune.c | |
parent | 27feab959625e70b29ef07bffe3fbf0dab4f27f4 (diff) |
Merged revisions 1315 via svnmerge from
https://origsvn.digium.com/svn/zaptel/branches/1.2
........
r1315 | russell | 2006-08-15 18:06:13 -0400 (Tue, 15 Aug 2006) | 4 lines
Ensure that fopen() is only called once for the debug output file to prevent
excessive file descriptor leakage when this function is called many times in
a loop. (issue #7203)
........
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1316 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'fxotune.c')
-rw-r--r-- | fxotune.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -86,6 +86,8 @@ struct silence_info{ static short outbuf[TEST_DURATION]; static int debug = 0; +static FILE *debugoutfile = NULL; + /** * Makes sure that the line is clear. * Right now, we do this by relying on the user to specify how long after dialing the @@ -262,7 +264,6 @@ static int maptone(int whichzap, int freq, char *dialstr, int delayuntilsilence) short inbuf[TEST_DURATION]; /* changed from BUFFER_LENGTH - this buffer is for short values, so it should be allocated using the length of the test */ FILE *outfile = NULL; - outfile = fopen("fxotune_dump.vals", "w"); if (!outfile) { fprintf(stdout, "Cannot create fxotune_dump.vals\n"); @@ -392,12 +393,9 @@ static int acim_tune2(int whichzap, int freq, char *dialstr, int delayuntilsilen struct zt_bufferinfo bi; short inbuf[TEST_DURATION]; - FILE *outfile = NULL; - - if (debug) { - outfile = fopen("fxotune.vals", "w"); - if (!outfile) { + if (debug && !debugoutfile) { + if (!(debugoutfile = fopen("fxotune.vals", "w"))) { fprintf(stdout, "Cannot create fxotune.vals\n"); return -1; } @@ -516,7 +514,7 @@ static int acim_tune2(int whichzap, int freq, char *dialstr, int delayuntilsilen echo ); - fprintf(outfile, "%s\n", result); + fprintf(debugoutfile, "%s\n", result); if (debug > 1) fprintf(stdout, "%s\n", result); } |