i2pd/fuzzing/fuzzing_throttle.cc
Chad Fraleigh 5f6bbd3eb9
Added undefined behavior sanitizer.
Combined common sanitizer flags.
Added fuzzers.
2023-07-10 18:35:34 -07:00

33 lines
469 B
C++

#include <thread>
#include "fuzzing.h"
static unsigned int counter = 0;
void
fuzzing_tick(void)
{
counter++;
}
void
fuzzing_throttle(void)
{
unsigned int delay;
// Give queues time to drain (avoid OOM or crash)
// - Too high a delay slows down fuzzing
// - Too low a delay causes intermittent crash on exit
delay = 50 + (counter / 50);
counter = 0;
if(delay > 5000)
delay = 5000;
std::this_thread::sleep_for (std::chrono::milliseconds(delay));
}