Move retry delay calculation into wakeup, since it's only used there.

This commit is contained in:
Ian Gulliver
2016-02-22 16:33:00 -08:00
parent d6a629fa7e
commit 21536eee33
6 changed files with 16 additions and 23 deletions

View File

@@ -11,7 +11,6 @@
#include <errno.h>
#include "common.h"
#include "rand.h"
#include "uuid.h"
#include "wakeup.h"
@@ -229,16 +228,3 @@ void hex_from_int_upper(char *out, uint64_t in, size_t bytes) {
void hex_from_int_lower(char *out, uint64_t in, size_t bytes) {
hex_from_int(out, in, bytes, hex_lower_table);
}
#define RETRY_MIN_MS 2000
#define RETRY_MAX_MS 60000
uint32_t retry_get_delay_ms(uint32_t attempt) {
uint32_t max_delay = RETRY_MIN_MS * (1 << attempt);
max_delay = max_delay > RETRY_MAX_MS ? RETRY_MAX_MS : max_delay;
uint32_t jitter;
rand_fill(&jitter, sizeof(jitter));
return jitter % max_delay;
}