Add probabilistic use of TCP_FASTOPEN and close()

This commit is contained in:
Ian Gulliver
2016-03-05 15:27:11 -08:00
parent cef259f5c4
commit 46d67ca376
4 changed files with 54 additions and 14 deletions

9
rand.c
View File

@@ -50,3 +50,12 @@ void rand_fill(void *value, size_t size) {
rand_buf.start = 0;
rand_buf.length = BUF_LEN_MAX;
}
bool rand_yes_no(uint64_t mean_yes_period) {
if (!mean_yes_period) {
return false;
}
uint64_t val;
rand_fill(&val, sizeof(val));
return !(val % mean_yes_period);
}