From b79896cceedf81df7873850f38e5e2c4ad3e3e57 Mon Sep 17 00:00:00 2001 From: Magnus Edenhill Date: Tue, 3 May 2016 19:12:03 +0200 Subject: [PATCH] Seed rng for proper random partitioning, jitters, etc. --- kafkacat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kafkacat.c b/kafkacat.c index 2a0c20bb..0e63f919 100644 --- a/kafkacat.c +++ b/kafkacat.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -1243,11 +1244,16 @@ static void conf_dump (void) { int main (int argc, char **argv) { char tmp[16]; FILE *in = stdin; + struct timeval tv; signal(SIGINT, term); signal(SIGTERM, term); signal(SIGPIPE, term); + /* Seed rng for random partitioner, jitter, etc. */ + gettimeofday(&tv, NULL); + srand(tv.tv_usec); + /* Create config containers */ conf.rk_conf = rd_kafka_conf_new(); conf.rkt_conf = rd_kafka_topic_conf_new();