Skip to content

Commit 42ce5b9

Browse files
committed
fix: switch to less aggressive backoff algorithm
This results in retry delays of: * 2 seconds * 4 seconds * 6 seconds * 8 seconds * 10 seconds
1 parent 15aa7de commit 42ce5b9

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

palaver.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define ZNC_PALAVER_VERSION "1.2.1"
1111

1212
#include <algorithm>
13-
#include <cmath>
1413

1514
#include <znc/Modules.h>
1615
#include <znc/User.h>
@@ -128,9 +127,9 @@ class RetryStrategy {
128127
}
129128

130129
unsigned int GetDelay(unsigned int uAttempts) {
131-
double minimumBackoff = 1;
132-
double maximumBackoff = 10;
133-
return std::max(std::min(pow((double)uAttempts, 2), maximumBackoff), minimumBackoff);
130+
unsigned int minimumBackoff = 1;
131+
unsigned int maximumBackoff = 10;
132+
return std::max(std::min(uAttempts * 2, maximumBackoff), minimumBackoff);
134133
}
135134
};
136135

test/test_palaver.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ async def connected(reader, writer):
320320
line = await reader.readline()
321321
assert line == b':*[email protected] PRIVMSG admin :Notification sent to 1 clients.\r\n'
322322

323-
await asyncio.sleep(1.2)
323+
await asyncio.sleep(2.2)
324324
server.close()
325325
await server.wait_closed()
326326

@@ -376,7 +376,7 @@ async def connected(reader, writer):
376376
line = await reader.readline()
377377
assert line == b':*[email protected] PRIVMSG admin :Notification sent to 1 clients.\r\n'
378378

379-
await asyncio.sleep(1.2)
379+
await asyncio.sleep(2.2)
380380
server.close()
381381
await server.wait_closed()
382382

@@ -433,7 +433,7 @@ async def connected(reader, writer):
433433
line = await reader.readline()
434434
assert line == b':*[email protected] PRIVMSG admin :Notification sent to 1 clients.\r\n'
435435

436-
await asyncio.sleep(1.2)
436+
await asyncio.sleep(2.2)
437437
server.close()
438438
await server.wait_closed()
439439

0 commit comments

Comments
 (0)