SlaveBase::dispatchLoop: Fix timeout calculation
ClosedPublic

Authored by kfunk on Jan 2 2020, 1:23 PM.

Details

Summary

Old version of the code:

ms = qMax<int>(d->nextTimeout.elapsed() - d->nextTimeoutMsecs, 1);

... will mean the sleep is for as long as the timer has run *minus* the
intended duration, so if nextTimeoutMsecs is ever set and the timer just
started this becomes very negative, and 1ms is the result.

Inverting the subtraction:

ms = qMax<int>(d->nextTimeoutMsecs - d->nextTimeout.elapsed(), 1);

Means sleeping for the remaining time, and so far my CPU seems much
happier, with my KIO-HTTP using apps looking fine.

BUG: 392768

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kfunk created this revision.Jan 2 2020, 1:23 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 2 2020, 1:23 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
kfunk requested review of this revision.Jan 2 2020, 1:23 PM
kfunk added a reviewer: broulik.
dfaure accepted this revision.Jan 3 2020, 9:23 PM

Yep. Bug in D9983.

This revision is now accepted and ready to land.Jan 3 2020, 9:23 PM
Closed by commit R241:27271405f408: SlaveBase::dispatchLoop: Fix timeout calculation (authored by Julien Goodwin <jgoodwin@studio442.com.au>, committed by kfunk). · Explain WhyJan 9 2020, 2:18 PM
This revision was automatically updated to reflect the committed changes.