]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: open all media dumps as binary. Fixes Windows corrupted cores.
authorMoises Silva <moy@sangoma.com>
Tue, 14 Dec 2010 21:55:40 +0000 (16:55 -0500)
committerMoises Silva <moy@sangoma.com>
Tue, 14 Dec 2010 21:55:40 +0000 (16:55 -0500)
libs/freetdm/src/ftdm_io.c
libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c
libs/freetdm/src/include/ftdm_declare.h

index e13d0196b8b10075fa6077edcde11ce2f743e0f5..2fa795344ac99606a0c1d6ef5661e0639208c0e2 100644 (file)
@@ -2715,7 +2715,8 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_co
                                close(ftdmchan->fds[FTDM_READ_TRACE_INDEX]);
                                ftdmchan->fds[FTDM_READ_TRACE_INDEX] = -1;
                        }
-                       if ((ftdmchan->fds[FTDM_READ_TRACE_INDEX] = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
+                       if ((ftdmchan->fds[FTDM_READ_TRACE_INDEX] = open(path, O_WRONLY | O_CREAT | O_TRUNC 
+                                                       | FTDM_O_BINARY, S_IRUSR | S_IWUSR)) > -1) {
                                ftdm_log(FTDM_LOG_DEBUG, "Tracing channel %u:%u input to [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, path);  
                                GOTO_STATUS(done, FTDM_SUCCESS);
                        }
@@ -2731,7 +2732,8 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_co
                                close(ftdmchan->fds[FTDM_WRITE_TRACE_INDEX]);
                                ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] = -1;
                        }
-                       if ((ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
+                       if ((ftdmchan->fds[FTDM_WRITE_TRACE_INDEX] = open(path, O_WRONLY | O_CREAT | O_TRUNC
+                                                       | FTDM_O_BINARY, S_IRUSR | S_IWUSR)) > -1) {
                                ftdm_log(FTDM_LOG_DEBUG, "Tracing channel %u:%u output to [%s]\n", ftdmchan->span_id, ftdmchan->chan_id, path); 
                                GOTO_STATUS(done, FTDM_SUCCESS);
                        }
@@ -3376,7 +3378,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, cons
                                ftdmchan->span_id, ftdmchan->chan_id, 
                                currtime.tm_year-100, currtime.tm_mon+1, currtime.tm_mday,
                                currtime.tm_hour, currtime.tm_min, currtime.tm_sec, ftdmchan->native_codec == FTDM_CODEC_ULAW ? "ulaw" : ftdmchan->native_codec == FTDM_CODEC_ALAW ? "alaw" : "sln");
-               ftdmchan->dtmfdbg.file = fopen(dfile, "w");     
+               ftdmchan->dtmfdbg.file = fopen(dfile, "wb");    
                if (!ftdmchan->dtmfdbg.file) {
                        ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "failed to open debug dtmf file %s\n", dfile);
                } else {
index 6bec6b0cf7853a88323e0b6d6e95e1083d61b1f9..154983357169ef8c31e5d825632439feb9f5119e 100644 (file)
@@ -568,14 +568,14 @@ static void dump_mf(openr2_chan_t *r2chan)
                ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Dumping IO output in prefix %s\n", logname);
                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, "w");
+               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);
 
                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, "w");
+               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);
index 4aba703f28d8ee9438d9ddd9ebbb1db560d233e9..5c57e01a70be0ca53d89dd21f7dc9e9a1acabc6d 100644 (file)
@@ -158,12 +158,14 @@ typedef __int64 int64_t;
 typedef __int32 int32_t;
 typedef __int16 int16_t;
 typedef __int8 int8_t;
+#define FTDM_O_BINARY O_BINARY
 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
 #define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
 #else
 #define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
 #endif /* _MSC_VER */
 #else /* __WINDOWS__ */
+#define FTDM_O_BINARY 0
 #define FTDM_INVALID_SOCKET -1
 typedef int ftdm_socket_t;
 #include <stdio.h>