]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
try to rotate on failed write to cdr file
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 22 Sep 2009 15:36:53 +0000 (15:36 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 22 Sep 2009 15:36:53 +0000 (15:36 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14948 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c

index c56b44f8f797cf1f1e886d847a275414304f1a53..11cb43880b9132b7608a7acc92f4e6a1c34dcddf 100644 (file)
@@ -129,6 +129,7 @@ static void write_cdr(const char *path, const char *log_line)
 {
        cdr_fd_t *fd = NULL;
        unsigned int bytes_in, bytes_out;
+       int loops = 0;
 
        if (!(fd = switch_core_hash_find(globals.fd_hash, path))) {
                fd = switch_core_alloc(globals.pool, sizeof(*fd));
@@ -155,11 +156,15 @@ static void write_cdr(const char *path, const char *log_line)
                do_rotate(fd);
        }
 
-       if ((bytes_in = write(fd->fd, log_line, bytes_out)) != bytes_out) {
+       while ((bytes_in = write(fd->fd, log_line, bytes_out)) != bytes_out && ++loops < 10) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Write error to file %s %d/%d\n", path, (int) bytes_in, (int) bytes_out);
+               do_rotate(fd);
+               switch_yield(250000);
+       }
+       
+       if (bytes_in > 0) {
+               fd->bytes += bytes_in;
        }
-
-       fd->bytes += bytes_in;
 
   end: