Ticket #1076: 1076.patch

File 1076.patch, 3.7 KB (added by danielk, 19 years ago)

Simple fix

  • libs/libmythtv/ThreadedFileWriter.cpp

     
    77#include <sys/types.h>
    88#include <sys/stat.h>
    99#include <unistd.h>
     10#include <signal.h>
    1011#include <fcntl.h>
    1112
    1213// MythTV headers
     
    3536 *   to the stream.
    3637 */
    3738
    38 /** \fn safe_write(int, const void*, uint)
     39/** \fn safe_write(int, const void*, uint, bool &ok)
    3940 *  \brief Writes data to disk
    4041 *
    4142 *   This just uses the Standard C write() to write to disk.
     
    4647 *  \param data Pointer to data to write
    4748 *  \param sz   Size of data to write in bytes
    4849 */
    49 static uint safe_write(int fd, const void *data, uint sz)
     50static uint safe_write(int fd, const void *data, uint sz, bool &ok)
    5051{
    5152    int ret;
    5253    uint tot = 0;
     
    8182            usleep(1000);
    8283        }
    8384    }
     85    ok = (errcnt < 3);
    8486    return tot;
    8587}
    8688
     
    8991 */
    9092void *ThreadedFileWriter::boot_writer(void *wotsit)
    9193{
     94    signal(SIGXFSZ, SIG_IGN);
    9295    ThreadedFileWriter *fw = (ThreadedFileWriter *)wotsit;
    9396    fw->DiskLoop();
    9497    return NULL;
     
    114117    mode(pmode),                         fd(-1),
    115118    // state
    116119    no_writes(false),                    flush(false),
    117     in_dtor(false),
     120    in_dtor(false),                      ignore_writes(false),
    118121    tfw_min_write_size(0),
    119122    // buffer position state
    120123    rpos(0),                             wpos(0),
     
    130133 */
    131134bool ThreadedFileWriter::Open(void)
    132135{
     136    ignore_writes = false;
    133137    fd = open(filename.ascii(), flags, mode);
    134138
    135139    if (fd < 0)
     
    362366           the 10% that was free... */
    363367        size = (size > TFW_MAX_WRITE_SIZE) ? TFW_MAX_WRITE_SIZE : size;
    364368
    365         if ((rpos + size) > tfw_buf_size)
     369        bool write_ok;
     370        if (ignore_writes)
     371            ;
     372        else if ((rpos + size) > tfw_buf_size)
    366373        {
    367374            int first_chunk_size  = tfw_buf_size - rpos;
    368375            int second_chunk_size = size - first_chunk_size;
    369             size = safe_write(fd, buf+rpos, first_chunk_size);
    370             if ((int)size == first_chunk_size)
    371                 size += safe_write(fd, buf, second_chunk_size);
     376            size = safe_write(fd, buf+rpos, first_chunk_size, write_ok);
     377            if ((int)size == first_chunk_size && write_ok)
     378                size += safe_write(fd, buf, second_chunk_size, write_ok);
    372379        }
    373380        else
    374381        {
    375             size = safe_write(fd, buf+rpos, size);
     382            size = safe_write(fd, buf+rpos, size, write_ok);
    376383        }
    377384
     385        QString msg =
     386            "Maximum file size exceeded by '%1'\n\t\t\t"
     387            "You must either change the process ulimits, configure\n\t\t\t"
     388            "your operating system with \"Large File\" support, or use\n\t\t\t"
     389            "a filesystem which supports 64-bit or 128-bit files.\n\t\t\t"
     390            "HINT: FAT32 is a 32-bit filesystem.";
     391
     392        if (!ignore_writes && !write_ok && (EFBIG == errno))
     393        {
     394            VERBOSE(VB_IMPORTANT, msg.arg(filename));
     395            ignore_writes = true;
     396        }
     397
    378398        if (written < tfw_min_write_size)
    379399        {
    380400            written += size;
  • libs/libmythtv/ThreadedFileWriter.h

     
    4646    bool            flush;
    4747    bool            write_is_blocked;
    4848    bool            in_dtor;
     49    bool            ignore_writes;
    4950    long long       tfw_min_write_size;
    5051
    5152    // buffer position state