From e9bd61c21222d68eece0637e6faba1ca3a1b4d4c Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 7 Aug 2014 15:15:54 +1000 Subject: [PATCH] ckdb - time limited ticker --- src/ckdb.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 5fcd9f80..2e940198 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -7382,6 +7382,24 @@ static void *summariser(__maybe_unused void *arg) return NULL; } +static uint64_t ticks; +static time_t last_tick; + +static void tick() +{ + time_t now; + char ch; + + now = time(NULL); + if (now > last_tick) { + last_tick = now; + ch = status_chars[ticks++ & 0x3]; + putchar(ch); + putchar('\r'); + fflush(stdout); + } +} + static bool reload_line(char *filename, uint64_t count, char *buf) { char cmd[CMD_SIZ+1], id[ID_SIZ+1]; @@ -7449,10 +7467,7 @@ static bool reload_line(char *filename, uint64_t count, char *buf) } } - char ch = status_chars[count & 0x3]; - putchar(ch); - putchar('\r'); - fflush(stdout); + tick(); K_WLOCK(transfer_free); transfer_root = free_ktree(transfer_root, NULL); @@ -7720,10 +7735,8 @@ static void *listener(void *arg) } close(sockd); - char ch = status_chars[(counter++) & 0x3]; - putchar(ch); - putchar('\r'); - fflush(stdout); + counter++; + tick(); if (cmdnum == CMD_SHUTDOWN) break;