X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/6077e08da9e6c94c708b30bcc088dc468f219627..21f79f2e37db9b37da2522ba7d0e8d6676ddad5b:/lib/base/filepush.cpp diff --git a/lib/base/filepush.cpp b/lib/base/filepush.cpp index a955e10b..51b26239 100644 --- a/lib/base/filepush.cpp +++ b/lib/base/filepush.cpp @@ -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. @@ -47,6 +49,7 @@ void eFilePushThread::thread() if (m_buf_start != m_buf_end) { // TODO: take care of boundaries. + filterRecordData(m_buffer + m_buf_start, m_buf_end - m_buf_start); int w = write(m_fd_dest, m_buffer + m_buf_start, m_buf_end - m_buf_start); // eDebug("wrote %d bytes", w); if (w <= 0) @@ -59,8 +62,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 +105,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) { @@ -189,3 +205,9 @@ void eFilePushThread::recvEvent(const int &evt) { m_event(evt); } + +void eFilePushThread::filterRecordData(const unsigned char *data, int len) +{ + /* do nothing */ +} +