From 3d089f0075ef70bf9206334c3d4c5bb27fc804c5 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Thu, 8 Apr 2010 20:49:56 +0200 Subject: [PATCH] FSMOD-35: mod_tts_commandline core dump, temp file problem. flush can be called several times --- .../mod_tts_commandline/mod_tts_commandline.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c b/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c index f86b9d5156..6b261f1d96 100644 --- a/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c +++ b/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c @@ -186,10 +186,14 @@ static void tts_commandline_speech_flush_tts(switch_speech_handle_t *sh) { tts_commandline_t *info = (tts_commandline_t *) sh->private_info; assert(info != NULL); - - switch_core_file_close(info->fh); - if (unlink(info->file) != 0) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Sound file [%s] delete failed\n", info->file); + + if (info->fh != NULL && info->fh->file_interface != NULL) { + switch_core_file_close(info->fh); + } + if (switch_file_exists(info->file, NULL) == SWITCH_STATUS_SUCCESS) { + if (unlink(info->file) != 0) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Sound file [%s] delete failed\n", info->file); + } } }