Skip to content

Commit

Permalink
Keep old clients from removing message rate delay
Browse files Browse the repository at this point in the history
Add a guard against zero message delay in setMessageRateDelay,
following the error-checking of setMessageRateBurstSize.  This blocks
old clients from setting message rate delay to 0 seconds for newly-
created networks, improperly overriding the default of 2.2 seconds.

This affects creating a network in an old client, switching to a new
client, then enabling custom rate-limits.

The supported method for removing rate limits by setting Unlimited to
true still works.

Resolves quasselGH-252.
  • Loading branch information
digitalcircuit authored and javierllorente committed Jan 6, 2017
1 parent 98ef9b0 commit 208ee02
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/common/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,10 @@ void Network::setUseCustomMessageRate(bool useCustomRate)
void Network::setMessageRateBurstSize(quint32 burstSize)
{
if (burstSize < 1) {
// Can't go slower than one message at a time
qWarning() << "Received invalid setMessageRateBurstSize data, cannot have zero message "
"burst size!" << burstSize;
// Can't go slower than one message at a time. Also blocks old clients from trying to set
// this to 0.
qWarning() << "Received invalid setMessageRateBurstSize data - message burst size must be "
"non-zero positive, given" << burstSize;
return;
}
if (_messageRateBurstSize != burstSize) {
Expand All @@ -723,6 +724,13 @@ void Network::setMessageRateBurstSize(quint32 burstSize)

void Network::setMessageRateDelay(quint32 messageDelay)
{
if (messageDelay == 0) {
// Nonsensical to have no delay - just check the Unlimited box instead. Also blocks old
// clients from trying to set this to 0.
qWarning() << "Received invalid setMessageRateDelay data - message delay must be non-zero "
"positive, given" << messageDelay;
return;
}
if (_messageRateDelay != messageDelay) {
_messageRateDelay = messageDelay;
SYNC(ARG(messageDelay))
Expand Down

0 comments on commit 208ee02

Please sign in to comment.