Changeset View
Changeset View
Standalone View
Standalone View
src/ioslaves/file/file_unix.cpp
Show First 20 Lines • Show All 255 Lines • ▼ Show 20 Line(s) | 254 | #endif | |||
---|---|---|---|---|---|
256 | 256 | | |||
257 | KIO::filesize_t processed_size = 0; | 257 | KIO::filesize_t processed_size = 0; | ||
258 | char buffer[ MAX_IPC_SIZE ]; | 258 | char buffer[ MAX_IPC_SIZE ]; | ||
259 | ssize_t n = 0; | 259 | ssize_t n = 0; | ||
260 | #ifdef USE_SENDFILE | 260 | #ifdef USE_SENDFILE | ||
261 | bool use_sendfile = buff_src.st_size < 0x7FFFFFFF; | 261 | bool use_sendfile = buff_src.st_size < 0x7FFFFFFF; | ||
262 | #endif | 262 | #endif | ||
263 | bool existing_dest_delete_attempted = false; | 263 | bool existing_dest_delete_attempted = false; | ||
264 | while (1) { | 264 | while (!wasKilled()) { | ||
265 | #ifdef USE_SENDFILE | 265 | #ifdef USE_SENDFILE | ||
266 | if (use_sendfile) { | 266 | if (use_sendfile) { | ||
dfaure: Maybe in testMode, the slave can become particularly slow for one given filename.
E.g. if… | |||||
267 | off_t sf = processed_size; | 267 | off_t sf = processed_size; | ||
268 | n = ::sendfile(dest_file.handle(), src_file.handle(), &sf, MAX_IPC_SIZE); | 268 | n = ::sendfile(dest_file.handle(), src_file.handle(), &sf, MAX_IPC_SIZE); | ||
269 | processed_size = sf; | 269 | processed_size = sf; | ||
270 | if (n == -1 && (errno == EINVAL || errno == ENOSYS)) { //not all filesystems support sendfile() | 270 | if (n == -1 && (errno == EINVAL || errno == ENOSYS)) { //not all filesystems support sendfile() | ||
271 | // qDebug() << "sendfile() not supported, falling back "; | 271 | // qDebug() << "sendfile() not supported, falling back "; | ||
272 | use_sendfile = false; | 272 | use_sendfile = false; | ||
273 | } | 273 | } | ||
274 | } | 274 | } | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 342 | #ifdef USE_SENDFILE | |||
343 | } | 343 | } | ||
344 | #endif | 344 | #endif | ||
345 | processedSize(processed_size); | 345 | processedSize(processed_size); | ||
346 | } | 346 | } | ||
347 | 347 | | |||
348 | src_file.close(); | 348 | src_file.close(); | ||
349 | dest_file.close(); | 349 | dest_file.close(); | ||
350 | 350 | | |||
351 | if (wasKilled()) { | ||||
352 | qCDebug(KIO_FILE) << "Clean dest file after ioslave was killed:" << dest; | ||||
353 | if (!QFile::remove(dest)) { // don't keep partly copied file | ||||
354 | execWithElevatedPrivilege(DEL, {_dest}, errno); | ||||
355 | } | ||||
356 | finished(); | ||||
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… | |||||
357 | return; | ||||
358 | } | ||||
359 | | ||||
351 | if (dest_file.error() != QFile::NoError) { | 360 | if (dest_file.error() != QFile::NoError) { | ||
352 | qCWarning(KIO_FILE) << "Error when closing file descriptor[2]:" << dest_file.errorString(); | 361 | qCWarning(KIO_FILE) << "Error when closing file descriptor[2]:" << dest_file.errorString(); | ||
353 | error(KIO::ERR_CANNOT_WRITE, dest); | 362 | error(KIO::ERR_CANNOT_WRITE, dest); | ||
354 | #if HAVE_POSIX_ACL | 363 | #if HAVE_POSIX_ACL | ||
355 | if (acl) { | 364 | if (acl) { | ||
356 | acl_free(acl); | 365 | acl_free(acl); | ||
357 | } | 366 | } | ||
358 | #endif | 367 | #endif | ||
▲ Show 20 Lines • Show All 568 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).