Ticket #1076: 1076.patch
File 1076.patch, 3.7 KB (added by , 19 years ago) |
---|
-
libs/libmythtv/ThreadedFileWriter.cpp
7 7 #include <sys/types.h> 8 8 #include <sys/stat.h> 9 9 #include <unistd.h> 10 #include <signal.h> 10 11 #include <fcntl.h> 11 12 12 13 // MythTV headers … … 35 36 * to the stream. 36 37 */ 37 38 38 /** \fn safe_write(int, const void*, uint )39 /** \fn safe_write(int, const void*, uint, bool &ok) 39 40 * \brief Writes data to disk 40 41 * 41 42 * This just uses the Standard C write() to write to disk. … … 46 47 * \param data Pointer to data to write 47 48 * \param sz Size of data to write in bytes 48 49 */ 49 static uint safe_write(int fd, const void *data, uint sz )50 static uint safe_write(int fd, const void *data, uint sz, bool &ok) 50 51 { 51 52 int ret; 52 53 uint tot = 0; … … 81 82 usleep(1000); 82 83 } 83 84 } 85 ok = (errcnt < 3); 84 86 return tot; 85 87 } 86 88 … … 89 91 */ 90 92 void *ThreadedFileWriter::boot_writer(void *wotsit) 91 93 { 94 signal(SIGXFSZ, SIG_IGN); 92 95 ThreadedFileWriter *fw = (ThreadedFileWriter *)wotsit; 93 96 fw->DiskLoop(); 94 97 return NULL; … … 114 117 mode(pmode), fd(-1), 115 118 // state 116 119 no_writes(false), flush(false), 117 in_dtor(false), 120 in_dtor(false), ignore_writes(false), 118 121 tfw_min_write_size(0), 119 122 // buffer position state 120 123 rpos(0), wpos(0), … … 130 133 */ 131 134 bool ThreadedFileWriter::Open(void) 132 135 { 136 ignore_writes = false; 133 137 fd = open(filename.ascii(), flags, mode); 134 138 135 139 if (fd < 0) … … 362 366 the 10% that was free... */ 363 367 size = (size > TFW_MAX_WRITE_SIZE) ? TFW_MAX_WRITE_SIZE : size; 364 368 365 if ((rpos + size) > tfw_buf_size) 369 bool write_ok; 370 if (ignore_writes) 371 ; 372 else if ((rpos + size) > tfw_buf_size) 366 373 { 367 374 int first_chunk_size = tfw_buf_size - rpos; 368 375 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); 372 379 } 373 380 else 374 381 { 375 size = safe_write(fd, buf+rpos, size );382 size = safe_write(fd, buf+rpos, size, write_ok); 376 383 } 377 384 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 378 398 if (written < tfw_min_write_size) 379 399 { 380 400 written += size; -
libs/libmythtv/ThreadedFileWriter.h
46 46 bool flush; 47 47 bool write_is_blocked; 48 48 bool in_dtor; 49 bool ignore_writes; 49 50 long long tfw_min_write_size; 50 51 51 52 // buffer position state