Browse Source

Rate limit the throbber to one update per second

master
Con Kolivas 10 years ago
parent
commit
713509823f
  1. 13
      src/stratifier.c

13
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) const char *func, const int line)
{ {
static int counter = 0; static int counter = 0;
static time_t time_counter;
ckdb_msg_t *msg; ckdb_msg_t *msg;
time_t now_t;
char ch; char ch;
ch = status_chars[(counter++) & 0x3]; now_t = time(NULL);
fprintf(stdout, "%c\r", ch); if (now_t != time_counter) {
fflush(stdout); /* 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) { if (!val) {
LOGWARNING("Invalid json sent to ckdbq_add from %s %s:%d", file, func, line); LOGWARNING("Invalid json sent to ckdbq_add from %s %s:%d", file, func, line);

Loading…
Cancel
Save