mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-23 17:36:37 +02:00
33 lines
469 B
C++
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));
|
|
}
|