htpd: trivial simplification in random interval selection
function old new delta poll_interval 57 52 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
8ed9672660
commit
3e78f6f955
@ -1660,13 +1660,14 @@ retry_interval(void)
|
|||||||
static unsigned
|
static unsigned
|
||||||
poll_interval(int exponent)
|
poll_interval(int exponent)
|
||||||
{
|
{
|
||||||
unsigned interval, r;
|
unsigned interval, r, mask;
|
||||||
exponent = G.poll_exp + exponent;
|
exponent = G.poll_exp + exponent;
|
||||||
if (exponent < 0)
|
if (exponent < 0)
|
||||||
exponent = 0;
|
exponent = 0;
|
||||||
interval = 1 << exponent;
|
interval = 1 << exponent;
|
||||||
|
mask = ((interval-1) >> 4) | 1;
|
||||||
r = random();
|
r = random();
|
||||||
interval += ((r & (interval-1)) >> 4) + ((r >> 8) & 1); /* + 1/16 of interval, max */
|
interval += r & mask; /* ~ random(0..1) * interval/16 */
|
||||||
VERB4 bb_error_msg("chose poll interval:%u (poll_exp:%d exp:%d)", interval, G.poll_exp, exponent);
|
VERB4 bb_error_msg("chose poll interval:%u (poll_exp:%d exp:%d)", interval, G.poll_exp, exponent);
|
||||||
return interval;
|
return interval;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user