From 713509823f73c430e1f9d5ab1611a1a424653942 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 7 Aug 2014 22:25:51 +1000 Subject: [PATCH] Rate limit the throbber to one update per second --- src/stratifier.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 37ede260..ea44d8e9 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -419,12 +419,19 @@ static void _ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val, const char const char *func, const int line) { static int counter = 0; + static time_t time_counter; ckdb_msg_t *msg; + time_t now_t; char ch; - ch = status_chars[(counter++) & 0x3]; - fprintf(stdout, "%c\r", ch); - fflush(stdout); + now_t = time(NULL); + if (now_t != time_counter) { + /* Rate limit to 1 update per second */ + time_counter = now_t; + ch = status_chars[(counter++) & 0x3]; + fprintf(stdout, "%c\r", ch); + fflush(stdout); + } if (!val) { LOGWARNING("Invalid json sent to ckdbq_add from %s %s:%d", file, func, line);