Summary: | Spawning insane amounts of DBus messages while copying files | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kio | Reporter: | Kevin Funk <kfunk> |
Component: | general | Assignee: | David Faure <faure> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | davidgiloliva, kdelibs-bugs |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://commits.kde.org/kio/801f58e7e76acd4bcb23d6e8092825cdda203a81 | Version Fixed In: | 5.38 |
Description
Kevin Funk
2017-08-22 11:40:20 UTC
This looks really bad...: 528│ void SlaveBase::processedSize(KIO::filesize_t _bytes) 529│ { 530├> bool emitSignal = false; 531│ 532│ QDateTime now = QDateTime::currentDateTime(); 533│ 534│ if (_bytes == d->totalSize) { 535│ emitSignal = true; 536│ } else { 537│ if (d->lastTimeout.isValid()) { 538│ emitSignal = d->lastTimeout.msecsTo(now); // emit size 10 times a second 539│ } else { 540│ emitSignal = true; 541│ } 542│ } 538│ emitSignal = d->lastTimeout.msecsTo(now); // emit size 10 times a second ^ This expression is totally wrong, isn't it? It doesn't do what the comment says. It will evaluate to true if there's just a millisecond time difference => signal will be emitted every ms? Introduced by this commit: commit dca3d5cfd19375f61dd7d8232586227af3f4b34b Author: David Gil <davidgiloliva@gmail.com> Date: Fri Jun 7 22:06:15 2013 +0200 Port time_t to QDateTime in SlaveBase (KIO) ... with the following interesting hunks of the diff: -void SlaveBase::processedSize( KIO::filesize_t _bytes ) +void SlaveBase::processedSize(KIO::filesize_t _bytes) { - bool emitSignal=false; - struct timeval tv; - int gettimeofday_res=gettimeofday( &tv, 0L ); + bool emitSignal = false; + + QDateTime now = QDateTime::currentDateTime(); - if( _bytes == d->totalSize ) + if (_bytes == d->totalSize) emitSignal=true; - else if ( gettimeofday_res == 0 ) { - time_t msecdiff = 2000; - if (d->last_tv.tv_sec) { - // Compute difference, in ms - msecdiff = 1000 * ( tv.tv_sec - d->last_tv.tv_sec ); - time_t usecdiff = tv.tv_usec - d->last_tv.tv_usec; - if ( usecdiff < 0 ) { - msecdiff--; - msecdiff += 1000; - } - msecdiff += usecdiff / 1000; - } - emitSignal=msecdiff >= 100; // emit size 10 times a second + else { + if (d->lastTimeout.isValid()) + emitSignal = d->lastTimeout.msecsTo(now); // emit size 10 times a second + else + emitSignal = true; } - if( emitSignal ) { + if (emitSignal) { KIO_DATA << KIO_FILESIZE_T(_bytes); - send( INF_PROCESSED_SIZE, data ); - if ( gettimeofday_res == 0 ) { - d->last_tv.tv_sec = tv.tv_sec; - d->last_tv.tv_usec = tv.tv_usec; - } + send(INF_PROCESSED_SIZE, data); + d->lastTimeout = now; } -// d->processed_size = _bytes; + + // d->processed_size = _bytes; } Git commit 801f58e7e76acd4bcb23d6e8092825cdda203a81 by Kevin Funk. Committed on 22/08/2017 at 14:43. Pushed by kfunk into branch 'master'. Really rate-limit INF_PROCESSED_SIZE messages Summary: Fixing an ancient porting bug which popped up when porting from Qt4 to Qt5. FIXED-IN: 5.38 Reviewers: dfaure Reviewed By: dfaure Subscribers: dfaure, #frameworks Tags: #frameworks Differential Revision: https://phabricator.kde.org/D7463 M +1 -1 src/core/slavebase.cpp https://commits.kde.org/kio/801f58e7e76acd4bcb23d6e8092825cdda203a81 |