Changeset View
Changeset View
Standalone View
Standalone View
src/ioslaves/file/file_unix.cpp
Show First 20 Lines • Show All 305 Lines • ▼ Show 20 Line(s) | 304 | #endif | |||
---|---|---|---|---|---|
306 | 306 | | |||
307 | KIO::filesize_t processed_size = 0; | 307 | KIO::filesize_t processed_size = 0; | ||
308 | char buffer[ MAX_IPC_SIZE ]; | 308 | char buffer[ MAX_IPC_SIZE ]; | ||
309 | ssize_t n = 0; | 309 | ssize_t n = 0; | ||
310 | #ifdef USE_SENDFILE | 310 | #ifdef USE_SENDFILE | ||
311 | bool use_sendfile = buff_src.st_size < 0x7FFFFFFF; | 311 | bool use_sendfile = buff_src.st_size < 0x7FFFFFFF; | ||
312 | #endif | 312 | #endif | ||
313 | bool existing_dest_delete_attempted = false; | 313 | bool existing_dest_delete_attempted = false; | ||
314 | while (1) { | 314 | while (!wasKilled()) { | ||
315 | #ifdef USE_SENDFILE | 315 | #ifdef USE_SENDFILE | ||
316 | if (use_sendfile) { | 316 | if (use_sendfile) { | ||
dfaure: Maybe in testMode, the slave can become particularly slow for one given filename.
E.g. if… | |||||
317 | off_t sf = processed_size; | 317 | off_t sf = processed_size; | ||
318 | n = ::sendfile(dest_file.handle(), src_file.handle(), &sf, MAX_IPC_SIZE); | 318 | n = ::sendfile(dest_file.handle(), src_file.handle(), &sf, MAX_IPC_SIZE); | ||
319 | processed_size = sf; | 319 | processed_size = sf; | ||
320 | if (n == -1 && (errno == EINVAL || errno == ENOSYS)) { //not all filesystems support sendfile() | 320 | if (n == -1 && (errno == EINVAL || errno == ENOSYS)) { //not all filesystems support sendfile() | ||
321 | // qDebug() << "sendfile() not supported, falling back "; | 321 | // qDebug() << "sendfile() not supported, falling back "; | ||
322 | use_sendfile = false; | 322 | use_sendfile = false; | ||
323 | } | 323 | } | ||
324 | } | 324 | } | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 392 | #ifdef USE_SENDFILE | |||
393 | } | 393 | } | ||
394 | #endif | 394 | #endif | ||
395 | processedSize(processed_size); | 395 | processedSize(processed_size); | ||
396 | } | 396 | } | ||
397 | 397 | | |||
398 | src_file.close(); | 398 | src_file.close(); | ||
399 | dest_file.close(); | 399 | dest_file.close(); | ||
400 | 400 | | |||
401 | if (wasKilled()) { | ||||
402 | qCDebug(KIO_FILE) << "Clean dest file after ioslave was killed:" << dest; | ||||
403 | if (!QFile::remove(dest)) { // don't keep partly copied file | ||||
404 | execWithElevatedPrivilege(DEL, {_dest}, errno); | ||||
405 | } | ||||
406 | error(KIO::ERR_USER_CANCELED, dest); | ||||
shouldn't this be error(KIO::ERR_USER_CANCELED) instead? It's not like the copy actually succeeded... dfaure: shouldn't this be error(KIO::ERR_USER_CANCELED) instead? It's not like the copy actually… | |||||
407 | return; | ||||
408 | } | ||||
409 | | ||||
401 | if (dest_file.error() != QFile::NoError) { | 410 | if (dest_file.error() != QFile::NoError) { | ||
402 | qCWarning(KIO_FILE) << "Error when closing file descriptor[2]:" << dest_file.errorString(); | 411 | qCWarning(KIO_FILE) << "Error when closing file descriptor[2]:" << dest_file.errorString(); | ||
403 | error(KIO::ERR_CANNOT_WRITE, dest); | 412 | error(KIO::ERR_CANNOT_WRITE, dest); | ||
404 | #if HAVE_POSIX_ACL | 413 | #if HAVE_POSIX_ACL | ||
405 | if (acl) { | 414 | if (acl) { | ||
406 | acl_free(acl); | 415 | acl_free(acl); | ||
407 | } | 416 | } | ||
408 | #endif | 417 | #endif | ||
▲ Show 20 Lines • Show All 569 Lines • Show Last 20 Lines |
Maybe in testMode, the slave can become particularly slow for one given filename.
E.g. if (testMode && fileName.contains("slow"))
This way, for other files, it remains fast, and for that one file it can be really reliably slow (possibly sleeping for a whole second, or something like that).
It also makes the more generically named "KIOSLAVE_FILE_ENABLE_TESTMODE" available for enabling other kinds of "test mode" in the ioslave (the filename acting as an additional switch).