continue on EOVERFLOW, use fdatasync every now and then
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 2 Feb 2006 21:15:16 +0000 (21:15 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 2 Feb 2006 21:15:16 +0000 (21:15 +0000)
lib/base/filepush.cpp

index a955e10b20e952f239d00690f6dcb3dded9208fc..705dbb5ea8ec88ceab99e3e50a1db684fa3f2d64 100644 (file)
@@ -27,6 +27,8 @@ void eFilePushThread::thread()
        off_t current_span_offset = 0;
        size_t current_span_remaining = 0;
        
+       size_t written_since_last_sync = 0;
+       
        int already_empty = 0;
        eDebug("FILEPUSH THREAD START");
                // this is a race. FIXME.
@@ -59,8 +61,16 @@ void eFilePushThread::thread()
 
                                /* this should flush all written pages to disk. */
                        posix_fadvise(m_fd_dest, dest_pos, w, POSIX_FADV_DONTNEED);
-
+                       
                        dest_pos += w;
+                       written_since_last_sync += w;
+                       
+                       if (written_since_last_sync >= 512*1024)
+                       {
+                               fdatasync(m_fd_dest);
+                               written_since_last_sync = 0;
+                       }
+
 //                     printf("FILEPUSH: wrote %d bytes\n", w);
                        m_buf_start += w;
                        continue;
@@ -94,7 +104,12 @@ void eFilePushThread::thread()
                        m_buf_end = 0;
                        if (errno == EINTR)
                                continue;
-                       eDebug("eFilePushThread *read error* - not yet handled");
+                       if (errno == EOVERFLOW)
+                       {
+                               eWarning("OVERFLOW while recording");
+                               continue;
+                       }
+                       eDebug("eFilePushThread *read error* (%m) - not yet handled");
                }
                if (m_buf_end == 0)
                {