From: Moises Silva Date: Thu, 27 Jan 2011 22:02:04 +0000 (-0500) Subject: freetdm: ftmod_r2 - check for io dump file errors on open X-Git-Tag: v1.2-rc1~172^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1842798e95eeeed61604455ebcd5001bdf35eeb1;p=thirdparty%2Ffreeswitch.git freetdm: ftmod_r2 - check for io dump file errors on open --- diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c index 0217a5172a..d86fb43195 100644 --- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c +++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c @@ -729,16 +729,24 @@ static void dump_mf(openr2_chan_t *r2chan) snprintf(dfile, sizeof(dfile), logname ? "%s.s%dc%d.input.alaw" : "%s/s%dc%d.input.alaw", logname ? logname : r2data->logdir, ftdmchan->span_id, ftdmchan->chan_id); f = fopen(dfile, "wb"); - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO input in file %s\n", dfile); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_INPUT, f); - fclose(f); + if (f) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO input in file %s\n", dfile); + ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_INPUT, f); + fclose(f); + } else { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Could not dump IO input in file %s, error: %s", dfile, strerror(errno)); + } snprintf(dfile, sizeof(dfile), logname ? "%s.s%dc%d.output.alaw" : "%s/s%dc%d.output.alaw", logname ? logname : r2data->logdir, ftdmchan->span_id, ftdmchan->chan_id); f = fopen(dfile, "wb"); - ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in file %s\n", dfile); - ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_OUTPUT, f); - fclose(f); + if (f) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in file %s\n", dfile); + ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_OUTPUT, f); + fclose(f); + } else { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Could not dump IO output in file %s, error: %s", dfile, strerror(errno)); + } } }