From 34c2a66a35b0502328bb8a54e48e116a20c6828a Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sat, 29 Oct 2016 01:03:18 +1100 Subject: [PATCH] Improve accuracy of DCC LIST speed and ETA calculations Switch from using whole-second time_t values to fractional values calculated with time_since(). --- source/dcc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/dcc.c b/source/dcc.c index 32073a4..19d359e 100644 --- a/source/dcc.c +++ b/source/dcc.c @@ -2573,7 +2573,7 @@ void dcc_glist(char *command, char *args) } for (i = 0; i < get_max_fd() + 1; i++, count++) { - time_t xtime; + double xtime; char *filename, *p; const char *type_name; @@ -2584,10 +2584,14 @@ void dcc_glist(char *command, char *args) type = s->flags & DCC_TYPES; tdcc = s->flags & DCC_TDCC; type_name = dcc_type_name(type, tdcc); - xtime = now - n->starttime.tv_sec; + + if (s->flags & DCC_ACTIVE) + xtime = time_since(&n->starttime); + else + xtime = time_since(&n->lasttime); - if (xtime <= 0) - xtime = 1; + if (xtime <= 0.0) + xtime = 1e-3; filename = LOCAL_COPY(n->filename); p = filename; @@ -2598,8 +2602,6 @@ void dcc_glist(char *command, char *args) if (!(s->flags & DCC_ACTIVE) || (type == DCC_CHAT) || (type == DCC_RAW) || (type == DCC_BOTMODE) || (type == DCC_FTPOPEN)) { - if (!(s->flags & DCC_ACTIVE)) - xtime = now - n->lasttime.tv_sec; if (do_hook(DCC_STAT_LIST, "%d %s %s %s %s %s %s", n->dccnum, type_name, s->server, dcc_get_state(s),